neogeo-mzs / Mezz-Estate-NeoGeo-Audio-Driver

An audio driver for the NeoGeo written in Z80 assembly
MIT License
19 stars 1 forks source link

Will support for ADPCM-B be added? #4

Open tcalospora opened 1 year ago

tcalospora commented 1 year ago

Support for ADPCMB would be really useful for pitched samples. That way, a composer or developer can use 8 samples (one per octave) and then change the playback speed to alter the pitch, instead of having one ADPCM-A sample for each note. Also, the ADPCM-B auto-loop might be useful for longer, extended notes. Deflemask support for ADPCMB would be great.

I realize this might not be an issue/bug, but there is not a suggestions category for this repo.

ghost commented 1 year ago

I do believe that ADPCM-B support would benefit the driver greatly, but I don't have any time schedule in which I'll implement it, as I'm prioritizing other features (Mainly control macros, which are macros that run MLM commands with custom parameters each tick). Additionally, due to ADPCM sample end flags being easy to break, the initial 2.0 release won't have ADPCM-B support. This is to give people a driver version to revert to in case ADPCM-B support breaks SFX playback. I'll keep in mind the need for ADPCM-B in future releases.

tcalospora commented 1 year ago

Here is a quote from another repo. I found something about the ADPCM-B channel looping feature that might prove helpful if and when you get around to adding support:

I've made a discovery. After editing two of my samples, the popping became less pronounced, but the rest still sounded the same. After comparing their lengths, I found that they both took up 18684 bytes. This is extremely close to 18688, which is a multiple of 256. I remember that the start and end addresses for the ADPCM-B channel on the YM2610 are 3 bytes long, but only the top 2 bytes can be set (the bottom byte being $0 or $FF). Perhaps the popping is because the channel doesn't loop until it reaches the end of 256 bytes, but most samples have some padding at the end, so the channel plays the padding of $0's. This would also explain why the pops appear as a flat line in the oscilloscope.

My conclusion is that looped samples must be slightly under a multiple of 256 bytes long or they will have popping when the channel interprets padding as sample data.

After re-consulting the datasheet, I think the only way to get a smooth loop would be to use Timer A to generate an interrupt for the Z80 sound cpu, check the ADPCM status and manually reset the channel if it is near the end.

ghost commented 1 year ago

Thank you, this might be quite helpful! I'll keep it in mind.