This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

Delay when using function sfx_play

Delay when using function sfx_play
by on (#185338)
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
Re: Delay when using function sfx_play
by on (#185339)
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.


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.
Re: Delay when using function sfx_play
by on (#185340)
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.