- My method of generating signed samples is...
Code:
output += cur_sample - prev_sample;
prev_sample = cur_sample;
Then, at every NES_FREQ / PC_SAMPLE_RATE number of samples:
output -= output >> 5;
- This doesn't work well with the triangle channel. Any help?
If I'm reading your pseudocode correctly, it looks like you're applying two high-pass filters to the output, which is a not-unreasonable way to effectively make the output signed. But the ones you're using have a very high "corner frequency" below which lower pitches are more rapidly attenuated.
Furthermore, square and pulse waves (channels 1 and 2) have more high frequency components than a triangle wave, and so will be less perceptibly attenuated by the highpass you're using.
If you want to keep on doing it this way, try lowering the effective corner frequency, by some combination of "output += cur_sample - prev_sample >> something" and increasing the 5 at the bottom.