Rock out with Intel Edison board

Published Date
11 - Jun - 2015
| Last Updated
11 - Jun - 2015
 
Rock out with Intel Edison board

This HOW TO aims to explain the various ways to get and play sound with an Intel® Edison board.
Only loopback methods will be described, as they are more interactive and let the Edison board behave as a connected device.
If a user wants to playback a sound file, they must use an external A2DP based player connected via Bluetooth.
The 3 ways which will be described are:
1. Loopback audio from and over a USB headset
2. Loopback A2DP stream over a USB sound device
3. Loopback A2DP stream to an A2DP remote device

Requirements
Hardware :

  • An Intel Edison board with Arduino-based expansion board
  • A USB audio device (A USB headset should be perfect)
  • An A2DP device to send audio to the board (like a smartphone)
  • An A2DP device to play audio from the board (like a Bluetooth speaker)

 

Software :

  • https://software.intel.com/en-us/iot/hardware/edison/downloads

Or an image made available in 2015 or later.

Loopback audio from and over an USB headset
Step-by-step guide

1. Activate the USB host mode by moving the SW1 (between the main USB and the mini USB ports) to the position closest to the mini USB ports. You will need an external power source in this mode.
2. Plug in your USB headset.
3. Check if the device is correctly mounted:
root@edison:~# cat /proc/asound/pcm
00-00: Loopback PCM : Loopback PCM : playback 8 : capture 8
00-01: Loopback PCM : Loopback PCM : playback 8 : capture 8
01-00: USB Audio : USB Audio : playback 1 : capture 1

In this example, a USB headset is plugged in. You can see the number of playback and capture devices connected by this USB device.
root@edison:~# pactl list | grep Name | grep usb
Name: alsa_output.usb-JABRA_Jabra_BIZ_620_USB-00-USB.analog-stereo
Name: alsa_output.usb-JABRA_Jabra_BIZ_620_USB-00-USB.analog-stereo.monitor
Name: alsa_input.usb-JABRA_Jabra_BIZ_620_USB-00-USB.analog-mono
Name: alsa_card.usb-JABRA_Jabra_BIZ_620_USB-00-USB

4. Loopback the USB capture device to the USB playback device.
Loopback audio stream can be achieved with the pulseAudio module "module-loopback".
The loopback module needs to be loaded and configured according to your device names:
pactl load-module module-loopback source=<name of your source device> sink=<name of sink device>

Example:

root@edison:~# pactl load-module module-loopback source=alsa_input.usb-JABRA_Jabra_BIZ_620_USB-00-USB.analog-mono sink=alsa_output.usb-JABRA_Jabra_BIZ_620_USB-00-USB.analog-stereo
5. Speak into the microphone and check the audio on the headphone side.

Loopback A2DP stream over a USB sound device
Step-by-step guide

1. Activate the USB host mode by moving the SW1 (between the main USB and the mini USB ports) to the position closest to the mini USB ports. You will need an external power source in this mode.
2. Plug in your USB headset.
3. Check if the device is correctly mounted :
root@edison:~# cat /proc/asound/pcm
00-00: Loopback PCM : Loopback PCM : playback 8 : capture 8
00-01: Loopback PCM : Loopback PCM : playback 8 : capture 8
01-00: USB Audio : USB Audio : playback 1 : capture 1
In this example, a USB headset is plugged in. You can see the number of playback and capture devices connected by this USB device.
root@edison:~# pactl list | grep Name | grep usb
Name: alsa_output.usb-JABRA_Jabra_BIZ_620_USB-00-USB.analog-stereo
Name: alsa_output.usb-JABRA_Jabra_BIZ_620_USB-00-USB.analog-stereo.monitor

4. Connect your A2DP player device (for example, a smartphone) and check to see if it is listed in pulseaudio as a source device by unblocking the local BT device:
root@edison:~# rfkill unblock 2
Now Discover/Trust/Pair/Connect to your remote A2DP device where BTADDR is the mac address of your A2DP device:
root@edison:~# bluetoothctl
[bluetooth]# scan on
[bluetooth]# trust BTADDR
[bluetooth]# pair BTADDR
[bluetooth]# connect BTADDR
[bluetooth]# scan off
[bluetooth]# exit

Check if your A2DP device is recognized in pulse audio and get the source name of your device (should start with "bluez_source"):
root@edison:~# pactl list sources | grep bluez_source
Name: bluez_source.88_C9_D0_51_C6_AE

Note: that by default the BT edison name is "BlueZ 5.24", so this is the name that may appear on your player device. See info to modify it.
5. Loopback A2DP source device to USB playback device
root@edison:~# pactl load-module module-loopback source=bluez_source.88_C9_D0_51_C6_AE sink=alsa_output.usb-

JABRA_Jabra_BIZ_620_USB-00-USB.analog-stereo

6. Play a sound on your remote device and check audio on headphone side

Loopback A2DP stream to an A2DP remote device
Step-by-step guide

1. Connect both your A2DP player device (for a example, smartphone) and your BT speaker, then check if they are listed in pulseaudio:
root@edison:~# rfkill unblock 2
Now Discover/Trust/Pair/Connect to your remote A2DP device where BTADDR is the mac address of your A2DP device:
root@edison:~# bluetoothctl
[bluetooth]# scan on
[bluetooth]# trust BTADDR
[bluetooth]# pair BTADDR
[bluetooth]# connect BTADDR
[bluetooth]# scan off
[bluetooth]# exit
Check if both your A2DP devices are recognized in pulse audio then get the source and sink name of both your devices.
root@edison:~# pactl list | grep bluez
Name: bluez_source.88_C9_D0_51_C6_AE
Name: bluez_sink.00_1D_DF_89_12_8E
Note: that by default the BT edison name is "BlueZ 5.24", so this is the name that may appear on your player device. See info to modify it.
2. Loopback A2DP source device (smartphone) to A2DP sink device (BT speaker)
root@edison:~# pactl load-module module-loopback source=bluez_source.88_C9_D0_51_C6_AE sink=bluez_sink.00_1D_DF_89_12_8E
3. Play a sound on your remote device and check the audio on the BT speaker.
 
You can rename your Bluetooth controller name by modifying it in /etc/bluetooth/main.conf.
Uncomment the "Name" attribute and set a name in the [general] section:
[general]
...
# %d - substituted for adapter id
# Defaults to 'BlueZ'
Name = Edison
Then restart the Bluetooth service and check the controller name:
root@edison:~# systemctl restart bluetooth
root@edison:~# bluetoothctl
[NEW] Controller 98:4F:EE:02:00:6A Edison [default]
 
Troubleshooting

  • Always check to verify if Bluetooth is blocked or unblocked. Most times it is blocked and must be unblocked to start.
  • Refer to FAQ and support pages, forum posts where applicable.

For more such intel IoT resources and tools from Intel, please visit the Intel® Developer Zone

Source: https://software.intel.com/en-us/articles/rock-out-with-edison