i'm trying to get sound going in my emulator, but i just don't quite understand what the math has to be to generate the waveforms. i have all the registers stuff working, and i even have some sort of super-crappy triangle channel playing sound but i'm not doing it right.
i've read blargg's and brad taylor's APU docs, both of which have a lot of good info - but, i'm just kind of lost when it comes to doing the math with the values calculated from all the register writes.
i know each channel gets clocked every (cpuclockrate / channelfreq) cpu ticks, and i need to take a snapshot of all the channels' values every (cpuclockrate / samplerate) cpu ticks.
the problem is i just am lost when trying to come up with the formulas to modify the values for every channel clock. i feel like am so close on this, but i can't quite figure out what's next.
here's a 1 MB WAV (44.1 KHz 8-bit mono) of what my triangle channel code is sounding like when i play megaman 1. this is from the stage select screen and then starting fire man's level.
http://rubbermallet.org/trianglechannel.wav
huge thanks to anybody who can point me in the right direction in getting this all working properly!!
i've read blargg's and brad taylor's APU docs, both of which have a lot of good info - but, i'm just kind of lost when it comes to doing the math with the values calculated from all the register writes.
i know each channel gets clocked every (cpuclockrate / channelfreq) cpu ticks, and i need to take a snapshot of all the channels' values every (cpuclockrate / samplerate) cpu ticks.
the problem is i just am lost when trying to come up with the formulas to modify the values for every channel clock. i feel like am so close on this, but i can't quite figure out what's next.
here's a 1 MB WAV (44.1 KHz 8-bit mono) of what my triangle channel code is sounding like when i play megaman 1. this is from the stage select screen and then starting fire man's level.
http://rubbermallet.org/trianglechannel.wav
huge thanks to anybody who can point me in the right direction in getting this all working properly!!