APU Emulation
Moderator: Moderators
APU Emulation
As disch told me im emulating the APU and taking te output every 41 opcodes cycles aprox. Every time i take the out put i fill an array of byte representing the wave (PCM), then when buffer reach 2048 i play it (direct sound). But as disch told me its a poor sound quality. Any suggestions to make the playback better?
ANes
Step 1: Try a box filter. Take the output of every APU cycle during each sample period (40-41 samples[1]) and average them before writing them to the buffer. This will improve the quality of your emulator's noise and high-pitched tones.
There is a step 2 that results in further improvement, but to understand it, you'll need to have the experience from step 1 as well as a background in digital signal processing.
[1] To get proper pitch, you'll need to alternate between 40 and 41 samples.
There is a step 2 that results in further improvement, but to understand it, you'll need to have the experience from step 1 as well as a background in digital signal processing.
[1] To get proper pitch, you'll need to alternate between 40 and 41 samples.
You sum the volumes over a specific amount of cycles and then divide the result by the amount of cycles. Like so:
The resulting sample is then written to the sound buffer, so that it can be output by your audio card.
Code: Select all
amp = 0;
for (i = 0; i < cycles; i ++)
{
amp += get_channel_volume_at_cycle (i);
}
sample = amp / cycles;