The 't_dir_addr' variable holds the pointer to the audio source directory and is the result of taking the contents of the DSP's 'DIR' register and the specific voice's 'SRCN' register. Blargg calls these t_dir and t_srcn, respectively. In Blargg's code it correctly calculates the value of 't_dir_addr' as follows in voice processing step 1:
Code: Select all
m.t_dir_addr = m.t_dir * 0x100 + m.t_srcn * 4;
A perfect example of this is voice's 6 and 7. If we look in Anomie's apudsp.txt we see (I removed the irrelevant voices to make it clearer):
Code: Select all
11. Voice steps: 6:V1
12. Voice steps:
13. Voice steps:
14. Voice steps: 7:V1
15. Voice steps: 6:V2
How can this possibly work right? It seems like you would have to have a separate 't_dir_addr' for each voice in order to ensure that they don't clobber each other.
But obviously the current way that it's coded is correct since Blargg's emulator is extremely accurate. And if I modify the code to have a separate t_dir_addr for each voice then the resulting audio doesn't sound right at all. I really want (need) to understand how/why it works with the t_dir_addr getting clobbered throughout the voice processing steps.
The way I'm thinking about it at a high level is that each voice channel has a separate "directory" of audio data with each DIR+SRCN pair pointing to a unique set of BRR samples. Like so...
DIR+V0SRCN = Pointer to Voice 0 BRR Data
DIR+V1SRCN = Pointer to Voice 1 BRR Data
DIR+V2SRCN = Pointer to Voice 2 BRR Data
...and so on...
But seeing how the t_dir_addr variable gets clobbered across different voices in Blargg's code it doesn't seem to be that simple.