Juce_AudioAppComponent clarification question

Hey all,

I’m aware this is probably a noob question to ask. However, I’m working on an audio app that takes in audio from a sound file given by the user and then processes it based on parameters set by the user etc.

The Problem
My code follows pretty closely to the “Build an audio player” tutorial in regards to the application component that handles the audio. However, when I have setAudioChannels(2, 2) I get the assert error in the juce_AudioAppComponent

void AudioAppComponent::setAudioChannels (int numInputChannels, int numOutputChannels, const XmlElement* const xml)
    String audioError = deviceManager.initialise (numInputChannels, numOutputChannels, xml, true);
    jassert (audioError.isEmpty());

I get the idea from the code that when the app is initialized, there is no audio present and then the assert error is thrown.

I’m sure this is incompetence on my end, but some help would be really appreciated.

The program works fine minus playing audio when I have setAudioChannels(0, 2). So that is where my guess is coming from. I’m not sure if I should automatically be playing something upon initialization etc.

I guess your audio hardware doesn’t support any input channels, at least with the defaults Juce’s AudioDeviceManager uses.

1 Like

Thanks, I appreciate the help. I’ll look into that.

Have you looked in the debugger what is the error text from AudioDeviceManager when the assert is hit?

It states the input/output devices don’t share the same sample rate. I’m trying to figure out where I set those parameters. I thought they default to 44.1k.

I appreciate you pointing that out. My speakers were set to 48k and my microphone was set to 44.1k. Its taking in the audio now but it isn’t reproducing well – so back to work!

You might investigate which audio device is being opened. be it some built-in device or some 3rd party device. For example, your system might be set to use an RME or MOTU device as the audio input, but you might be using the built-in speakers as the output instead of the RME or MOTU interface. so, JUCE is gonna use those devices as the ‘default’ device. If that’s the situation, then you’ll have separate clocks controlling the sample rate for each device. However, if you have 1 device being used for input and output, that won’t be the case.

Take a look at the JUCE demo project, particularly the Audio Settings demo and how you can choose which input/output device is selected, how it’s sample rate is changed, etc…