Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > samples
2021-09-12 03:20
ws

Registered: Apr 2012
Posts: 228
samples

ok, so, a long time ago, i did this:
http://dl.dataelephant.net/wl-hitormiss.prg <-- main prg (yes, it has a sample of hit or miss by ilovefriday, ffs.)

the audio data of which is built upon this script:
http://dl.dataelephant.net/conv16to8samp_unsignedraw_HITORMISS...
which converts this raw data to "c64 hi-lo-nybble 4-bit": http://dl.dataelephant.net/hitormiss8khz8bitunsigned.raw

my c64 prg uses a "mahoney-style" SID-setup and writes values to d418 in a "as fast as possible, because additional code" loop..

;--gethi    lda   ($fe),y ;load hi-lo nybble merged sample
            pha           ;store for lo-nybble later usage

processhi   lsr
            lsr
            lsr
            lsr
(..)
            sta   $d418
(..)

;-- getlow  pla 
            and   #$0f
(..)
            sta   $d418
(..)
            bne   loop

(..) = interim stuff, sprite coords writing.



the question is - why is there this modulation in my sample output? i tried so many things to alter the d418 writing, i just don't understand where the frequency modulation is coming from. (see .prg link above) for example the voice sounds like it has a 50-60-hz modulation to it. i'd rather have it more noisy like in: Der rosarote Panther
where in contrary the noise is very extreme. what am i doing wrong?
i also fail to understand the code .. is this also some 4-bit decoding thing? or 5bit? what is with the adc #$02??

$0a59 LDA #$01
$0a5b BIT $DD0D
      BEQ $0A5B ; some timer thing obviously
      LDA #$00  ; ...
      ROL $07   ; this obviously contains sample data every loop
      ROL       ; okay another bit up the hill
      ROL $07   ; okay get another bit in (is this "scaling"?)
      ROL       ; ye
      ROL       ; ah... 
      ADC #$02  ; ? why ?
      STA $D418



the noise level of the pink panther sample is extreme, but i don't understand why it doesn't have the modulation problem of my attempt. (or does it? is this normal?)

roast me.

best
WS
2021-09-12 03:53
ws

Registered: Apr 2012
Posts: 228
for a moment i had doubts if it might be the sub bass of the tune that might cause the modulation but no, it must be something i'am doing wrong.

http://dl.dataelephant.net/wl-hitormiss-hipass.prg

(frequencies removed below 150 hz to avoid too much amplitude modulation, but that is obiously not my problem)
(also yes, this is a bit slower since i had to make sure d000 read is covered since this is the longer version of the sample)
2021-09-12 04:25
ws

Registered: Apr 2012
Posts: 228
in the name of science, here is the 16 bit mono wav loop, zip pw is missya
http://dl.dataelephant DOT net/hit-r-misz.zip
2021-09-12 07:37
Oswald

Registered: Apr 2002
Posts: 5017
your d418 writes are not evenly spaced (cycles between them in the main loop), maybe that is the problem ?
2021-09-12 11:32
tlr

Registered: Sep 2003
Posts: 1714
I agree with Oswald. If you have unevenly spaced $d418 writes you are going to introduce a modulation.

When you do the playback using a timed loop like in the original post, if you have the screen open and/or sprites enabled you will get quite large timing glitches because of badlines. This will introduce even bigger modulation.

The Paulchen Panther playback routine you posted seems to use a timer to pace the writes. This will keep the average timing correct, but you will still have problems with badlines if not care is taken to deliberately have the writes miss those.

That code is using 2-bit samples with the $d418 values mapped to 2,4,6 and 8.
2021-09-12 11:36
Krill

Registered: Apr 2002
Posts: 2839
There seem to be a lot of variables here you want to rule out.

To get down to this, first you should reduce everything to just the sample routine, screen and sprites off, with stable replay points for your samples.
Your actual replay rate should match the expected replay rate as implicit in your converted samples, and yes, as Oswald mentioned, the same number of cycles between any two sample writes.

One little thing i don't get is your mention of "Mahoney-style" SID-setup. What is that? :) You're replaying good old 4-bit samples, not using Mahoney's novel approach.
2021-09-12 14:18
ws

