AndreaOrru / LaiNES

Cycle-accurate NES emulator in ~1000 lines of code
BSD 2-Clause "Simplified" License
1.49k stars 115 forks source link

Audio on Linux has some problem. Also, SDL2 audio APIs are deprecated. #13

Open AndreaOrru opened 8 years ago

kraln commented 7 years ago

Is the problem "Extreme choppyness?" if so, I am experiencing this and will investigate.

AndreaOrru commented 7 years ago

It is. I just switched back to Linux actually, so I can have a look too. I have plans to rewrite the APU core to be independent from blargg's libraries anyway.

AndreaOrru commented 7 years ago

621aa65858ec6eaae33f051cd0041e4d95df9354 should solve this. Hopefully it doesn't break on Mac.

kraln commented 7 years ago

Issue still present on my machine: Linux galium 4.8.3-1-ARCH #1 SMP PREEMPT Thu Oct 20 19:53:59 CEST 2016 x86_64 GNU/Linux

Compiler: clang version 3.8.1 (tags/RELEASE_381/final)

Computer: Thinkpad L460

Here's a .FLAC -- you can see the audio output is really choppy. test.zip

AndreaOrru commented 7 years ago

Ok. It solved it on mine. I'll borrow another Linux machine and experiment more.

I started sketching the new APU core anyway. If this is a quick fix then it's great, otherwise I'd rather focus on the rewrite. :)

kraln commented 7 years ago

I started to poke around a bit. When I run the APU for twice as many cycles, it seems to be better. When I run it at a lower sample rate (= lowpass filter), it seems to be much better.

https://github.com/kraln/LaiNES/tree/investigating_audio

AndreaOrru commented 7 years ago

Thanks.

What I find weird is that it works flawlessly on Mac OS X. Could that be because of a better sampling engine or something like that?

I won't have a lot of time to work on this till at least the 21st of December. Your contributions are super appreciated. :)

RyanPattison commented 7 years ago

In Ubuntu, entering export SDL_AUDIODRIVER=ALSA before running improves the audio by a lot.

AndreaOrru commented 7 years ago

Thanks, that's good to know! I'll write that in the README.