What to do in an AudioProcessor if you switch the device?

Hi there!

I have a problem i did not find the right documentation right now: When i switch the device i get a chattering sound. I found out, that when i remove my Code from my Processors processBlock() function, the problem disappears (Testtone runs fine), so there must be something wrong with my Processor or with the connections to it. I am new to Juce, so i think i don’t know about something i would have cared about.

I’ll just give you a little more information:

The processBlock-function:

void BasicAudioProcessor::processBlock(AudioBuffer &buffer, MidiBuffer &midiMessages)
{
for(int channel = 0; channel < buffer.getNumChannels(); channel++) {
for(int sample = 0; sample < buffer.getNumSamples(); sample++) {
buffer.setSample(channel, sample, (random.nextFloat() * 0.25f - 0.125f + buffer.getSample(channel, sample)));
}
}
}

My Callstack looks normal for Juce, i think:
I create an AudioDeviceManager, that adds an Audio Callback with an AudioProcessorPlayer and this processes the AudioProcessorGraph, to which i will add more than the BasicAudioProcessor later.

One thing, that is not important i think, but could be: I am not calling the AudioDeviceSelectorComponent from the same class, that contains the AudioDeviceManager, but from a friend class. But as everything works fine, when the processBlock()-Method is empty, i don’t think, that matters.

Thanks for help in advance!

Perhaps some handling missing in the prepareToPlay method?

1 Like

Oh, thanks, you seem to be right. I have some other issues now, but i think i can solve them myself. :slight_smile:

Okay, now i have an issue that is even stranger: I added the setPlayConfigDetails function in the prepareToPlay-Method. Right afterwards I run into another bug - the app runs fine, and i can hear the test tone after switching the device, but no Noise anymore. I also get the Output “HALSystem.cpp:1679:AudioObjectPropertiesChanged: AudioObjectPropertiesChanged: no such object” (Audio HAL is part of Core-Audio).

So, i think, the function i added to setPlayConfigDetails() tries to call an Audio Device the wrong way (?) Anyone any idea why this is so?

Hi there!

I still have the same problem. If anyone would help, i really would appreciate that. Thanks in advance!

I just want to explain shortly, what the idea was: I wanted to implement the smallest Version of an AudioCallback, using an AudioProcessor. So, now i just made a new app, which only contains the code, concerning the Audio-Workflow. The problem remains the same (there is no more noise, generated by the AudioProcessor after changing the device and it says “2018-04-13 12:37:34.616063+0200 Audio Test App[3227:101895] [AudioHAL_Client] HALSystem.cpp:1679:AudioObjectPropertiesChanged: AudioObjectPropertiesChanged: no such object”). It’s probably something really silly, but i just was not able to find anything.

MyAudioProcessor.h (1.3 KB)
MainComponent.h (1.7 KB)
MyAudioProcessor.cpp (1.9 KB)
MainComponent.cpp (2.6 KB)
Main.cpp (4.0 KB)

One thing would be to test in release mode as well. There are a lot of assertions that will be checked when switching the device, and the debugger can stall the audio thread (when I have netflix or a radio stream while testing, sometimes it even stalls the audio of other programs when using breakpoints). Chances are that running in release mode it becomes an almost inaudible glitch…

Good luck

(N.B. haven’t looked at your code)

1 Like

Hey Daniel!

Thanks for your answer. I just made a release build and nothing changes, i still seem to have the same problem.