Hi Guys,
First of all it is great to see a gameboy dev forum here as I havent been able to find a decent one on the net. I have a fully working gameboy emulator and now just need to add sound support. I have previously posted on the nesdevemu forum asking for help with square waves because the sound chip on the gameboy and NES are very similar. I am now attempting to implement the wave channel and have come stuck. My main problem with this channel is knowing how to interpret the 32 samples in memory and how to play them. This channel has a frequency like the square wave channels so Im assuming that when enough clock cycles have passed and the frequency has decreased to 0 then you move onto the next sample in memory and reload the frequency and start counting down again (this is similar to how I handle square waves by counting down the frequency and upon 0 I increase the duty cycle and change the polarity if needed).
Does this sound correct so far?
My problem now is how to play the current sample. So if the sample Im playing has the value of 0xA what does this actually mean? You see with square waves I simply multiply the volume by the polarity (either +1 or -1) and total them all up before adding to the playback buffer, but im unsure how to do this with a wave. Also am I correct in assuming the value returned from a wave is +1 and 0 and not +1 and -1 like square waves? If so then how do I mix a wave and a squre wave before adding it to the playback buffer?
Thanks for your time and any help.
First of all it is great to see a gameboy dev forum here as I havent been able to find a decent one on the net. I have a fully working gameboy emulator and now just need to add sound support. I have previously posted on the nesdevemu forum asking for help with square waves because the sound chip on the gameboy and NES are very similar. I am now attempting to implement the wave channel and have come stuck. My main problem with this channel is knowing how to interpret the 32 samples in memory and how to play them. This channel has a frequency like the square wave channels so Im assuming that when enough clock cycles have passed and the frequency has decreased to 0 then you move onto the next sample in memory and reload the frequency and start counting down again (this is similar to how I handle square waves by counting down the frequency and upon 0 I increase the duty cycle and change the polarity if needed).
Does this sound correct so far?
My problem now is how to play the current sample. So if the sample Im playing has the value of 0xA what does this actually mean? You see with square waves I simply multiply the volume by the polarity (either +1 or -1) and total them all up before adding to the playback buffer, but im unsure how to do this with a wave. Also am I correct in assuming the value returned from a wave is +1 and 0 and not +1 and -1 like square waves? If so then how do I mix a wave and a squre wave before adding it to the playback buffer?
Thanks for your time and any help.