It is currently Sat Oct 21, 2017 7:52 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: APU Emulation
PostPosted: Wed Mar 16, 2005 6:48 pm 
Offline
User avatar

Joined: Tue Dec 21, 2004 8:35 pm
Posts: 600
Location: Argentina
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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 16, 2005 7:03 pm 
Offline

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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 16, 2005 8:28 pm 
Offline
User avatar

Joined: Tue Dec 21, 2004 8:35 pm
Posts: 600
Location: Argentina
what do you mean with "average"?

_________________
ANes


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 16, 2005 9:50 pm 
Offline

Joined: Mon Sep 27, 2004 11:51 pm
Posts: 101
You sum the volumes over a specific amount of cycles and then divide the result by the amount of cycles. Like so:

Code:
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.

_________________
http://hydesprojects.cjb.net/


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 16, 2005 10:09 pm 
Offline
User avatar

Joined: Tue Dec 21, 2004 8:35 pm
Posts: 600
Location: Argentina
thanks hyde

_________________
ANes


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: Bing [Bot] and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group