Git Product home page Git Product logo

bluevoice-for-linux's Introduction

BlueVoice Linux Receiver - BVLINK_rbpi3

This repository contains the ST BVLINK_rbpi3 app source code for Linux OS. The application has been tested on Raspberry Pi 3 Model B but could be easily ported to other Linux platform provided that they support ALSA drivers and BlueZ.

The BVLINK_rbpi3 application can receive an audio stream over Bluetooth Low Energy link using the "BlueVoice" vendor-specific profile. The received audio stream is then exported as a it was a standard microphone peripheral taking advantage of the ALSA aloop device.

BlueVoice transmitting device

The transmitter (or BLE microphone) can be any ST platform that supports the BlueVoice protocol. The following table states the list of compatible firmware and the supported hardware platform that can be programmed as "BlueVoice" transmitting device.

Firmware Name Supported hardware platforms
FP-AUD-BVLINK1 SensorTile, BlueCoin or Nucleo+X-Nucleo
FP-SNS-ALLMEMS1 SensorTile, BlueCoin or Nucleo+X-Nucleo
STSW-BLUEMIC-1 STEVAL-BlueMic-1

SensorTile Development kit --> www.st.com/sensortile BlueCoin Starter Kit --> www.st.com/bluecoin STEVAL-BLUEMIC-1 --> www.st.com/en/evaluation-tools/steval-bluemic-1.html

FP-AUD-BVLINK1 --> www.st.com/en/embedded-software/fp-aud-bvlink1.html FP-SNS-ALLMEMS1 --> www.st.com/en/embedded-software/fp-sns-allmems1.html STSW-BLUEMIC-1 --> www.st.com/en/embedded-software/stsw-bluemic-1.html

The chosen firmware must be configured to stream BlueVoice at either 8KHz or 16KHz with a connection interval set to 8. FP-AUD-BVLINK1 or FP-SNS-ALLMEMS1

BV_ADPCM_Config.sampling_frequency = FR_8000; /* FR_16000; */
#define AUDIO_IN_SAMPLING_FREQUENCY   SAMPLING_FREQ_8000 /* SAMPLING_FREQ_16000 */
aci_l2cap_connection_parameter_update_request(handle,
                                              8 /* interval_min*/,
                                              8 /* interval_max */,
                                              0   /* slave_latency */,
                                              400 /*timeout_multiplier*/);

STSW-BLUEMIC-1

#define AUDIO_SAMPLING_FREQUENCY     (uint16_t)(SAMPLING_FREQ_8000) /* SAMPLING_FREQ_16000 */ 
aci_l2cap_connection_parameter_update_request(handle,
                                              8   /* interval_min*/,
                                              8   /* interval_max */,
                                              0   /* slave_latency */,
                                              400 /*timeout_multiplier*/);

Once the firmware code has been modified according to the above hints it must be recompiled and flashed on the microcontroller, STM32 or BlueNRG-1 depending on the chosen platform.

BVLINK_rbpi3 application

Prerequisites

  • Linux based system (Tested on Raspberry Pi 3 Model B)
  • Linux OS (Tested on Raspbian)
  • ALSA kernel drivers
  • BlueZ kernel modules
  • Python 3

Installing procedure

Type the following commands to the console to install required packages

 sudo apt-get update
 sudo apt-get install build-essential libssl-dev libffi-dev python-dev python-cffi libglib2.0-dev
 sudo pip3 install sounddevice
 sudo pip3 install bluepy

Type the following commands to the console to load required module

 sudo modprobe snd-aloop 
 sudo bash -c "echo snd-aloop >> /etc/modules"
 sudo bash -c "echo options snd_bcm2835 index=0 >> /etc/modprobe.d/alsa-base.conf"
 sudo bash -c "echo options snd_aloop index=-2 >> /etc/modprobe.d/alsa-base.conf"

Clone the repository

git clone https://github.com/STMicroelectronics-CentralLabs/BlueVoice-for-Linux.git

Go to the proper directory

cd BlueVoice-for-Linux/BVLINK_rbpi3

Running the application

 sudo python3 main.py [mode] [frequency]
  • mode
    • alsa_playback: to playback directly the audio acquired from ST platform to the speaker
    • stl_capture: to create a standard microphone named STL_capture for audio acquisition by audacity or arecord
  • frequency
    • 16000: for a 16KHz audio frequency
    • 8000: for a 8KHz audio frequency

Running example: To create a 16KHz microphone peripheral named STL_capture.

 sudo python3 main.py stl_capture 16000

Acquisition example: Create a 16Khz file audio called "record1.wav" by arecord.

 arecord -D STL_capture -f S16_LE -r 16000 -c 1 record1.wav

Troubleshooting

Prevent audio out garbling because of audio out peripheral of raspberry

sudo bash -c "echo disable_audio_dither=1 >> /boot/config.txt"
sudo bash -c "echo audio_pwm_mode=2 >> /boot/config.txt"

Authors

  • Central Lab - STMicroelectronics -

License

COPYRIGHT(c) 2018 STMicroelectronics

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

bluevoice-for-linux's People

Contributors

faenzafernando avatar nikapov-st avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.