Updating S-DSP registers

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Updating S-DSP registers
by on (#63578)
Are there any restrictions for when DSP registers can / should be updated (besides the whole echo mess).

eKid mentioned this regarding the VOL registers:

Quote:
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?

by on (#63582)
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?

by on (#63583)
No, I haven't talked to him. It's just what he wrote on his page.

by on (#63598)
I tried doing this:

Code:
   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.

by on (#63599)
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.

by on (#63600)
Quote:
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.

by on (#63605)
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.