SamplerSound sample rate - EXC_BAD_ACCESS

Hello Everyone,

First post here, apologies in advance if this is very basic.

Im trying to make a sampler synthesiser using JUCE and am running into a run time error - JUCE Message Thread (1): EXC_BAD_ACCESS (code=1, address=0x8) pointing to the following line from the juce_Sampler.cpp file -

I can’t quite seem to find out what it is that I’m not doing(or doing incorrectly).

I’m following the AudioSynthesiserDemo from the DemoRunner and the ‘Build a MIDI Synthesiser’ tutorial to try and combine bits of code from the two to arrive at a sampler instrument that I can then use in my sampler audio application. I’m also using this sampler tutorial for reference.

I’ve put my SynthAudioSource class on an online text editor for reference - https://onlinegdb.com/HJQ9W72pH

In my MainContentComponent class (inheriting from AudioAppComponent) I’m calling the setUsingSampledSound() method which throws this error. However, setUsingSineWaveSound() results in a working sine wave synthesiser.

I know that I’m using a ScopedPointer which is now deprecated, however I believe this is not the cause of the error. From my little knowledge of C++, I understand that the error message means that I’m trying to access something that is not valid.

I would appreciate any advice on solving this issue.

Thanks !

Whenever I have this occur, it’s because i’m running the Audio Plugin Host, and it was compiled with a different version of JUCE compared to the version of juce my plugin is running. like, the APH was built with v5.4.3, and my plugin was built with v5.4.5. The solution has always been to rebuild APH with the same version of JUCE that my plugin was built with. I don’t know if that’ll help you at all, but this error for me was always caused by the different versions of juce being used.

Thanks for your reply @matkatmusic!

I’m building a standalone audio application. The APH I believe is for audio plugins, right?

You are not checking if this succeeds :

File* file = new File("../VeryHeavy1.wav");
ScopedPointer<AudioFormatReader> reader = audioFormatManager.createReaderFor(*file);

And I bet it fails because you are trying to use that relative path for the .wav file. It likely isn’t pointing to a location you expect. (Also as a sidenote, there is no reason to use File via a pointer and allocation by “new”.)

1 Like

Hi @Xenakios

Thanks a ton for those tips. Yep, managed to make it work finally using absolute file paths.

Cheers