I'm programming a basic audio synthesizer and I want it to sound authentic to the NES without actually writing an emulator.
So far I have the basics down pat for creating a WAV file and filling it with a square wav, changing the frequency, etc. I am creating WAV files at 44,100 hz, 16 bits, and they sound nice and chippy
To be authentic, however, I would like to generate 4 bit audio, since I understand that is the NES bit depth for most channels.
What I don't understand is how to quantize (am I using the correct term?) a square wave or other waveform into 4 bits.
My synthesizer will have a value like "50% volume" at any given point.
4 bits gives 16 different values. My first question is which position is silence?
My second question is how should I convert the wave form depending on which part of the duty cycle it is on? For example if the square wave is to be written out "low" at 50%, which might mean a value of 4, but on the "high" part of the duty cycle would it then be 12 or 13?
My last question is how would I up-convert the resulting 4-bit audio into a 16-bit WAV file?
I'm sorry if I'm using the wrong terminology. Does anyone understand what I'm looking to achieve?
Also for further info, when I am writing out my 16-bit audio I take the max value (65536), subtract 1 and divide by 2. So complete silence would be 32768, and there are 32767 positions above or below. I'm not even sure if I'm doing that correctly but that's how I've seen quantinization code online so I stole an example from somebody's c++ app.
Thanks in advance for any guidance.
So far I have the basics down pat for creating a WAV file and filling it with a square wav, changing the frequency, etc. I am creating WAV files at 44,100 hz, 16 bits, and they sound nice and chippy
To be authentic, however, I would like to generate 4 bit audio, since I understand that is the NES bit depth for most channels.
What I don't understand is how to quantize (am I using the correct term?) a square wave or other waveform into 4 bits.
My synthesizer will have a value like "50% volume" at any given point.
4 bits gives 16 different values. My first question is which position is silence?
My second question is how should I convert the wave form depending on which part of the duty cycle it is on? For example if the square wave is to be written out "low" at 50%, which might mean a value of 4, but on the "high" part of the duty cycle would it then be 12 or 13?
My last question is how would I up-convert the resulting 4-bit audio into a 16-bit WAV file?
I'm sorry if I'm using the wrong terminology. Does anyone understand what I'm looking to achieve?
Also for further info, when I am writing out my 16-bit audio I take the max value (65536), subtract 1 and divide by 2. So complete silence would be 32768, and there are 32767 positions above or below. I'm not even sure if I'm doing that correctly but that's how I've seen quantinization code online so I stole an example from somebody's c++ app.
Thanks in advance for any guidance.