cute_headers icon indicating copy to clipboard operation
cute_headers copied to clipboard

cute_sound: ALSA Backend - Looking for Pull Request

Open r-lyeh-archived opened this issue 8 years ago • 6 comments

From #12

Even if I'm a windows user, the geek in me knows that an ALSA backend would be a great addition. FYI, http://github.com/yui0/aplay-/blob/master/alsa.h (PD)

r-lyeh-archived avatar Jun 19 '17 09:06 r-lyeh-archived

Another PD licensed solution here https://github.com/dr-soft/mini_al

r-lyeh-archived avatar Sep 07 '17 08:09 r-lyeh-archived

I'll try implementing this today, assuming I can successfully use WSL on Windows to test it out.

RandyGaul avatar Aug 25 '19 23:08 RandyGaul

Hmm, looks like ALSA is not supported with WSL. I'll try virtual box then.

RandyGaul avatar Aug 25 '19 23:08 RandyGaul

@r-lyeh Alright, I've got a basic port going. Though there are some problems.

  1. When I first boot up my machine and run the ALSA demo, there's a segfault. I have no idea why. It only happens the first time the program is run after a machine restart. Which makes it very annoying to debug. And unfortunately the segfault occurs after some audio starts playing.
  2. Timing is all weird. I have no idea why. This could be because of usleep, or because I have a low-end machine in my virtual box, or because the ALSA handling is poor. I really am not sure. I don't currently understand very well how timings with ALSA work, in terms of feeding in the correct number of samples over a period of time. I fear I might be mixing in too much silence when no audio is playing, causing a time warp effect where silence can be really long or shorter randomly.

Anyways, I'm going to call it good enough for now. Maybe someone else will have a little more knowledge about ALSA and comment here, by the time I take another look.

RandyGaul avatar Aug 26 '19 08:08 RandyGaul

My main reference for implementation came from SDL: https://github.com/spurious/SDL-mirror/blob/17af4584cb28cdb3c2feba17e7d989a806007d9f/src/audio/alsa/SDL_alsa_audio.c

RandyGaul avatar Aug 26 '19 08:08 RandyGaul

Hmm, looks like there's a callback API I completely missed. ALSA can probably be setup just like CoreAudio and SDL, which might be a lot easier than the current strategy. I found a nice page to reference for this: https://alsa.opensrc.org/Asynchronous_Playback_(Howto)#Initializing_the_Callback

RandyGaul avatar Aug 26 '19 09:08 RandyGaul

Going to nix this and just stick with SDL2 backend for Linux.

RandyGaul avatar Nov 10 '22 02:11 RandyGaul