Author Topic: Sound lag: any clues?  (Read 6068 times)

Jonesie (OP)

  • Posts: 32
Sound lag: any clues?
« on: November 10, 2013, 07:51:13 am »
Hi fellas,

I'm opening this thread to try and corner the sound lag issue, so we can devise a fix for it. Please share your most candid experiences with the annoying sound lag here. I'll start:

- I've realised that you can change the sound sampling frequency in PocketSNES (gorgeous port of an outstanding emulator, by the way). I've made several tests, just to find out that you can actually change the lag, being the outcome lag(11kHz) > lag(22kHz) > lag(44kHz) && lag(44kHz) < lag(48kHz). Long story short, the lag is minimum or non-existent when using 44.1kHz as sampling frequency.

Interesting, eh?

dcervi

  • Posts: 67
Re: Sound lag: any clues?
« Reply #1 on: November 10, 2013, 08:42:58 pm »
I've noticed the sound lag is greater when using lower sampling rates, and lower or non existant at higher ones (I wasn't aware that it is higher at 48 kHz than it is at 44,1 kHz). It seems to me that the native OS plays sound with a fixed delay of x samples, so the lag becomes lower at higher rates because this x number of samples are played faster.

I'm glad to see more people developing for the GA330. I have little time to work on it, but I've got hardware scaling working on PocketSNES, so now we can scale fullscreen without loosing any performance (and with better quality, as it seems to use interpolation to do the scaling). I'll try to release my latest working binary with the sources this week, so maybe you can take something useful from them.
« Last Edit: November 10, 2013, 08:48:13 pm by dcervi »

dcervi

  • Posts: 67
Re: Sound lag: any clues?
« Reply #2 on: November 10, 2013, 08:47:28 pm »
Also remember that the available SDK sound init routines use values of 1 for mono and 2 for stereo for the sound channels. The initial release of PocketSNES was using 0 and 1, and it caused the sound being played at half speed.

Jonesie (OP)

  • Posts: 32
Re: Sound lag: any clues?
« Reply #3 on: November 11, 2013, 08:20:01 am »
I've noticed the sound lag is greater when using lower sampling rates, and lower or non existant at higher ones (I wasn't aware that it is higher at 48 kHz than it is at 44,1 kHz). It seems to me that the native OS plays sound with a fixed delay of x samples, so the lag becomes lower at higher rates because this x number of samples are played faster.

My current theory is articulated on the difference between 44.1 and 48. I think, whatever driver they developed, just outputs sound at 44.1 and everything else needs to be interpolated. Another (much more subjective, of course) detail is that sound output at 11.05 doesn't sound to me like 11.025 but as 11.025 interpolated to 44.1kHz. I spent countless hours some 15 years ago oversampling and downsampling sounds with my crappy SB16, and I believe I'm listening to that same effect :)

I'm glad to see more people developing for the GA330. I have little time to work on it, but I've got hardware scaling working on PocketSNES, so now we can scale fullscreen without loosing any performance (and with better quality, as it seems to use interpolation to do the scaling). I'll try to release my latest working binary with the sources this week, so maybe you can take something useful from them.

Yay! Excellent news! Can't wait to try it!

I don't have much spare time either, but I'm more than happy to spend it researching and discussing the results here.

Harteex

  • * Administrator
  • Posts: 713
    • Harteex Productions
Re: Sound lag: any clues?
« Reply #4 on: November 12, 2013, 12:06:33 am »
I'm guessing there is a system buffer which it plays from. If the buffer is a set size, that would explain why there is less lag on higher sample rates.

If we have an emulator in a sound lag version and one without, we should be able to compare the two, for example by disassembling them.

Jonesie (OP)

  • Posts: 32
Re: Sound lag: any clues?
« Reply #5 on: November 13, 2013, 08:38:23 am »
I've made some videos using the different sampling frequencies, and I can no longer appreciate any difference between 44.1 and 48. I've tried doing a slo-mo version, but the editing software introduces a delay itself, so it's not very helpful. 

Right now the buffer hypothesis seems the most plausible one to me. So, we must find a way to bypass it.

fosamax

  • Posts: 328
Re: Sound lag: any clues?
« Reply #6 on: November 13, 2013, 09:08:30 am »
If you need help in decompiling some emulators in order to getting clues on how to remove sound lag and perhaps hints on how to create sim files, maybe you could try to ask for help from Steward :

http://boards.dingoonity.org/gemei-a330/'hello-world!'-code-and-boot-from-sdcard/

He already did some nice research on the gemei even if i suspect he now moved to something else.
I don't think he came often on dingoonity's boards but you could drop him an email from his homepage :

http://home.educities.edu.tw/fushiyun2000/

BTW, I just got my gemei A330 today (I ordered from DX on october 29 so I'm pleased to get it quite fast delivered to France).

I did'nt have time to try it anyway...

Jonesie (OP)

  • Posts: 32
Re: Sound lag: any clues?
« Reply #7 on: November 13, 2013, 06:50:50 pm »
BTW, I just got my gemei A330 today (I ordered from DX on october 29 so I'm pleased to get it quite fast delivered to France).

Wow, congratulations! Mine took nearly a month to be delivered to York, England. I've lived in France for quite some time; it's nice to have a frenchman here :)

I'll try to make a higher quality slow-mo video in order to determine if the delay is higher at 48. If it's not, harteex is right and we'll have to bypass the actual mechanism for sending the audio data.

Jonesie (OP)

  • Posts: 32
Re: Sound lag: any clues?
« Reply #8 on: November 22, 2013, 10:04:09 am »
Does anybody have high resolution pictures of both sides of the board? I'm definitely going to partially disassemble mine for fixing those noises produced by plastic friction, but before further dismantling it I would like to know if somebody has already taken those kind of pictures before.

fosamax

  • Posts: 328
Re: Sound lag: any clues?
« Reply #9 on: November 22, 2013, 10:37:17 am »
Those are the best i could find :

http://www.dingux.com/2010/10/a330-guts.html






Jonesie (OP)

  • Posts: 32
Re: Sound lag: any clues?
« Reply #10 on: November 22, 2013, 02:05:28 pm »
Very nice indeed! Cheers!

 

Post a new topic