Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Solved] AudioIn needs to be granted audio device access to capture sound on Mac OSX 10.14 Mojave #30

Closed
crcdng opened this issue Apr 29, 2019 · 17 comments

Comments

@crcdng
Copy link

crcdng commented Apr 29, 2019

AudioIn does not work, no audio from microphone, no error message shown.

The microphone works in other applications (e.g. Skype) and AudioIn has worked in previous versions of the Processing Sound library.

To replicate, start:
File > Examples > Libraries> Sound > IO

Processing 3.5.3, Sound 2.1.0, Macbook Pro, Mac OSX 10.14.4

@kevinstadler
Copy link
Collaborator

Thanks for reporting, have you tried changing the input away from the default audio device? Call

Sound.list();

to see the list of available audio devices on your computer, you can then select which device (and input channel) to record from as documented here: https://processing.org/reference/libraries/sound/Sound_inputDevice_.html

@crcdng
Copy link
Author

crcdng commented Apr 30, 2019

I added this to the IO example and tried with the microphone (1) and the default device (0).

Output from Sound.list():

device id 0: Default Audio Device
  max inputs : 1   (default)
  max outputs: 2   (default)
device id 1: MacBook Pro Microphone
  max inputs : 1
  max outputs: 0
device id 2: MacBook Pro Speakers
  max inputs : 0
  max outputs: 2
device id 3: Port MacBook Pro Microphone
  max inputs : 0
  max outputs: 0
device id 4: Port MacBook Pro Speakers
  max inputs : 0
  max outputs: 0

Code:

import processing.sound.*;

AudioIn input;
Amplitude loudness;
  
void setup() {
  size(640, 360);
  background(255);
  Sound s = new Sound(this);
  Sound.list();
  s.inputDevice(1);
  
  // Create an Audio input and grab the 1st channel
  input = new AudioIn(this, 0);

  // Begin capturing the audio input
  input.start();
  // start() activates audio capture so that you can use it as
  // the input to live sound analysis, but it does NOT cause the
  // captured audio to be played back to you. if you also want the
  // microphone input to be played back to you, call
  //    input.play();
  // instead (be careful with your speaker volume, you might produce
  // painful audio feedback. best to first try it out wearing headphones!)

  // Create a new Amplitude analyzer
  loudness = new Amplitude(this);

  // Patch the input to the volume analyzer
  loudness.input(input);
}


void draw() {
  // Adjust the volume of the audio input based on mouse position
  float inputLevel = map(mouseY, 0, height, 1.0, 0.0);
  input.amp(inputLevel);

  // loudness.analyze() return a value between 0 and 1. To adjust
  // the scaling and mapping of an ellipse we scale from 0 to 0.5
  float volume = loudness.analyze();
  int size = int(map(volume, 0, 0.5, 1, 350));

  background(125, 255, 125);
  noStroke();
  fill(255, 0, 150);
  // We draw a circle whose size is coupled to the audio analysis
  ellipse(width/2, height/2, size, size);
}

@crcdng
Copy link
Author

crcdng commented Apr 30, 2019

I found the solution after an openframeworks app also has stopped working. On Mac OSX 10.14 Mojave an application has to be given microphone access explicitly.

There are two ways to do it. One is by requesting authorization for media capture through the application. It will then ask the user during the first startup.

The other one is by the user in System Preferences -> Security & Privacy -> Privacy.

Screenshot 2019-04-30 10 55 15

@kevinstadler
Copy link
Collaborator

Thanks for the detailed report, I'll keep this issue open so that other people can find it too if they run into the same problem.

@kevinstadler kevinstadler changed the title AudioIn fails silently on Processing 3.5.3, Sound 2.1.0, Macbook Pro, Mac OSX 10.14.4 [Solved] AudioIn needs to be granted audio device access to capture sound on Mac OSX 10.14 Mojave May 3, 2019
@guilebarros
Copy link

Hi, guys. I'm having the same problem with audio and camera input with Processing in Mojave 10.14.4. I can't explicitly give access of the Macbook inputs cause Processing isn't even asking for permission. The code shows no errors and the devices are correctly listed with Sound.list(), but no audio input. Any tips? Thanks in advance.

@kevinstadler
Copy link
Collaborator

@guilebarros have you tried the solution in #30 (comment) above?

