I have managed to get sound working, although the volume is high and cannot be changed from the Recalbox GUI. But too much sound is better than no sound ;-)
What I did was this:
Remounted root as writable:
mount -o remount,rw /
Add env var for nano to work:
Created a .asoundrc file:
with the following contents:
Saved the above file and rebooted from the GUI.
I still didn’t have sound and figured I might need another approach, like directly editing the conf file. Before doing that I went one more time to the GUI and tried selecting each audio output. Lo and behold now hw:0,7 worked!
To see if the settings would stick I rebooted. Sound still worked.
For grins I ssh’d back in and tool a look at ~/.asoundrc. To my surprise it was different than the file that I created. It now contained the hw:0,7 settings that must have come from my audio change in the GUI. Here’s the current contents of ~/.asoundrc:
Apparently the HDMI device 7 does work on my hardware as long as it’s set as the asla default? Strikes me as odd that I could not get this to work when calling aplay directly.
Anyway it appears that the real issue here is that the absence of a writable ~/.asoundrc file was the problem all along. Making the partition writable and creating this file has now allowed recalbox to be able to successfully write its own contents here and make sound work.
If I'm right about this and Recalbox needs to be able to create and write to the ~/.asoundrc file then this seems like a bug.
I guess I’m happy with this because I have sound. But it’s kind of a pain that the system volume slider is useless. It seems like the PC is now pumping out full volume, so I have to turn the TV sound bar way down when using recalbox.
It would be nice to be able to specify HDMI as the output and be able to control the volume. If anyone has ideas, please let me know. Otherwise I’ll just take what I have as a win.
Tried various things with .conf files above after getting root (/) filesystem mounted as rw, but still unable to get things working.
Used retroarch directly after stopping emulationstation manually, i.e.
retroarch --menu --verbose ; customretroarch definitely being read-in including the following audio settings. have confirmed that audio_device is @ 0,1 and modified the audio_driver with alsa too.
retroarch --features compiled with ALSA as expected, nothing else valid to use:
simply getting an "failed to initialize audio" error from retroarch log:
[ERROR] [ALSA]: Failed to initialize...
[ERROR] Failed to initialize audio driver. Will continue without audio.
decided to take a good look at osmc config with retro and what its using:
audio_driver = "alsathread"
audio_resampler = "sinc"
audio_device = ""
audio_sync = "true"
I emulated this in recalbox, and the errors in retroarch stop with the following in the retroarch startup as in osmc
[INFO] ALSA: Using signed 16-bit format.
[INFO] ALSA: Period size: 384 frames
[INFO] ALSA: Buffer size: 1536 frames
so figured I was onto something, however still no sound.
really just clueless now. remember, I launch emulation in osmc (from kodi) and I start up a game... audio just works.
i suppose my next question is: is there something in kodi that launches stuff correctly or emulation station, or is this simply a recalbox 'startup driver problem' that doesnt recognize the audio correctly. can anyone shed light on this for me?
How to test:
1)Fresh install recalbox onto a Pi 3B.
2)Add Mario 3 ROM to game list.
3)Start Mario 3 game and press select button to move the little red arrow. It will make a sound as it moves.
4)Press Hotkey + B and use that menu to write a savestate (doing it other ways will not reproduce the bug)
5)Use that green Retroarch menu you're in to restart the game.
5)press select button to move the little red arrow. It will make a sound way after it moves, and you will notice the awful audio lag.
The white noise you talk about on the Rpi3 is only when using the 3.5 jack output right? I've noticed it too but it doesnt occur with audio through HDMI, thought it would be useful to some readers to point that out ;)
Yes, you are correct. RPi3 and audio jack. Good catch. :)