APU Emulation

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
User avatar
Anes
Posts: 707
Joined: Tue Dec 21, 2004 8:35 pm
Location: Mendoza, Argentina

APU Emulation

Post by Anes »

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
tepples
Posts: 22864
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

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.
User avatar
Anes
Posts: 707
Joined: Tue Dec 21, 2004 8:35 pm
Location: Mendoza, Argentina

Post by Anes »

what do you mean with "average"?
ANes
Hyde
Posts: 101
Joined: Mon Sep 27, 2004 11:51 pm

Post by Hyde »

You sum the volumes over a specific amount of cycles and then divide the result by the amount of cycles. Like so:

Code: Select all

amp = 0;

for (i = 0; i < cycles; i ++)
{

amp += get_channel_volume_at_cycle (i);

}

sample = amp / cycles;
The resulting sample is then written to the sound buffer, so that it can be output by your audio card.
User avatar
Anes
Posts: 707
Joined: Tue Dec 21, 2004 8:35 pm
Location: Mendoza, Argentina

Post by Anes »

thanks hyde
ANes
Post Reply