This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

NESADPCM -- a new library for playing VOX ADPCM audio

NESADPCM -- a new library for playing VOX ADPCM audio
by on (#135607)
I'm tired from spending all day yesterday and much of today working on the thing, so I'll just toss up the link here:

https://github.com/furrykef/nesadpcm

There's a demo NSF file in the repository with four clips if you just want to hear what it sounds like. Works fine in NSFPlay and FCEUX; your mileage may vary on anything else.
Re: NESADPCM -- a new library for playing VOX ADPCM audio
by on (#135621)
I just added some performance features, so now it can play at up to 8948 Hz. However, this adds some 800 bytes to the ROM. There's a compromise mode that adds only some 400 bytes and plays at 8470 Hz, and the "slow" mode is still there, playing at 6351 Hz.

The NSF demo still uses the slow mode at the moment, since using the higher rates would require bank switching to make it all fit, and I can't be bothered at the moment.
Re: NESADPCM -- a new library for playing VOX ADPCM audio
by on (#135625)
Wow, it sounds terrible on NSFPlug (winamp). Sounds fine on other emulators though.
Re: NESADPCM -- a new library for playing VOX ADPCM audio
by on (#135626)
How does it sound different in NSFPlay than other emulators? Could you be specific about the sound you find objectionable, or about the other emulators so that I can make a comparison? (Which version of NSFPlay are you using?)
Re: NESADPCM -- a new library for playing VOX ADPCM audio
by on (#135629)
NSF wasn't really designed for software-decompressed samples played back through writes to $4011. Perhaps making a .NES file for use in full NES emulators might produce more repeatable results.
Re: NESADPCM -- a new library for playing VOX ADPCM audio
by on (#135636)
I'm using NSFPlug 2.3 and it sounds the same as on FCEUX for me.

tepples wrote:
NSF wasn't really designed for software-decompressed samples played back through writes to $4011. Perhaps making a .NES file for use in full NES emulators might produce more repeatable results.


I just wanted something that I can double-click and it will play the sounds. I don't have .nes files associated with any one emulator (I bounce between puNES, Nestopia, and FCEUX anyway), but I have NSFs associated with NSFPlug.

I'd argue that an NSF player that can't handle it is broken anyway (though of course the UI will hang on hardware players while a sample is playing).
Re: NESADPCM -- a new library for playing VOX ADPCM audio
by on (#135638)
tepples wrote:
NSF wasn't really designed for software-decompressed samples played back through writes to $4011. Perhaps making a .NES file for use in full NES emulators might produce more repeatable results.

What on earth do you mean by this? The software execution is identical whether it is an NSF or NES.
Re: NESADPCM -- a new library for playing VOX ADPCM audio
by on (#135639)
He's right, actually; the NSF spec on the wiki says, "A play routine should normally finish with an RTS instruction, but is not required to do so. A non-returning play will cause problems for NSF players that use the same CPU to control the user interface and to run the NSF, such as NSF players that run on an NES. It is strongly recommended to return every few frames if at all possible, such as when no PCM is playing. If play takes longer to finish than the specified interval, that interval may be skipped and play may not be called again until the next one."

It's probably not relevant for emulators, though.
Re: NESADPCM -- a new library for playing VOX ADPCM audio
by on (#135645)
Now the demo NSF in the repo uses the new maximum play speed.
Re: NESADPCM -- a new library for playing VOX ADPCM audio
by on (#135651)
furrykef wrote:
He's right, actually; the NSF spec on the wiki says, "A play routine should normally finish with an RTS instruction, but is not required to do so. A non-returning play will cause problems for NSF players that use the same CPU to control the user interface and to run the NSF, such as NSF players that run on an NES. It is strongly recommended to return every few frames if at all possible, such as when no PCM is playing. If play takes longer to finish than the specified interval, that interval may be skipped and play may not be called again until the next one."

It's probably not relevant for emulators, though.


Most NSF players are germane to a non-returning play, including the PowerPak. The TNS player might have a problem with it; I know it uses NMI to drive the PLAY routine, but I'm not sure if it prevents re-entrant NMI. It's a commonly used technique, popularly employed by SuperNSF and a few other NSF engines, so it's widely supported. Actually, I should probably add a note about this in the wiki.

At any rate, that issue is totally irrelevant to whatever sound problem Dwedit was having. NSFPlay has no problem with non-returning PLAY, and neither does any emulator in which this NSF worked.
Re: NESADPCM -- a new library for playing VOX ADPCM audio
by on (#135655)
Figured it out... The setting called "Eliminate Clicking Noise" was sabotaging this one. It was basically lowpassing the hell out of it, making it almost sound like bad DMC samples. Now it sounds perfect with that disabled.
Re: NESADPCM -- a new library for playing VOX ADPCM audio
by on (#135656)
Ah, yeah that would do it. The feature replaces immediate $4011 pops with a ramp, so you'd be getting some sort of weird triangular interpolation there.