Enabling Equalizer on Raspberry Pi using ALSA equal Plugin


This post shows how to setup a system wide equalizer on Raspberry Pi using ALSA equal plugin. Below are my setup.

  • Raspberry Pi3 B+ with Raspbian Stretch (2018 April version)
  • 3.5 mm plug Speaker

 

Contents
– Assumptions
– Steps
1. Equalizer Plugin Installation
2. ALSA Configuration
3. Play audio
4. Verify Equalizer
– Notes
– Reference

 

Steps
1. Equalizer Plugin Installation

 

2. ALSA Configuration
2-1. Create .asoundrc.

2-2. Add the lines below, save and close the file.

2-3. Reload .asoundrc.

 

3. Play audio
Play a sample sound file in a loop for testing.

Note: Press Ctrl+C to exit.

 

4. Verify Equalizer
Adjust the equalizer by using alsamixer command.

The sound from Raspberry Pi’s speaker should change as you change the equalizer values.

 

Notes
Since Raspbian Stretch, Bluetooth audio is handled by ALSA using bluez-alsa [2]. So if A2DP sink is enabled, this equalizer can be also applied on Bluetooth audio.

 

References
[1] Raspbian: the great Equalizer
[2] Raspbian Stretch has arrived – Raspberry Pi Official Blog

 

 

Streaming Bluetooth Audio from Phone to Raspberry Pi using ALSA


This post shows steps to setup Bluetooth audio sink on Raspberry Pi using bluez-alsa. Bluetooth audio sink (A2DP sink) enables Raspberry Pi to receive audio from other Bluetooth devices (e.g. smartphone) and play it through the connected speaker. Below are my setup.

  • Raspberry Pi3 B+ with Raspbian Stretch (2018 April version)
  • 3.5 mm plug Speaker
  • Smartphone

 

Contents
– Steps
1. Bluetooth Pairing and Connection
2. Audio Routing
3. Verify
– Summary
– Troubleshoot
– Reference

 

Steps
1. Bluetooth Pairing and Connection
1-1. Launch BlueZ command line interface.

1-2. Setup a pairing agent.

1-3. Make the Raspberry Pi discoverable.

1-4. On your phone, search and select your Raspberry Pi from Bluetooth menu.

1-5. Confirm the pairing on both your phone and Raspberry Pi.

1-6. Authorize A2DP service (first 32 bits: 0000110d). [1]

Note: You may be asked about other services (such as HFP: 0000111E) depending on what services your phone supports. Just answer ‘yes’ to all the services if you are not sure.

1-7. Trust the phone so that Raspberry Pi will automatically accept connections from the phone from the next time.

Note: Replace “XX:XX:XX:XX:XX:XX” with your phone’s Bluetooth device address.

1-8. Exit from BlueZ command line interface.

 

2. Audio Routing
2-1. Forward audio from the phone to Raspberry Pi’s output.

 

3. Verify
3-1. Launch a media player and play some music on your phone. You should be able to hear the music from Raspberry Pi’s speaker.

 

Troubleshoot : Sound Cutting Out
Raspberry Pi’s (3 / 3+ / Zero W) on-board Bluetooth+WiFi combo chip has an issue and the Bluetooth sound cuts out when WiFi is enabled [2]. If you don’t need WiFi, you can just disable the WiFi interface to avoid the sound cutting issue.

If you need WiFi, one of the workarounds is to disable the on-board Bluetooth and use a Bluetooth dongle (e.g. Plugable BLE Adapter, Panda Bluetooth 4.0 Adapter) instead. Below is the steps to do that.

1. Open “/etc/modprobe.d/raspi-blacklist.conf”.

2. Add lines below and save.

3. Connect Bluetooth dongle on Raspberry Pi’s USB port.

4. Restart the Raspberry Pi.

 

References
[1] Service Discovery – Bluetooth SIG
[2] Pi3 bluetooth audio stutters with Wifi enabled

 

 

Enabling Equalizer on Handsfree Sending Audio with ALSA equal plugin


This post shows steps to enable equalizer on Bluetooth handsfree (HFP) sending audio by using ALSA equal plugin.

 

Contents
– Prerequisites
– Steps
1. Equalizer Plugin Installation
2. ALSA Configuration
3. PulseAudio Configuration
4. Connect your phone and make a call
5. Adjust equalizer
– Reference

 

Prerequisites
Bluetooth Handsfree profile needs to be enabled first. If it’s not done yet, please refer this post.

 

Steps
1. Equalizer Plugin Installation

 

2. ALSA Configuration
2-1. Load the kernel module of ALSA loopback device.

The following command enables the module at boot time,

2-2. Create .asoundrc.

2-3. Add the lines below, save and close the file.

1-4. Reload .asoundrc by entering the command below:

 

