JUCE Assertion failure in juce_AudioSampleBuffer.cpp:150

Hi All,

 I am a beginner, and I am having a hard time using JUCE. In short, I am still waiting for the fruit to ripen. I want to process the input data real time and do pitch tracking. So, for beginners, I started exploring on how to input audio and record it. I dug into the AudioRecordingDemo.cpp from the JUCE Demo, and all I want to write is a simple button that says record to record without any visualization whatsoever. This is the code 


 After spending hours on debugging the compile and link-time errors, now I am getting a JUCE assertion error, that says

 "JUCE Assertion failure in juce_AudioSampleBuffer.cpp:150"

 I have come to the conclusion that my understanding is flawed somewhere, but any lead to this problem would be very helpful. Thank you so much. 

If you actually go and look at that line of code, it has a comment explaining what you're doing wrong!

Yes Jules, it tells me to  " pass in the same number of valid pointers as numChannels "  And yet I don't see where I am going wrong. From my perspective, I am clueless as to where exactly I am doing the mistake of passing mismatched no. of pointers. 

It's telling you that the number of channels is wrong, so go and look at the code you wrote that generates that number. Hint: your code is passing in uninitialised garbage to the function. I'm actually surprised the compiler didn't give you at least a warning about it.

I still don't get how one must initialize an object of the AudioDeviceManager class. This is what i have:


    MainContentComponent(): deviceManager (getSharedAudioDeviceManager())




    AudioDeviceManager& getSharedAudioDeviceManager()


        if (sharedAudioDeviceManager == nullptr)


            sharedAudioDeviceManager = new AudioDeviceManager();

            sharedAudioDeviceManager->initialise (1, 2, 0, true, String::empty, 0);



        return *sharedAudioDeviceManager;



Forgive me, i could be blunt. Am I in the first place initializing the AudioDeviceManager object correctly? 

It would be good to know at which line in your above code the assertion occurs. Can you look at the call stack when you hit the assertion?

When you look at how you initiate the buffer:

const AudioSampleBuffer buffer (const_cast<float**> (inputChannelData), buffer.getNumChannels(), numSamples); 
//thumbnail.addBlock (nextSampleNum, buffer, 0, numSamples); 

You set the number of channels to the number of channels of the buffer you are just creating, which is of course not known at that moment. Use numOutputChannels instead. Or since you don't use the buffer at all right now, you might as well delete that line altogether.