rlpatton
Posts: 4
Joined: Sun Feb 10, 2013 3:55 am

Using on board sound

Tue Feb 26, 2013 2:13 am

Hello,
This is a complete nubie question. I have ported one of my MS windows (console mode) (written in C) to the PI. It works fine. However for the life of me I can not determine how to programmatically use the on board sound card. With MS windows a call to MessageBeep(MB_ICONWARNING) will cause the sound card in a PC play the associated sound with the parameter supplied (MB_ICONWARNING). How do I do something similar to this on the PI? I googled my fingers off and can’t find anything that even comes close.
I just really want the sound card to go “Beep”.

Thanks,
Ron

-rst-
Posts: 1316
Joined: Thu Nov 01, 2012 12:12 pm
Location: Dublin, Ireland

Re: Using on board sound

Tue Feb 26, 2013 11:36 am

Would

Code: Select all

fprintf(stdout, "\a" );
work?

And there is a commanline utility beep http://linux.die.net/man/1/beep for testing - I assume this could be called from your C program with exec() (or similar).

Then there is the /opt/vc/src/hello_pi/hello_audio example (at least on Raspbian) https://github.com/raspberrypi/firmware ... ello_audio

Note that if you have HDMI connected, the sound goes there by default - there is a command to select the output...
http://raspberrycompote.blogspot.com/ - Low-level graphics and 'Coding Gold Dust'

rlpatton
Posts: 4
Joined: Sun Feb 10, 2013 3:55 am

Re: Using on board sound

Tue Feb 26, 2013 2:44 pm

Hello,
Thanks, beep will do the trick.

Ron

rlpatton
Posts: 4
Joined: Sun Feb 10, 2013 3:55 am

Re: Using on board sound

Thu Feb 28, 2013 7:56 pm

Hello,
I installed "beep" but still no sound. I believe it was mentioned that the HDMI is the default device for sound. How do I make the on board audio connector the default sound port?

Thanks,
Ron

Cloudcentric
Posts: 982
Joined: Fri Sep 14, 2012 9:13 am

Re: Using on board sound

Thu Feb 28, 2013 8:59 pm

Sound depends on what Linux system is running, both these basics blogs have info which may be helpful !

http://debianarmpi.blogspot.co.uk
or
http://archlinuxpi.blogspot.co.uk/
I know everything about nothing"

rlpatton
Posts: 4
Joined: Sun Feb 10, 2013 3:55 am

Re: Using on board sound

Fri Mar 01, 2013 2:55 am

Hi,
Those links helped very much. Aplay works and I can now hear sound via the audio port. However the alsa-utils only work as root on my machine. I must sudo any of the commands for them to work. What do I need to change so that the utilities will work with non root users?
Sorry for being a bit thick as a brick but I just can't seem to get a handle on this.

Thanks,
Ron

-rst-
Posts: 1316
Joined: Thu Nov 01, 2012 12:12 pm
Location: Dublin, Ireland

Re: Using on board sound

Fri Mar 01, 2013 1:24 pm

This is for Arch Linux, but should be the same for any other: https://wiki.archlinux.org/index.php/Ad ... stallation - maybe that helps at elast a bit...
http://raspberrycompote.blogspot.com/ - Low-level graphics and 'Coding Gold Dust'

Return to “General programming discussion”