3. PulseAudio Configuration
3-1. Launch PulseAudio if it’s not running yet.

3-2. Add modules and set default source as below:

 

4. Connect your phone and make a call
4-1. Connect your phone via bluetooth by using bluetoothctl.

4-2. Make a call by using your phone, or oFono.

 

5. Adjust equalizer
Now adjust the equalizer by using alsamixer command and listen the audio on the far-end.

 

Reference
– Redirect an audio stream with aloop
https://blog.getreu.net/projects/snd-aloop-device/body.html

 

 

Accessing SD Card from Linux VirtualBox Guest on Windows Host

This post shows steps to enable SD card access from Linux VirtualBox guest on Windows host. In this post, I use Windows 10 as the host and Ubuntu 18.04 as the guest.

 

Contents
– Steps
1. Create Virtual Machine Disk file (VMDK) for the SD Card device
2. Attach SD card VMDK to VM
3. Verify
– Troubleshoot

 

Steps
1. Create Virtual Machine Disk file (VMDK) for the SD Card device
1-1. Open Command Prompt as administrator (“Windows” key + “x” and select “Command prompt (admin)”).

1-2. Check the device ID for the SD card device

The result should be like this. In this example, the deviceID for the SD card is “\\.\PHYSICALDRIVE1”.

1-3. Create VMDK file for the SD card device by using “VBoxManage” command.

Note:
Replace “C:\Program Files\Oracle\VirtualBox” and “\\.\PHYSICALDRIVE1” with the installation folder of your VirtualBox and the device ID from the previous step respectively. The result should be like this.

and “sdcard.vmdk” file will be appared on the Desktop.

 

2. Attach SD card VMDK to VM
2-1. Launch VirtualBox as administrator.

2-2. Navigate to “Settint” > “Strage”.

2-3. Click on “Controller: SATA”.

2-4. Check “Use Host I/O Cache” check box.

2-5. Then, click on “Adds hard disk” icon.

2-6. Select “Choose Existing Disk”.

2-7. Navigate to Desktop and select the “sdcard.vmdk” file.

 

3. Verify
3-1. Launch the VM and verify. In my case it appeared as “/dev/sdb” as below (Raspbian OS image in 32GB SD card).

 

Troubleshoot
If you got the error below (during/after you made changes on the SD card), please go back to Step 2 and make sure “Use Host I/O Cache” check box is checked.

“I/O cache encountered an error while updating data in medium “ahci-0-1″ (rc=VERR_ACCESS_DENIED)”

 

 

Using Your Phone as Touch Screen Display for Raspberry Pi

Got a Raspberry Pi but don’t have a display, keyboard, or mouse? You can go with headless setup, or use your phone as a touch screen display (with onscreen keyboard).

This post shows steps to connect Raspberry Pi with your phone wirelessly and use it as a touch screen display by using Remote Desktop Protocol [1].

Here is the list of contents of this post.

Contents
– Assumptions
– Steps
1. Remote Desktop Server Setup on Raspberry Pi
2. Remote Desktop Client Setup on Your Phone
– Reference

 

 

Assumptions
Here are some assumptions before start. The parentheses shows my environment for reference.

  • Raspbian Desktop runs on Raspberry Pi (Raspbian 2018 March on Raspberry Pi 3+)
  • iOS or Android device (Android 7.0)
  • Raspberry Pi and phone is connected to same network (private Wi-Fi network: 192.168.0.0/24)
  • SSH enabled on Raspberry Pi

 

 

Steps
1. Remote Desktop Server Setup on Raspberry Pi
xrdp [2] is a remote desktop server which is capable of accepting connections from Microsoft Remote Desktop.

1-1. Update package list.

1-2. Install xrdp.

 

2. Remote Desktop Client Setup on Your Phone
For client side, we’ll use Microsoft Remote Desktop app which is available for both iPhone and Android. I used Android for below example but the steps are very similar for iPhone.

2-1. Install Microsoft Remote Desktop from the app store.

2-2. Launch the app, then read and accept the terms of the agreements.

2-3. Touch “+” button, then select “Desktop”.

(* I changed the display orientation to portrait mode.)

2-4. Enter Raspberry Pi’s IP address, user name and password.

IP address can be found by using ifconfig command on Raspberry Pi.

The result should look like this:

 

2-5. Tap on newly created Desktop.

 

2-6. If everything is fine, Raspberry Pi’s desktop will be displayed on your phone!

 

Microsoft Remote Desktop app provides an onscreen keyboard.

 

Also, you can select “Touch” or “Mouse Pointer” in setting menu.

 

 

References
[1] Remote Desktop Protocol – Wikipedia
[2] xrdp: Open Source Remote Desktop Protocol Server
[3] How to Use an Android Tablet as a Screen for Raspberry Pi