Hot answers tagged

66

Sound does not work with an HDMI monitor This is caused by some computer monitors which select DVI mode even if an HDMI cable is connected. This fix may be necessary even if other HDMI devices work perfectly on the same monitor (or TV)! Edit the configuration file - see the instructions at Raspberry-Pi Configuration File. Add the following line to the ...


61

This is the main project my Raspberry Pi is dedicated to right now, so I figure I can add my two cents. Keep in mind this project is still very much a work in progress. I chose to use the C programming language for this project exclusively on the Raspbian OS, and that may have affected some of my decisions and instructions. I'm going to only list free and ...


32

I recommend the widely popular Pygame. I may be wrong, but I believe that it is pre-installed on the Pi. You can use the Pygame Mixer Music Module to play audio files. I have included some example code below. Assuming that we have an audio file called myFile.wav. import pygame pygame.mixer.init() pygame.mixer.music.load("myFile.wav") pygame.mixer.music....


30

Background It's amazing to see how much effort has been put in to trying to resolve various sound related problems for the Raspberry Pi. Apparently it must be the weakest spot for new users to successfully develop with and use ALSA under Raspbian. Having spent considerable time and effort trying to get my own RPi3 sound working in different OS versions ...


28

Turns out that the OP was thinking along the correct path with his trying $ sudo nano /etc/modprobe.d/alsa-base.conf and changing the index from -2 to 0 via adding options snd-usb-audio index=0 to the file. However, this wasn't working. The correct way to do it is to add options snd-usb-audio index=0 followed by options snd_bcm2835 index=1. Essentially ...


25

I have been on this project after while (to help my friend doing their paper for graduating) and find the online project doing just fine (although the pi processing the audio is quite lagging the pi, and voltage drop make it freeze as the only way to make it reboot is to unplugged the power cable). This is the step that I've been working on and it works on ...


24

If you are running Linux on your PC then this is perfectly doable, as long as you install and properly configure PulseAudio on both, your Raspberry Pi and your Linux PC. If your PC is running Windows... Skip to the end of the post (which I have just updated). Another option would be to use PulseAudio as an AirPlay receiver/client, but as far as I know, ...


19

The official instructions for creating a "direct connection" on a network hopefully just work for most people, but it seems pulseaudio and I do not get along that well: it took me hours. [Besides "direct connection", you can also use a "tunnel" method described further down, but I recommend reading this first.] I now have a (fedora 17) desktop streaming ...


17

Here is an alternate solution that doesn't rely on PulseAudio: https://github.com/lukasjapan/bt-speaker Install on raspbian as root with: curl -s https://raw.githubusercontent.com/lukasjapan/bt-speaker/master/install.sh | bash It will start a bluetooth speaker daemon that automatically accepts a single client for A2DP/AVRCP and pipes the audio stream ...


16

You can also set the volume with the command-line amixer tool e.g. amixer cset numid=1 -- -2000 Note: amixer and alsamixer are part of the alsa-utils package. You may need to install this first.


15

There is no microphone input in the Raspberry Pi. Raspberry Pi's sound chip only supports audio output, not input. If you want to record some audio using RPi you will have to use some external microphone device, like USB microphone. Some USB webcameras also have build in microphones so you could use it.


15

There are a few reasons why this could be happening. Possible Problem #1: Wrong RasPi hardware audio output selected (auto vs. HDMI vs. headphone/pwm out) Solution: Force selection of the correct hardware. amixer cset numid=3 0 # automatic detection (not always reliable) amixer cset numid=3 1 # force headphone (PWM) output amixer cset numid=3 2 # force ...


14

AFAIK only one audio output can be selected. You can, however, select one of them manually using amixer command: sudo amixer cset numid=3 <n> Where is 0=auto, 1=analog, 2=hdmi. By default it's set to auto which means HDMI if present, analog otherwise. Unlike changing video output, this change does not need rebooting.


14

With Raspbian Jesse, to change the default audio device is simpler than it used to be. Now, simply use this command to list your alsa-detected sound cards, and take note of the card number of your preferred device. aplay -l Then create/edit the alsa configuration file at ~/.asoundrc, or the system wide one at /etc/asound.conf, and paste these lines: pcm.!...


14

Judging by schematics the audio output circuit has not changed. It is definitely the same in Pi3 and Pi2, however in Pi1 this portion is omitted from the public schematics, but I have no reason to believe its different. This is a very simple audio output circuit that smooths PWM from the CPU through a bandpass filter @ 33Hz-15KHz. Additionally this ...


13

The Peripherals datasheet for the BCM2835, used on the Raspberry Pi, gives you the answer in Chapter 8. I quote: "The PCM audio interface is an APB peripheral providing input and output of telephony or high quality serial audio streams. It supports many classic PCM formats including I2S." 20 pages of information on this subject alone. Like you said: ...


13

As shown here you can get I2S via P5: http://elinux.org/RPi_Low-level_peripherals#P5_header And here is a kernel driver for using it: http://blog.koalo.de/2013/05/i2s-support-for-raspberry-pi.html


13

You could use mpd, pulseaudio and raop2 module, if necessary: mpd for managing playlists, library, etc (sudo apt-get install mpd) pulseaudio for managing audio outputs: raop for AirPlay, or any other output device such as analog jack, HDMI, http streaming service, etc (sudo apt-get install pulseaudio) raop2 module for pulseaudio if the original raop module ...


12

This is a known problem that you can read about here and see the bug report here. It appears to be an issue with the Broadcom VideoCore firmware, and the popping is caused by voltage jumps as the audio is enabled and disabled. There is no current solution to the problem, however you can mitigate it's effect by playing audio continuously, instead of having ...


12

Essentially all you have to do to create a start-up script is the following: Create a file here and make it executable: sudo nano /etc/init.d/start-sound && chmod +x $_ Add it to the default runlevel: sudo update-rc.d start-sound defaults All your script really needs to do is call aplay on an audio file. Something like this: # /etc/init.d/start-...


12

I have seen some tutorial where someone used an Phillips TEA 5767 FM Tuner to receive radio. with this breakout board. You should be successfull with that! It seems the TEA cost about $3~4$. This blog gives a detailed description how you can convert your PI into an FM Tuner: Here in this post where there is a discussion about the PI and the TEA. I hope ...


11

I needed a script to play a song from thirty seconds in in the background whilst responding to other user input. I then wanted it to end the song on some event. I don't suppose it's particularly elegant, but I opened a pipe to a background MPlayer process. import subprocess player = subprocess.Popen(["mplayer", "song.mp3", "-ss", "30"], stdin=subprocess....


11

The product announcement does not list any form of audio in. You could use a USB device as mentioned by Phil, or use a hat that's designed for the job.


9

I also ran into the same problem with my Raspberry Pi 2. I connected my Pi to my HD TV via an HDMI cable. My solution: Set the audio output using the following command: amixer cset numid=3 2 I tested the sound output using the following command, but no sound was heard: speaker-test -c2 -t wav To enable HDMI sound, I followed the directions found here ...


9

I think I have a way for solving your problem, try to type omxplayer -o local xxx.mp3(for mp3 file) or omxplayer -o local xxx.mp4(for mp4 file) to hear sound from raspi over your headphone. And you can also type omxplayer --help for more usage about omxplayer.


9

I expect the pi will use ALSA in which case you probably want the command alsamixer from the command line, or maybe there will be a GUI mixer control app. You should be able to put a command to alsamixer or edit your ALSA config files to lower the default volume at boot time if needed.


9

I have got it working on my Raspberry Pi using the ALSA sink, with procedure as follows: To install the necessary files: sudo apt-get install pulseaudio pulseaudio-module-zeroconf alsa-utils avahi-daemon To enable ALSA: sudo modprobe snd-bcm2835 # load module for single boot echo "snd-bcm2835" | sudo tee -a /etc/modules # load ...


9

Ok, first delete the file /etc/modprobe.d/alsa-base.conf Raspbian Jessie does not use this config file like Wheezy did. To find what address your device uses you need to first enter the command aplay -l this shows all audio output devices, and their address. For example, my USB sound card comes up as device 1 in the output which looks like this. card 0: ...


9

The audio jack channels (left and right) are provided by PWM driven GPIO (channel 0 by GPIO 12 or 18, and channel 1 by GPIO 13 or 19). So if you connect appropriate circuitry to those GPIO you will get audio. See BCM2835 ARM Peripherals for details on the GPIO and PWM peripheral. EDITED TO ADD Some background On recent Pis the audio jack output is ...


8

have you tried: adduser <username> audio as suggested here, or: usermod -a -G audio <username> as suggested here.


Only top voted, non community-wiki answers of a minimum length are eligible