Regarding getting a permission request popup during runtime instead of having to set the permission manually up front in the MacOS system settings, this will have to be fixed in the Processing app itself (see #51 @benfry), not at the level of individual libraries.

@guilebarros
Copy link

Hi, Kevin. Thanks for the reply. The #30 solution didn't work cause I don't have Processing in the list to give it permission. I don't know if I understood the #51 solution. But I've edited the info.plist file from Processing Plugin folder and added these lines:

NSCameraUsageDescription
Processing Java needs access to the camera for your video calls
NSMicrophoneUsageDescription
Processing Java needs access to the microphone for your calls

But it made no difference in the behaviour regarding the camera and microphone inputs.

@dantfv
Copy link

dantfv commented Mar 2, 2020

Hi @guilebarros, I guess I am at the same point as you.

In Mojave 10.14.6, without microfone and camera on my application, althought I can list the devices from there. The application doesn`t ask permission for use, so it stops running on device.start(). I have edited info.plist from processing and the plugin folder as described in #51 solution.

I can´t (or I still haven't found) a way to manually give access to processing in System Preferences (2nd solution suggested by @i3games), therefore Processing isn't listed as solution #30.

Let's keep it rolling... if I find something new, I will share with you here!

@guilebarros
Copy link

Hi, @dantfv , thanks for your input. It's somewhat comforting knowing that I'm not alone on this issue. :) If somehow I found a solution, I will share it here too.

@hedbergj
Copy link

hedbergj commented Mar 2, 2020

Simply changing the info.plist files didn't do it for me. I see other discussions that indicate it would probably require resigning the app or even forcing OS to ask for mic/cam permissions by altering deeper db files, but I haven't gotten around to trying that yet. (MacOS catalina)

@dvlahos
Copy link

dvlahos commented Mar 2, 2020

Also having this issue. I went into System Preferences > Security and Privacy and attempted to give Processing permission to access the microphone but it appears that you cannot manually add an application. Or perhaps I just do not know how. I'm using Processing 3.5.4 in macOS Catalina 10.15.3. Any help is appreciated!

@guilebarros
Copy link

Thanks, @hedbergj. Regarding deeper db files, not sure if I'm willing to go so deep to solve this issue. But I'll be in the fence, if someone find a less scary solution I'll be glad. :)

@dantfv
Copy link

dantfv commented Mar 3, 2020

Hi @hedbergj, please, could you share this other discussion, so I can give a read and maybe a try...

Like @guilebarros, I also didn't want to go so deep, but right now I am probably taking anything that comes... :)

@hedbergj
Copy link

hedbergj commented Mar 3, 2020

@dantfv This post seems to offer a solution: https://www.reddit.com/r/macgaming/comments/dk1t47/heres_how_to_get_your_microphone_to_work_on/
However, I haven't tried it and so obviously am not endorsing it and would include some sort of 'at your own risk' clause... (Nor am I going to do it myself, since I don't really want to mess around with the system too much at this point)

@dantfv
Copy link

dantfv commented Mar 3, 2020

Hi @hedbergj, thank you very much! I followed the idea from that solution and with some small changes it worked for me!!

I will try to share with you guys in case you want to go with it. ALERT: Do it at your own risk, ok?! I am not really sure/confident about everything that I've done...

STEP 1 : Disable The System Integrity Check so that you can access the relevant system database.
Reboot your Mac and hold Cmd+R on startup. This will bring up the Recovery Mode.
Open Utility -> Terminal from the menu bar and type csrutil disable
Reboot.

STEP 2 : Manually add permission for Processing to access the microphone/camera.
Open Terminal and type the following command:
sudo sqlite3 ~/Library/Application\ Support/com.apple.TCC/TCC.db
->Now, you can select, insert, etc into the table access.
First, I did
select * from access
With that command I could understand the lines of permissions, even checking those on my System Preferences - Security and Privacy, changing the checkmarks on the apps and checking what changed on the registers.

Then, I performed:
INSERT INTO access VALUES('kTCCServiceCamera','org.processing.app',0,1,1,NULL,NULL,NULL,'UNUSED',NULL,0,1578356911);"

 Now, Processing was listed on the interface in System Preferences - Security and Privacy and my camera started on my application.  
 To be honest, I can't really tell what each value of this register means, specially the last one.. I guess it could be some sort of date-time value, so I copied from one register that I have listed (I took it from the same register from skype)

Finally, adding permission to mic:
INSERT INTO access VALUES('kTCCServiceMicrophone','org.processing.app',0,1,1,NULL,NULL,NULL,'UNUSED',NULL,0,1578356911);"

To leave the sqlite3, just give the command .quit.

Step 3: Cleanup
Reboot your Mac and hold Cmd+R on startup. This will bring up the Recovery Mode.
Open Utility -> Terminal from the menu bar and type csrutil enable
Reboot.

IMPORTANT: Before trying this steps, I had already changed the Plist from processing and jre pluggin in the processing content as described in #51 .

Thanks again everybody, I hope that helps you somehow (and specially don't crash any SO)!

@hedbergj
Copy link

hedbergj commented Mar 3, 2020

nice @dantfv ! Glad it worked.

@gomako
Copy link

gomako commented May 13, 2020

In case anyone is looking for another way to get around this, I tried the solution in this comment and it worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants