Delay when using function sfx_play

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

Post Reply
User avatar
-Basti-
Posts: 40
Joined: Sun Sep 26, 2010 10:29 pm

Delay when using function sfx_play

Post by -Basti- »

Hello,
I am nearly done with my first NES project written in C. One of the last things I have to achieve is to add some sound effects.
I use Shiru's NESLibrary and therefore function sfx_play for the purpose of playing sound effects.
I wrote my first simple sound effect with Famitracker and converted it into a .s file using Shriu's Famitone2.

The problem is as follows: The sound effects are played with a large delay after they are actually triggered. I checked the demo game that comes with Shiru's NESLibrary (Chase) and it seems to me, that this game is also facing this issue.

Can anybody help me out with this problem?


Regards Sebastian
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: Delay when using function sfx_play

Post by dougeff »

I'm looking at Chase in a debugger...title screen...

Time between 'Start' read by the joypad routine and the sfx(0) data being read = 29093 cycles, or about 1 frame. Time till that data is written to the APU...357 cycles [total = 0.0167 seconds]

Seems 'ok' to me.

EDIT...

In game, time between sfx(1) called and read data = 27996 cycles, time till written to APU, 288 cycles. Also 0.0167 seconds. Confirmed. Chase Sfx are ok.
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
-Basti-
Posts: 40
Joined: Sun Sep 26, 2010 10:29 pm

Re: Delay when using function sfx_play

Post by -Basti- »

Sorry my bad. After I read your post I got an idea which revealed to be the solution:
I develop my NES project on a small AWS windows machine in order to have a single space that is only for NES programming.

Testing my projects in the cloud worked fine until I added sound. Therefore I now downloaded my project to my local machine and tested
it there: sound is played properly.
So the problem was my latency which lead into a delay, when transmitting sound effects :D

Thanks for your support, though.
Post Reply