Minim icon indicating copy to clipboard operation
Minim copied to clipboard

getLineIn() not working on Big Sur with Processing 3 and Minim 2.2.2

Open paulcanning opened this issue 4 years ago • 7 comments

As per the title.

Installed Processing 3 and Minim 2.2.2, and tried the following code

import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.signals.*;
import ddf.minim.spi.*;
import ddf.minim.ugens.*;

Minim minim;
AudioInput in;

void setup() {
  minim = new Minim(this);
  in = minim.getLineIn();
  in.enableMonitoring();
}

void draw() {
  for(int i = 0; i < in.bufferSize() - 1; i++)
  {
    line( i, 50 + in.left.get(i)*50, i+1, 50 + in.left.get(i+1)*50 );
    line( i, 150 + in.right.get(i)*50, i+1, 150 + in.right.get(i+1)*50 );
  }
}

And nothing happens.

paulcanning avatar Mar 21 '21 19:03 paulcanning

Most likely related to something changing in Big Sur's handling of audio things, might require a Java update, not sure. I can't test Big Sur on my ancient Macbook unfortunately. You could try adding a minim.debugOn() before calling getLineIn() and see what's reported in the console.

ddf avatar Mar 29 '21 01:03 ddf

Would also recommend searching the Processing forum to see if other folks have had trouble with audio on Big Sur and if they were able to fix it.

ddf avatar Mar 29 '21 01:03 ddf

The debug line gave me:

==== JavaSound Minim Debug ====
==== TargetDataLine buffer size is 16384
==== TargetDataLine format is PCM_SIGNED 44100.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian
==== TargetDataLine info is interface TargetDataLine supporting 14 audio formats, and buffers of at least 32 bytes

=== Minim Debug ===
=== byteBufferSize is 4096

==== JavaSound Minim Debug ====
==== SourceDataLine is class com.sun.media.sound.DirectAudioDevice$DirectSDL
==== Buffer size is 16384 bytes.
==== Format is PCM_SIGNED 44100.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian.

=== Minim Debug ===
=== Likely buffer underrun in AudioOutput.

paulcanning avatar Mar 29 '21 15:03 paulcanning

Well, that looks like it's successfully getting an input, but it may not be the one you are expecting. I'd recommend running the setInputMixer example in the Advanced folder of the Minim examples and see what you get onscreen for buttons. You can click on a button to attempt to open that input.

ddf avatar Mar 30 '21 03:03 ddf

I did as you asked with the example, and got this message when clicking the button for the onboard mic:

==== JavaSound Minim Error ====
==== Error acquiring TargetDataLine: Line unsupported: interface TargetDataLine supporting format PCM_SIGNED 44100.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian

=== Minim Error ===
=== Minim.getLineIn: attempt failed, could not secure an AudioInput.

paulcanning avatar Mar 30 '21 08:03 paulcanning

Ok, so it could be that the onboard mic doesn't support the default format. I'd recommend checking your system settings to see how audio for the mic is configured (ie sample rate, bit-depth) and then modify setInputMIxer to use the version of getLineIn that takes format arguments and provide those values. For example minim.getLineIn(Minim.MONO, 1024, 48000, 24) would try to acquire a mono input with a buffer size of 1024 that has a sample rate of 48kHz and a bit-depth of 24.

ddf avatar Mar 30 '21 20:03 ddf

I was getting this same error and was able to correct it with the arguments @ddf mentioned above with a slight modification. The built in Macbook Pro microphone is mono, but only works with a bit depth of 8 or 16. in = minim.getLineIn(Minim.MONO, 1024, 44100, 16); worked for me. With the caveat that I just upgraded to Processing 4 because of P3D issues. So my setup is: MacBook Pro (16-inch, 2019) MacOS Monterey Processing 4.0b5

justincouch avatar Feb 10 '22 15:02 justincouch