Hi I've trying to solve this more then 3 weeks.

Now...i can't solve it myself :(

I want to made audio spectrum which can support microphone input and bluetooth(android) input.


Raspberry pi 4 External USB Audio Sound card Adapter 7.1 Virtual Channel with Cable Microphone 3.5mm interface sound Cards. Link

3.5mm analog speaker

3.5mm microphone

Android phone

  1. Speaker and microphone are connected to USB sound adapter.

  2. Usb sound adapter is connected to raspberry pi

  3. Android phone is connect to raspberry pi via bluetooth

(I installed "pulseaudio-module-bluetooth" package to connect android phone)

Refer Environment

I'm using processing(URL) to anlaysis audio.

And processing is installed on pi.

and here is the .pde code which can run on pi.

import ddf.minim.analysis.*;
import ddf.minim.*;
import processing.serial.*; 

Serial port1; 
Serial port2;

Minim minim;
AudioInput in;
FFT fft;

int buffer_size = 4096; 
float sample_rate = 200000;

int freq_width = 250;

int[] freq_array = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
float[] freq_height = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

void setup()
  size(200, 200);

  minim = new Minim(this);
  port1 = new Serial(this, "dev/arduino_1" , 115200);
  port2 = new Serial(this, "dev/arduino_2" , 115200);

  in = minim.getLineIn(Minim.MONO,buffer_size,sample_rate);

  fft = new FFT(in.bufferSize(), in.sampleRate());


I'm using FFT for analysis sound and using minim library for visualizing

FFT Minim Library

My problem

How can I separate bluetooth audio input and microphone input each other?

according below line,

in = minim.getLineIn(Minim.MONO,buffer_size,sample_rate);

Minim get sound from soundcard.

but it's always input by microphone.

  1. I want to get audioinput from bluetooth via minim library.
  2. And also want to choose mic input & bluetooth input if i want.. i can switch.
  3. If it's impossible to use minim for this techinc... please advice other way..

Here is my profile for soundcard.

$ aplay -l 

**** List of PLAYBACK Hardware Devices ****

card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]

  Subdevices: 7/7

  Subdevice #0: subdevice #0

  Subdevice #1: subdevice #1

  Subdevice #2: subdevice #2

  Subdevice #3: subdevice #3

  Subdevice #4: subdevice #4

  Subdevice #5: subdevice #5

  Subdevice #6: subdevice #6

card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]

  Subdevices: 1/1

  Subdevice #0: subdevice #0

card 1: Device [USB Audio Device], device 0: USB Audio [USB Audio]

  Subdevices: 1/1

  Subdevice #0: subdevice #0 

$ nano .asoundrc 
pcm.!default {

    type asym

    capture.pcm "mic"

    playback.pcm "speaker"


pcm.mic {

    type plug

    slave {

        pcm "hw:1,0"



pcm.speaker {

    type plug

    slave {

        pcm "hw:1,0"



Any help is appreciated.

Thank you!

  • So you have a problem using Pi4 Processing Minim talking to sound card. Minim last update is 2018, and there is no support for Rpi4B. Furthermore, minim docs itself is minimal, not to mention that java does not run that smoothly (comparing with Python) in Rpi buster. I would suggest to switch to numPy FFT which is many times more powerful. (1) Processing for Pi:pi.processing.org/get-started, (2) NumPy FFT: docs.scipy.org/doc/numpy/reference/routines.fft.html. – tlfong01 Nov 30 '19 at 1:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.