sudo apt-get update && sudo apt-get upgrade

sudo apt-get install alsa-utils bluez bluez-tools pulseaudio pulseaudio-module-bluetooth

pactl list sources short (List available audio sources with simplified format)

(List available audio sources with simplified format) pactl list sources (List available audio sources with more details)

pactl list sources short

0 alsa_output.platform-soc_audio.analog-stereo.monitor module-alsa-card.c s16le 2ch 44100Hz SUSPENDED

0

alsa_output.platform-soc_audio.analog-stereo.monitor

module-alsa-card.c

s16le 2ch 44100Hz

SUSPENDED

Type in bluetoothctl in terminal to enter bluetooth command line terminal. You should see the next line in terminal start with [bluetooth]# once you press enter. Type in power on and press enter. You should see output " Changing power on succeeded " from terminal. Type in agent on and press enter. You should see output " Agent registered " from terminal. Type in default-agent and press enter. You should see output " Default agent request successful " from terminal. Type in discoverable on and press enter. You need to key in this command to make sure your bluetooth dongle is visible to your bluetooth speaker. You should see output " Changing discoverable on succeeded [CHG] Controller XX:XX:XX:XX:XX:XX Discoverable: yes " from terminal. The string XX:XX:XX...XX is your bluetooth dongle's mac address. [Optional] If you see message from terminal state " [CHG] Controller XX:XX:XX:XX:XX:XX Discoverable: no ", just repeat step 5 to make your device discoverable again. Turn on your bluetooth speaker and set it to pairing mode. (Follow your bluetooth speaker manual to set it to pairing mode) Type in scan on to start scanning for bluetooth devices. You should see a similar message " [NEW] Device YY:YY:YY:YY:YY:YY BLUE SYNC OR3 ". For my case my bluetooth speaker name is Blue Sync OR3. YY:YY:YY...YY is the bluetooth speaker mac address. Type in pair YY:YY:YY:YY:YY:YY to pair with the bluetooth speaker. You will see a bunch of message and ends with message " [CHG] Device YY:YY:YY:YY:YY:YY Paired: yes Pairing successful " if pairing successful. Type in trust YY:YY:YY:YY:YY:YY to enable authentication-less connection with your bluetooth speaker. You should see a message " [CHG] Device YY:YY:YY:YY:YY:YY Trusted: yes ". Type in connect YY:YY:YY:YY:YY:YY to establish connection to bluetooth speaker. You should see output " Attempting to connect to YY:YY:YY:YY:YY:YY [CHG] Device YY:YY:YY:YY:YY:YY Connected: yes Connection successful " from terminal if connection is successful. Type in exit to exit from bluetooth command line terminal.

pactl list sinks short

0 alsa_output.platform-soc_audio.analog-stereo module-alsa-card.c s16le 2ch 44100Hz SUSPENDED

1 bluez_sink.YY_YY_YY_YY_YY_YY module-bluez5-device.c s16le 2ch 44100Hz SUSPENDED

bluez_sink.YourDeviceMacAddress

alsa_output.platform-soc_audio.analog-stereo.monitor

0

bluez_sink.YY_YY_YY_YY_YY_YY

1

pactl load-module module-loopback source=0 sink=1 rate=44100 adjust_time=0

top

sudo apt-get install mplayer2

pactl set-source-volume 0 32768

0

32768

pactl list sources

mplayer -ao help

pulse PulseAudio audio output

mplayer -ao pulse path_to_your_song.mp3

To remove the link between audio source and sink when you are not using it. Simply type in command pactl unload-module module-loopback . pacmd set-source-volume 0 32768 command works as well to set source volume. You can also set sink volume using command pacmd set-sink-volume 1 32768 . Remember use pactl list sinks short command to find out the unique id of your desired bluetooth speaker.

https://gist.github.com/oleq/24e09112b07464acbda1

Been a while since my last post. Totally crazy year for me last year.Alright, for those who come from my previous post of bluetooth audio streaming using Raspberry Pi. I finally found a proper procedure to setup bluetooth device in Raspbian Jessie using solely command line only. This method will work on Raspbian Jessie lite version as well. Let's start.My hardware setup is the same as shown in my previous post . The differences start on the software setup side. Assuming you already flash fresh Raspbian on your Pi (Mine is Raspbian Jessie dated on 2nd March 2017). Firstly we need to install additional packages using command below.Once installation complete. Type in command below to make sure PulseAudio is working. Use any command below for verification.Above command should provide you a list audio sources available. By now you should see only one audio source. Below is the output example from my Raspberry Pi using commandIf you see same output above in your Pi that means your PulseAudio is working properly. Here are some simple explanation on the output.means the unique id of your audio source,is the name of your audio source,is the driver name,is audio source's sample specification andmeans the audio source state is currently suspended.Next, it is time for us to setup the bluetooth speaker. Follow instructions below:Once you successfully establish connection to your bluetooth speaker, you should be able to see new bluetooth audio sink available in the Pi. To verify this, type into check how many audio sinks available in your Pi. You should see output below:The second output show in terminal is my bluetooth speaker's audio sink. The name of the device usually similar to. If you see this in your Pi, that means PulseAudio is picking up your bluetooth speaker properly.Now that we have almost everything ready, the trick is to redirect whatever source that is playing in Raspberry Pi and send the audio signal to your bluetooth speaker. To do this, we need to send another command to PulseAudio so that it will establish an audio link between the source and sink. Now remember in earlier section where we use one command to verify PulseAudio after its installation? That is the method we identify the audio source. We've already identify the name of the source audio to beand its unique id is. We also know that our audio sink name isand its unique id is. Let's key in command below to establish the link between the require source and sink.Once you enter the command, key inin terminal and you should see pulseaudio is utilizing around 11-12% of your CPU power. This indicates you successfully establish the link between audio source and sink. Press Q to quit top.Lastly we need to test whether the bluetooth speaker is playing the audio properly. Similar to my previous post , I'll use mplayer to test it, so go ahead and install mplayer by type in command. Wait for the installation to complete.I will recommend to set the source volume to 50% first because by default it is set to 100%. If you play a song using 100% i think it is not going to be pleasant to your ear. So go ahead type inin your command line and press enter.is the unique id of your source audio andrepresent 50% of volume. If volume = 100% the value is 65536. So if you want to set your own level of volume by percentage X, the formula is (X * 65536 / 100). You can verify the current volume level by type in command, Look for details under "Source#0 -> Volume:".Once mplayer2 installation complete, simply upload one MP3 file to your Pi for testing. In command line, type into list available audio output driver visible to mplayer. You should see one PulseAudio driver in the output. The output look like this "".Type in commandto start playing a song. You should be able to hear the song playing from your bluetooth speaker. It will play exactly like video shown in my previous post Thanks for reading! Enjoy playing with your bluetooth speaker using latest Raspbian Jessie!Additional note:Reference: