Greetings LQ. I am working on a Raspberry Pi Zero 2 and recently attached a Waveshare WM8960 Hi-Fi soundcard. The OS is RetroPie and the Waveshare driver installation did an apt upgrade so all of the packages are up-to-date and the kernel is 5.10.81+ (IIRC).
My plan for this Pi project is a dedicated MAME system, specifically mame2000. The monitor will be either VGA or DVI, and either way it will need an alternate soundcard, whether USB or GPIO. The libretro mame2000 core is okay but mame4all is preferred due to performance and supporting hiscores and cheat files.
Before adding the Waveshare card both the lr-mame2000 and mame4all cores played the games fine over HDMI audio. Now with the soundcard attached the lr-mame2000 works fine but mame4all fails to launch. At first the log file had an ALSA error of
Code:
Unable to set hw params for PLAYBACK: Invalid argument
I spent much of the past few days Googling the error and studying the .asoundrc file to find an answer. As far as I can tell, mame4all specifically wants an ALSA device named PCM, and I solved that by creating an alias in ~/.asoundrc. Now the error is
Code:
Rate doesn't match (requested 44100Hz, get 48000Hz)
I've seen some posts in other forums about this error with USB audio adapters and was solved by adding
rate 44100 and
format S16_LE somewhere in .asoundrc. I have been trying for several hours now, following the asoundrc guide at alsa-project.org, to get such a line in .asoundrc to work. I even tried editing the 10-xxxx files in /etc/alsa/conf.d to change the default rate from 48000 to 44100. Nothing worked.
After a while I started trying to use aplay with a .wav file from /usr/share/sounds/alsa to test if it is capable of 44100. I tested with several of the names in my .asoundrc with -r 44100 and every time the playback status shows 48000. Finally, I looked in the wm8960.c file of the source code and there is one section about alc_rates
Code:
} alc_rates[] = {
{ 48000, 0 },
{ 44100, 0 },
{ 32000, 1 },
{ 22050, 2 },
{ 24000, 2 },
{ 16000, 3 },
{ 11025, 4 },
{ 12000, 4 },
{ 8000, 5 },
};
Then further down is this
Code:
#define WM8960_RATES SNDRV_PCM_RATE_8000_48000
I may be wrong but it looks like it is capable, but how can I get it to work?
The source files are located at
https://github.com/waveshare/WM8960-Audio-HAT
Also, the ~/.asoundrc file I am using is an unmodified copy of the asound.conf from the above link. At this point I have removed all of my failed attempts, and the only addition I have in place is the following alias which originally gives the "Rate doesn't match" error
Code:
pcm_slave.pcm { pcm "dmixed" }
Thank in advance