Registered: Apr 2012
Posts: 228
Thank you so much. Now i finally understand. And now i also finally understand that timing is of the essence in nearly every case on the c64. I really erroneously believed the SID was somehow independent of that.

And about the "mahoney style setup", i believed that was the current way to set up the sid for not having to use a high-freq-carrier-sound. But again, that was a misunderstanding.
I somehow also didn't fully understand how to use his "new" method with the clicks, i remember now and that setup was just some sort of leftover, that seemed to work somehow, magically.

Well you never know how much you don't know. Sheesh.
I will now go & try & fix all of these things.
Thanks alot, guys!
2021-09-12 14:27
Krill

Registered: Apr 2002
Posts: 2839
Note that you can have stable sample replay with screen and sprites enabled.
But this requires carefully designing your player routine (and sample replay rate) around the DMA slots for badlines and sprites.

(Also note that things like sprite gaps exists to make for stable timing regardless of certain sprites being enabled/active in a rasterline or not.)
2021-09-14 21:23
Pex Mahoney Tufvesson

Registered: Sep 2003
Posts: 50
ws: I agree with Krill. Make a small routine with $d011 set to screen disabled. Then, start counting clock cycles in your loop. The writes to $d418 needs to be in perfect distance from eachother.

Then, of course, there are many nice tricks you can do to improve this. The most advanced I've done is enable screen (which steals ~40 clock cycles every 8'th raster line), and use moving sprites on screen - while playing samples in 60kHz. This was done in the demo We are Demo: We Are Demo ...the trick there was to profile the code and use the vice emulator monitor to get an exact clock cycle number for _every single write_ to $d418. Then, use this list of timings for those 15000 writes and adjust the encoding of the samples to align despite those missed clock cycles.

Abouth "Mahoney-style" samples: what I did was improve the 4-bit sample playing to somewhere around 6.5-bit using imperfections in the filters. But that's another story.

---
Have a noise night!
http://mahoney.c64.org
2021-09-15 15:54
ChristopherJam

Registered: Aug 2004
Posts: 1378
Quoting Pex Mahoney Tufvesson
Then, use this list of timings for those 15000 writes and adjust the encoding of the samples to align despite those missed clock cycles.


Haha I'd been wondering about doing something like that. Of course Pex got there first! Respect as always :)
2021-10-24 17:51
DeMOSic

Registered: Aug 2021
Posts: 126
Quote: ok, so, a long time ago, i did this:
http://dl.dataelephant.net/wl-hitormiss.prg <-- main prg (yes, it has a sample of hit or miss by ilovefriday, ffs.)

the audio data of which is built upon this script:
http://dl.dataelephant.net/conv16to8samp_unsignedraw_HITORMISS...
which converts this raw data to "c64 hi-lo-nybble 4-bit": http://dl.dataelephant.net/hitormiss8khz8bitunsigned.raw

my c64 prg uses a "mahoney-style" SID-setup and writes values to d418 in a "as fast as possible, because additional code" loop..

;--gethi    lda   ($fe),y ;load hi-lo nybble merged sample
            pha           ;store for lo-nybble later usage

processhi   lsr
            lsr
            lsr
            lsr
(..)
            sta   $d418
(..)

;-- getlow  pla 
            and   #$0f
(..)
            sta   $d418
(..)
            bne   loop

(..) = interim stuff, sprite coords writing.



the question is - why is there this modulation in my sample output? i tried so many things to alter the d418 writing, i just don't understand where the frequency modulation is coming from. (see .prg link above) for example the voice sounds like it has a 50-60-hz modulation to it. i'd rather have it more noisy like in: Der rosarote Panther
where in contrary the noise is very extreme. what am i doing wrong?
i also fail to understand the code .. is this also some 4-bit decoding thing? or 5bit? what is with the adc #$02??

$0a59 LDA #$01
$0a5b BIT $DD0D
      BEQ $0A5B ; some timer thing obviously
      LDA #$00  ; ...
      ROL $07   ; this obviously contains sample data every loop
      ROL       ; okay another bit up the hill
      ROL $07   ; okay get another bit in (is this "scaling"?)
      ROL       ; ye
      ROL       ; ah... 
      ADC #$02  ; ? why ?
      STA $D418



