audioDeviceIOCallbackInt - input is always silent

Hello,
I am on macbook pro with Apple Silicon M1.

I initialised everything as follows:

String devInfo = deviceManager.initialise(1, 0, nullptr, true);
deviceManager.addAudioCallback(myAudioIODeviceCallback);

And in audioDeviceAboutToStart() defined in my myAudioIODeviceCallback I set:

void audioDeviceAboutToStart(juce::AudioIODevice* device)
{
        DBG("Current input device: " << device->getName());
        DBG("Number of input channels: " << device->getInputChannelNames().size());
        
        DBG("is opened: " + String(device->isOpen() ? "YES" : "NO"));
        DBG("is playing: " + String(device->isPlaying() ? "YES" : "NO"));
        DBG("active channels: " + String(device->getActiveInputChannels().toInt64()));
}

And I get here in console printed:

Current input device: MacBook Pro Microphone
Number of input channels: 1
is opened: YES
is playing: YES
active channels: 1

And I checked in my “MacOs → System Settings → Sound → Input” and there is input volume set to maximum and on the meter I see there is signal.

But in my audioDeviceIOCallbackWithContext input has all values equal zero.

Please help. What is going wrong here?

For any help great thanks in advance.

You need to handle the audio input device permissions.

Thanks @xenakios for your answer.
I’ve heard about that. But I have no idea how to do that.

There is juce::RuntimePermissions but in documentation there is said that it works only for Android.
So juce::RuntimePermissions::request() and other methods do nothing. And juce::RuntimePermissions::isGranted() always return true;

I am not familiar with this. But the following four lines works for my standalone which wants microphone input:

juce_add_plugin(// something here
        MICROPHONE_PERMISSION_ENABLED TRUE
        MICROPHONE_PERMISSION_TEXT "something here"
        HARDENED_RUNTIME_ENABLED TRUE
        HARDENED_RUNTIME_OPTIONS com.apple.security.device.audio-input)

Thanks, but I can’t find juce_add_plugin() anywhere. Even in JUCE documenntation

That would be a thing to add in your Cmake CmakeLists.txt file, not in your C++ code. If you are not using Cmake, there is an option in the Projucer too :

1 Like

Woooooow… !!! @xenakios THANKS THANKS THANKS!

I spent on it today about 4 hours. :joy:

I have a similar issue to the OP, I have added the above parameters to my CMakeLists.txt, but I still get no audio input if I build a universal binary. If I delete the arm64 target then my x86 binary works perfectly (on my Intel Mac), but as soon as I specify “arm64;x86_64” I get no audio at all.
Using projucer is not an option for me, as it can’t create a cmake file.
I don’t think the problem is related to enabling the microphone, as it is definitely enabled already. Are there any more cmake settings that matter for audio input?