Page 1 of 1
Updating S-DSP registers
Posted: Fri Jul 02, 2010 12:55 am
by mic_
Are there any restrictions for when DSP registers can / should be updated (besides the whole echo mess).
eKid mentioned this regarding the VOL registers:
There are some undocumented quirks (emulated though) that I experienced when using these registers (while writing XMSNES). Sometimes the value I write gets ignored.. (or something), I'm not really sure what the exact problem is.
But he didn't elaborate any further.
Can VOL, GAIN, P be written successfully at any time (assuming direct gain mode)? Do any of these registers require a KOF/KON sequence to take effect - similar to how DMG channel sometimes need to be restarted - or can you change the frequency just by updating P?
Posted: Fri Jul 02, 2010 4:45 am
by blargg
As far as I can tell from my DSP emulator source, they all take effect by the next sample or two. I have test ROMs which constantly write random values to these for tens of thousands of samples, and verify every sample of output. This DSP emulator passes all of these, and is the one used in bsnes, if you want test your code. Did that other guy give any more information as to why he thought they don't take effect immediately?
Posted: Fri Jul 02, 2010 4:52 am
by mic_
No, I haven't talked to him. It's just what he wrote on
his page.
Posted: Fri Jul 02, 2010 1:03 pm
by mic_
I tried doing this:
Code: Select all
mov TEMP,#1
mov TEMP+1,#0
play_tones:
mov SPC_DSP_ADDR,#DSP_P0L
mov SPC_DSP_DATA,TEMP
mov SPC_DSP_ADDR,#DSP_P0H
mov SPC_DSP_DATA,TEMP+1
; delay
mov SPC_TIMER1,#200
mov SPC_CTRL,#$02
-:
mov a,SPC_COUNTER1
beq -
mov SPC_CTRL,#$00
incw TEMP
bne play_tones
I would've expected it to play the entire frequency range, with each step lasting 25 ms, but all I get is a single *pop* and then silence. I've disabled ADSR, set GAIN to direct mode with a value of 80, and set VOL to 96, but ENVX is stuck at zero when I look at the S-DSP properties in BSNES with auto-updating enabled. I can see the pitch being updated, so that's not the problem. And I've already set the KON bit for channel 0 before entering this loop.
Posted: Fri Jul 02, 2010 1:11 pm
by Bregalad
Well if the gain is 80 that's a decrease at speed 0 so it'll stay at 0. You'd need to write 7f here / or to use ADSR values FF/E0 (which is basically always staying at maximum level).
Also it could take a while until your sample plays at a pitch high enough to be audible (I don't know what sample you're playing). Be sure to use a square wave or something like that.
A trick to test if volume writes takes effect immediately would be to play a sample which is a DC level and vary the volume quickly and form a sine wave that way. If a sine wave is heard then the writes takes immediately.
Posted: Fri Jul 02, 2010 1:25 pm
by mic_
Well if the gain is 80 that's a decrease at speed 0 so it'll stay at 0. You'd need to write 7f here / or to use ADSR values FF/E0 (which is basically always staying at maximum level).
It's decimal 80.
Posted: Fri Jul 02, 2010 3:35 pm
by mic_
Turned out I had messed up the entries in my sample directory, so sometimes I would get lucky and it would play something, but other times the S-DSP would just sit there silently.