the noise level of the pink panther sample is extreme, but i don't understand why it doesn't have the modulation problem of my attempt. (or does it? is this normal?)

roast me.

best
WS


Anywhere where i can download this python script still?
2022-09-09 08:11
ws

Registered: Apr 2012
Posts: 228
https://dl.dataelephant.net/conv8bitwavto4bitc64.zip

just for the fun. it is a win32 blitz3d exe now (works on win10), because there are just too many aspects of python that i actually hate. ( _yes_ .bb source with all my super terrible code is included, enjoy. )
the prerequisites should be doable in soundforge or audacity, whathaveyou. maybe i'll go the full lenght and write a wav importer -- but if you're preparing your sample in a sophisticated editor anyways... why not save it in the way thats required.
yes, the 2 demos are with d011 blanked, because i didnt care to add gfx. enabled screen just makes the crappy sound a bit more crappy.

[Edit: also ofcourse big thx to tlr, oswald, krill & mahoney for helping me understand this!]
2022-09-09 10:41
wacek

Registered: Nov 2007
Posts: 501
Mahoney's method is pretty resistant to inconsistent write jitter to my experience ;)

My simple ways to go around the badlines without too much hard work regarding timing (and with screen turned on) was going every 2nd line skipping the badlines altogether. If I did it in simple wait loop, or via retriggered IRQs, doesn't matter, the code was simpler that way.
2022-09-09 18:53
ws

Registered: Apr 2012
Posts: 228
@wacek : sounds interesting! would you care to provide an example to look at? Maybe this thread can accumulate some helpful approaches.
2022-09-10 11:11
Krill

Registered: Apr 2002
Posts: 2839
Quoting wacek
My simple ways to go around the badlines without too much hard work regarding timing (and with screen turned on) was going every 2nd line skipping the badlines altogether.
With a CIA timer interrupt firing at the start of the right-hand border, you have about 23 cycles for the sample replay interrupt handler until badline DMA.

I wonder if it's possible to have a sample rate of 15.6 KHz (one sample per rasterline) and normal badline action with that. =)
2022-09-10 12:09
ChristopherJam

Registered: Aug 2004
Posts: 1378
Well, one could always just not RTI after playing the sample at the end of line 7, and just set up to play the end-of-line-0 sample 23 cycles later..
2022-09-10 12:18
ChristopherJam

Registered: Aug 2004
Posts: 1378
Oh, and also cf The Brothers Gonna Wr4k It Out (100%) which plays back two samples every IRQ, with an interrupt every 168 cycles (2.67 rasters) to achieve 11.7KHz playback without disabling badlines.

(more details in the release notes for (old CIA edition))
2022-09-10 12:25
Krill

Registered: Apr 2002
Posts: 2839
Quoting ChristopherJam
Well, one could always just not RTI after playing the sample at the end of line 7, and just set up to play the end-of-line-0 sample 23 cycles later..
True that. It was early... :)
2022-09-10 14:29
The Human Code Machine

Registered: Sep 2005
Posts: 110
There's enough time for 15,6Khz even when badlines are enabled, but you have to trigger the NMI IRQ at the right spot , the NMI code has to be in zeropage and shouldn't use more cycles than here:

nmiplaybuf sta abuf+1
fetch lda mixingbuffer1
sta $d418
inc fetch+1
abuf lda #$00
jmp $dd0c ;clear NMI IRQ flag and rti

I used this code in C=Bit 18. 11,7Khz is also possible with badlines enabled, just have a look at the concert part of Musik Run/Stop.
2022-09-17 06:33
ws

Registered: Apr 2012
Posts: 228
Another n00b question :

1. While replaying samples, the oldschool way, what is the logical explanation for the fact that we're just ramping the volume of a stalled squarewave, but the actual effect is on both sides of the center line? Why is the output not on one side of the audio 0 line but in fact it is bi-polar? If the square-wave changes polarity at any time, i would even expect long parts of the wave being on the plus side and other long parts being on the minus side, depending on the base frequency of the square wave? Why is it bi-polar/balanced?

Oldschool sample-replay output example:
https://ibb.co/Y2X4G5b (wave output screenshot)

