JUCE Assertion failure in juce_AudioFormatManager.cpp:124

I am following theAudioProgrammer’s simple file player tutorial on youtube. I am able to open the application and run the modal to select a file. When I select a file however, it triggers a breakpoint. I am very new to juce and file managment in general. Any suggestions on why this error might be happening would be much appreciated. I am using visual studio 2022 and am on windows 11.

Below is the code that is executing

void MainComponent::openButtonClick() {
//dbg wries to output log. Bassicly cout.
DBG(“Clicked”);

//choose a file
juce::FileChooser chooser("Choose a wav or AIFF file", juce::File::getSpecialLocation(juce::File::userDesktopDirectory), "*.wav");

//if the user chooses a file
if (chooser.browseForFileToOpen()) {
    juce::File myFile;

    //what did the user choose?
    myFile = chooser.getResult(); 

    //read the file 
    juce::AudioFormatReader* reader = formatManager.createReaderFor(myFile);

    //get the file ready to play
    std::unique_ptr<juce::AudioFormatReaderSource> tempSource(new juce::AudioFormatReaderSource(reader, true));

    //playSource.reset(tempSource.release());

    DBG(reader->getFormatName());
}

}

Fixed! I forgot to call registerBasicFormats() on my AudioFormatManager haha. Hope this helps anyone else who may have missed that.

1 Like

thank you for that :pray:

i wasted hours on that one