It is currently Tue Oct 17, 2017 1:37 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Sun May 07, 2017 7:34 pm 
Offline

Joined: Sun May 07, 2017 7:26 pm
Posts: 2
I created a very rudimentary implementation of the APU in my emulator. I currently sample at 48000Hz and every 41st cycle of the cpu, I go ahead and spew the current tone out for the two pulse waves (basically nearest neighbor algorithm). I don't do anything else fancy like envelopes or handling duty cycles, everything is at a constant volume. As a result, the music/sound never turns off (I'm only testing with Donkey Kong) which is expected.

What I noticed is that the PPU doesn't match up with the APU. I'm testing with Donkey Kong and if Mario gets hit by a barrel, the kill noise is delayed and doesn't output for a few seconds.

My implementation of the PPU is to currently draw out the whole frame at the end (89,342 PPU cycles). I don't think I'm bound by my computer as it's able to keep up fine. Also there's zero input lag between keyboard input (controlling mario) and picture output.

Based on my implementation, does it make sense that the sound doesn't match up with the picture? There is still a lot of work to do but for now I'm more curious as to what could cause the delay. Thanks.


Top
 Profile  
 
PostPosted: Sun May 07, 2017 10:37 pm 
Offline
Site Admin
User avatar

Joined: Mon Sep 20, 2004 6:04 am
Posts: 3470
Location: Indianapolis
That's what would happen if the audio buffer is too long, can you make it shorter? What system/library are you using for audio? I've only used SDL myself, but that info might allow someone else to help.

edit: PPU and audio synchronization seems to be a recurring problem with making an NES emulator, so there will surely be more to it than just using a shorter buffer. If you can find other threads about that, it might help.


Top
 Profile  
 
PostPosted: Mon May 08, 2017 4:46 pm 
Offline

Joined: Sun May 07, 2017 7:26 pm
Posts: 2
Memblers wrote:
That's what would happen if the audio buffer is too long, can you make it shorter? What system/library are you using for audio? I've only used SDL myself, but that info might allow someone else to help.

edit: PPU and audio synchronization seems to be a recurring problem with making an NES emulator, so there will surely be more to it than just using a shorter buffer. If you can find other threads about that, it might help.


I'm also using SDL... I can believe that my audio buffer is too long. Is this the "samples" member in SDL_AudioSpec as an argument to SDL_OpenAudioDevice? (https://wiki.libsdl.org/SDL_OpenAudioDevice) I'm using 1600 here, which I calculated from:

4800hz * sizeof(short) / 30 / 2 (30 being arbitrary, in this case 30fps -- NTSC).

I stole that boilerplate calculation from some stackoverflow post so I may be off track here.


Top
 Profile  
 
PostPosted: Mon May 08, 2017 5:08 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 10:59 pm
Posts: 1389
_jamesbrown_ wrote:
(30 being arbitrary, in this case 30fps -- NTSC)

As far as the NES is concerned, NTSC is 60fps, not 30.

_________________
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 4 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