2. Also, in the above example, which is recorded from a sample replay output like 4-bit in Pink Panther fashion, why do the horizontals graviate towards the center? In a saw-tooth-ish way? Is that the decay of the ADSR?

I am happy to read about this elsewhere, i just was unable to find anything because ... how is this even called?
2022-09-17 08:18
Oswald

Registered: Apr 2002
Posts: 5017
here is my noob question, why does it work as 4th channel on a totally random volume if the other 3 is playing music :)
2022-09-17 09:21
ChristopherJam

Registered: Aug 2004
Posts: 1378
The other three have a DC component - it is the product of that with the sample that you hear as sample playback.
2022-09-17 12:50
tlr

Registered: Sep 2003
Posts: 1714
Quoting ws
Another n00b question :

1. While replaying samples, the oldschool way, what is the logical explanation for the fact that we're just ramping the volume of a stalled squarewave, but the actual effect is on both sides of the center line? Why is the output not on one side of the audio 0 line but in fact it is bi-polar? If the square-wave changes polarity at any time, i would even expect long parts of the wave being on the plus side and other long parts being on the minus side, depending on the base frequency of the square wave? Why is it bi-polar/balanced?

Oldschool sample-replay output example:
https://ibb.co/Y2X4G5b (wave output screenshot)

2. Also, in the above example, which is recorded from a sample replay output like 4-bit in Pink Panther fashion, why do the horizontals graviate towards the center? In a saw-tooth-ish way? Is that the decay of the ADSR?

I am happy to read about this elsewhere, i just was unable to find anything because ... how is this even called?

It's AC coupled. See C77 here: 250469-rev.B-right.gif
2022-09-17 19:39
Oswald

Registered: Apr 2002
Posts: 5017
Quote: The other three have a DC component - it is the product of that with the sample that you hear as sample playback.

that dont really explain it to me. I have 3 waveforms mixed, why dont I hear their volume changing, instead a 4th sample channel ?
2022-09-17 20:08
DeMOSic

Registered: Aug 2021
Posts: 126
Quote: that dont really explain it to me. I have 3 waveforms mixed, why dont I hear their volume changing, instead a 4th sample channel ?

well. There is a bug in the Old 6581 SID chip which, whenever changing the master volume, produces a click at the set volume. So you can use those clicks rapidly to make Samples.
2022-09-17 20:22
Mixer

Registered: Apr 2008
Posts: 422
https://codebase64.org/doku.php?id=base:sid_programming

Has link to some well written resources about playing samples in C-64. I recommend reading the Music Non Stop technical details by Mahoney.
2022-09-17 21:37
ws

Registered: Apr 2012
Posts: 228
Oswald: think of it as subtractive mixing. Your SID-Synth-Waves create the amplitude, from which the sample is so to speak subtracted, which kind of "distorts" the synth/music content and makes the sample hearable. The simpler your synth-sound is (that is why we use a square wave as "carrier"), the cleaner the sample sound gets.

@Mixer - thanks for that link, i totally forgot to read there.
2022-09-18 07:04
Oswald

Registered: Apr 2002
Posts: 5017
ws, yeah that makes more sense than its clicks :) still not 100% for me tho. It would be interesting to see sid output, and then same with d418 digi, fex simple triangle / pulse and then with some digi bass :)
2022-09-18 16:39
ws

Registered: Apr 2012
Posts: 228
The clicks method is the most recent method discovered by Mahoney "clicks came whenever I toggled a voice from being routed through the analog filter of the SID chip, or not",
but what we have mostly talking about here is the good old d418 volume change method, that is disliked for its low quality and non-good-results on the new SID, because the 8580 has DC-Offset correction, so that the amplitude's null line is now correctly being centered, resulting in samples being very quiet if played with the old volume method.
all details are here: https://livet.se/mahoney/c64-files/Musik_RunStop_Technical_Deta..
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Guests online: 136
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Bromance  (9.6)
10 Memento Mori  (9.6)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Rainbow Connection  (9.5)
7 Onscreen 5k  (9.5)
8 Wafer Demo  (9.5)
9 Dawnfall V1.1  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Logo Graphicians
1 Sander  (10)
2 Facet  (9.7)
3 Mermaid  (9.4)
4 Pal  (9.4)
5 Shine  (9.3)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.072 sec.