Click here to Skip to main content
15,885,309 members
Articles / Internet of Things
Article

Rock out with Intel® Edison board

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
11 Jun 2015CPOL4 min read 6.5K  
This HOW TO aims to explain the various ways to get and play sound with an Intel® Edison board.

This article is for our sponsors at CodeProject. These articles are intended to provide you with information on products and services that we consider useful and of value to developers

Get access to the new Intel® IoT Developer Kit, a complete hardware and software solution that allows developers to create exciting new solutions with the Intel® Galileo and Intel® Edison boards. Visit the Intel® Developer Zone for IoT.

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 :

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.

Intel® Developer Zone for IoT

Start inventing today with the Intel® IoT Developer Program which offers knowledge, tools, kits and a community of experts to quickly and easily turn your innovative ideas into IoT Solutions.

Dream it, Build it with the Intel® IoT Developer Kit for Intel® Edison and Intel® Galileo platforms. These kits are versatile, performance-optimized and fully integrated end-to-end IoT solutions supporting a variety of programming environments, tools, security, cloud connectivity and hardware.

For more resources and to learn how the new Intel® IoT Developer Kit v1.0 can help streamline your IoT projects:

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
You may know us for our processors. But we do so much more. Intel invents at the boundaries of technology to make amazing experiences possible for business and society, and for every person on Earth.

Harnessing the capability of the cloud, the ubiquity of the Internet of Things, the latest advances in memory and programmable solutions, and the promise of always-on 5G connectivity, Intel is disrupting industries and solving global challenges. Leading on policy, diversity, inclusion, education and sustainability, we create value for our stockholders, customers and society.
This is a Organisation

42 members

Comments and Discussions

 
-- There are no messages in this forum --