Jump to content

Possible lag between image and sound on Stella


Recommended Posts

Hi there,


I have been using the Stella emulator for coding/playing a couple of demos on Atari 2600, and that's been great so far. Thanks for that !


However, when running the binary provided in attachment (I wrote a code to illustrate the lag) in Stella 6.3 (Stella 6.0.2 as well), I experience a lag between the picture and the sound (Rough estimate about 50-100 ms). When running the same binary on the real hardware I don't see/hear any lag. As I don't notice any lag when playing videos (on youtube) on my machine, I don't think my OS (Ubuntu 20.04) introduces it. It feels like it comes from the Stella emulator (Even though I selected "Ultra Quality, minimal lag", in the Audio Mode options).


The source code of `main.bin` is there: https://github.com/FlorentFlament/stella-lag


Just wondering if this has been noticed already ? Or is it my setup that is broken ?


Link to comment
Share on other sites

There will always be some lag; it's unavoidable due to how emulation works.  But it shouldn't be noticeable in most cases.  Certainly if you hook up stuff to some measuring equipment (scope, etc) you will see it is there.   But in practice is shouldn't be too bad.  But I suppose it could depend on hardware/settings, and how sensitive you are to such issues.

Link to comment
Share on other sites

Also, in the sound settings, try 'Custom' and then set 'Fragment size' as low as possible, before you start getting crackling in the sound.  I can get down to 256 on my system, and sometimes 128 depending on the ROM (Linux, KDE Neon 20.04 with pretty fast hardware).  But on other systems, 256 is too low, and I have to increase it.

Link to comment
Share on other sites

Thanks for your reply @stephana,

Indeed, with a 128 samples fragment size, I barely notice the delay between image and sound! And yes, you're right about the delay being unnoticeable in most cases.

I guess it could be feasible to delay the image by the same duration than the sound to have them in sync, but we would introduce lag between user input and the software being emulated... Emulation compromises ...

Link to comment
Share on other sites

I guess you could edit the code to use 64 byte or even 32 byte samples.  The lower you go, the lesser the lag.  But most non-realtime systems can't keep up at extremely low fragment sizes, and other issues pop up.  I just tried modifying the code, and could get down to 16!  At that point I didn't see any lag.  Tried 8, but Stella locked up.  But 32/64 may be possible on some systems.  Perhaps we'll add an option to go lower than 128.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...