Audacity For Raspberry Pi



Audacity For Raspberry Pi

Sound configuration on Raspberry Pi with ALSA

While setting up a Raspberry Pi to play streamed music usingUPnP,I have had quite a bit of trouble understanding how to configure thesound on my Raspberry Pi. This is partly because I am running it inheadless mode (no graphical desktop) and partly because sound on Linuxis fiendishlycomplicated.

Anyway, I am making progress in understanding what’s going on but I amno expert. Here are my findings on how to control the ALSA system fromthe command line. All I am focussed on here is getting control of thesound output by the 3.5mm stereo socket. If you want to control theoutput over the HDMI socket or an external USB sound card then you’llneed to do some of your own investigation.

On your Raspberry Pi’s desktop open the menu and select the Audacity application. This is your recording studio control board. Click just below the word ‘Audacity’ to begin monitoring the mic (short for microphone). Speak into the mic and see the green status bar level change with your voice. Audacity is an easy to use sound editor. Install on the Raspberry Pi by typing the following into LXTerminal: sudo apt-get update sudo apt-get install audacity. To install on a Windows computer, download the Windows version. Q&A for users and developers of hardware and software for Raspberry Pi Stack Exchange Network Stack Exchange network consists of 176 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers. Apr 08, 2021 Support for older, first-generation Raspberry Pi and Raspberry Pi Zero/Zero W models is available as well, as separate images. Installation and first impression Installing Kali Linux on the Raspberry Pi 4 is as easy as downloading the image and writing it to a microSD card with an SD card flashing utility, such as Raspberry Pi Imager. The Raspberry Pi Foundation has not yet published a schematic for the Raspberry Pi 2. However, Adafruit (and others) claim that the audio circuit is the same as the earlier, first generation Raspberry Pi. Let’s take a look at that. The Raspberry Pi drives a pulse width modulated (PWM) signal into a.

Horse leg markingsdaruma fields saddlery. ALSA is the lowest level of the Linux sound stack. The alsa-utilspackage comes ready installed on the debian wheezy distribution I amusing (2012-12-16-wheezy-raspbian.zip). It provides some usefulcommands: amixer, alsamixer, alsactl, aplay and speaker-test.

Testing

It’s good to be able to test things as you go a long to see what affectconfiguration changes have. You can do this with the speaker-testcommand for one, which will by default play white (actually pink) noiseout of the speakers. Press Ctrl-C to stop it.

Audacity For Raspberry PiAudacity for raspberry pi 2

Another command to try is aplay. This command will play WAV files forinstance as well as lots of other basic sound file types (but not thingswith complex compression such as MP3, FLAC, OGG, etc). The Pi comes withsome sound files already present, for instance in/usr/share/scratch/Media/Sounds. Try:

To get more information while the sound is playing, use the “-v” and“-V” options, e.g.

That will print a lot of info about the sound file and what device it isbeing sent to as well as a VU meter as the sound plays.

To see the available devices, use aplay -L. My machine gives thisoutput (since installing PulseAudio):

It shows that the default device to use is directly to the ALSA device.Interestingly, if I try to play via PulseAudio using aplay with aplay-D pulse then I get a bit of a pop but no sound…

amixer

Looking at the top part of the output, we can see that the playbackvolume for the left and right channels are both at maximum (65536, whichis 2^16) and are both unmuted (“on”).

To control these settings we can use the alsamixer command which gives agraphical display (in your terminal) or the amixer command. Let’s lookat amixer first:

That’s the list of things you can change (control) through the command.We can look at the playback volume in more detail:

This shows the maximum and minimum values for the playback volume andthat it is actually a pair of values (for left and right channels). Forinstance, to change the playback volume we can do:

If you wanted to change the left channel to 50% and the right to 100%for some reason then this command is for you:

To mute the sound you can you control 4:

This also affects the volume values on control 3:

However, the value of the volumes must be stored somewhere because whenyou unmute it again it restores them.

I have found odd effects when changing the volume while it is muted sobest to avoid doing that.

Saving the ALSA state

The operating system saves the ALSA sound configuration when you turn itoff and restores it when you turn it on. This is done with the/etc/init.d/alsa-utils script. The state is stored and restored usingthis file: /var/lib/alsa/asound.state

Once you have the sound configuration as you want it you can store itthere using the alsactl command which you have to run with rootpermissions as it changes a protected file. Let’s set the volume to max,unmute it and store it:

For me, this gives this changes /var/lib/alsa/asound.state to be:

If we mute it then have another look, line 5 changes to “value -10239”,line 13 changes to “dbvalue.0 -9999999” and line 19 changes to “false”.

If we were to unmute and then set the volume to 50% (as described above)then line 5 changes to “value -1405” and line 13 to “dbvalue.0 -1405”(with line 19 being now set to “true”). Not quite sure where thesenumbers come from, they are probably the decibel volumes which arelogarithmic, but let’s not go there…

If you want to stop the current state being saved when the machine shutsdown then you need to disable the alsa-utils init script from runningwhen the machine enters runlevel 0 (halt) and 6(reboot). Aslightly hacky way of doing this is to execute these commands:

Note that the files have been renamed to have a lowercase “k” at thestart. When the machine enters runlevel 0 for instance (it does thiswhen shutting down) all the scripts starting with “K” in the /etc/rc0.dfolder are executed. By renaming it to start with a lowercase “k” thefile is ignored and the ALSA state is not saved.

alsamixer

As well as using amixer on the command line to change the volumes and soon, you can also use a slightly graphical utility called alsamixer. Justtype alsamixer and you’ll get something like the screenshot shown below:

In this utility you can move the volume up and down using the up anddown cursor keys, mute and unmute using the “m” key and move from onedevice to another (if you have them) using the left and right cursorkeys. Press the Esc key to exit. If you play with this and then typeamixer once you’ve exited then you’ll see that the changes arereflected in the output of that command as well.

Audacity

Final thoughts

Raspberry Pi Projects

I hope that’s useful to someone like me who is struggling to understandall this. It is only one part of the stack, so I hope to look intoPulseAudio in more detail another time as I think that’s where myproblems are at the moment.

Raspberry Pi Os

One last thing: if you completely mess things up then this commandshould sort it all out and make things sane again (sets volume to 44%for me):