Verdin microphone input example

All,

I found this example for playing sound.

Is there a sample for obtaining microphone input? Nothing really jumps out at me in this list.

Greetings @seasoned_geek,

We currently don’t have any code examples for microphone capture. The only thing we have that I could find is this article: Audio (Linux)

Though this is more about using the alsa command line utilities. You seem to be looking for C++ example. I guess then the best reference would be looking at the asoundlib.h functions for the appropriate API.

Best Regards,
Jeremias

Okay,

I looked at the link. When you get down to the Verdin stuff, it shows this.

# cat /proc/asound/cards
 0 [imx8mpnau8822  ]: imx8mp-nau8822 - imx8mp-nau8822
                      imx8mp-nau8822

When I SSH into my dev board I see this:

# ls proc/asound
# cat /proc/asound/cards
cat: /proc/asound/cards: No such file or directory

That’s from straight into the board. This is not a device qualifier missing on a docker command. There is obviously some step hardware people take for granted missing from those instructions.

Either that or there is a jumper somewhere that needs to be set.

Naturally if I try to run my code that works perfectly in Ubuntu

ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM default
Can't open audio default: No such file or directory

So, what is the secret handshake to get the iMX8M Plus to see the sound on the full sized Verdin carrier board?

After walking away from this for the weekend and focusing on life in general I came back to mine the links again.

This first link needs to include the critical piece of information from this second link.

https://developer.toradex.com/knowledge-base/how-to-play-audio-on-torizoncore-using-alsa-and-cc

One must add

--device=/dev/snd

to your docker run command

One must also cold boot before doing that. For some reason, this can “just go away.”

verdin-imx8mp-06848973:~$ cat /proc/asound/cards
 0 [imx8mpnau8822  ]: imx8mp-nau8822 - imx8mp-nau8822
                      imx8mp-nau8822

It wasn’t there on Friday when I wrote this, but after this morning’s cold boot it was back.

Just to clarify then, does this work now? Or are you still trying out approaches?

Also it’s very odd that there was no sound-card hardware detected when you initially tried this. If you’re able to replicate/reproduce this behavior please let me know so I can properly report it as a bug.

Best Regards,
Jeremias

I have yet to try replicating, but I believe it should be easy to reproduce. The only difference between the previous and the successful iteration was has having the speakers plugged in during cold boot. I had the board already running when I plugged the speakers in and saw nothing.

My guess is the devices are only created when output is sensed on cold boot and that the hot-plug logic needs a bit of work. Might be specific to the full sized Verdin dev board?

I have a bigger hole to dig myself out of right now.

Oh!

You guys seriously need to rewrite the alsa-example program. That was written by an Assembly programmer who begrudgingly used C. It’s got “goto” statements and other frowned upon practices.

Just an FYI. Might not want to be holding that up as an example of how to do things.

Your theory sounds correct, probably the driver for the sound card doesn’t load unless a device is present.

Thank you for your feedback as always. Please let us know if you encounter any issues with the audio subsystem.

Best Regards,
Jeremias