Easiest sampler from tutorial doesn't work, why?

Hi All,

I am following this tutorial Build a Sampler VST Plug-in with JUCE Part 1 - Loading and Playing on YT.

The project builds, but does not work (no sound).
The only difference between tutorial and my code is, that I do not choose the file like this:

But I have it predefined at this location:

Still, unlike in tutorial, I have no sound.

My processBlock and prepareToPlay are like in the tutorial:

That’s it.
All needed entries to header files are done, in the Projucer settings the PluginCharacteristics → Plugin is a Synth and PlugIn MIDI Input are ticked.

TheAudioProgrammer chooses the .wav from the explorer that pops up, I pre-defined it.

How to solve this?

Ask this question: What is going to happen in that code if mFormatReader does, in fact, have nullptr value? (Hint: you shouldnt be using it at all, if it has nullptr value - yet, you do allow it to be used in this code…)

Have you set a breakpoint to see that for sure, your assumptions about mFormatReader are correct?

The big ‘smell’ in your code is the strange juce::File path-name, which can be a cause of a headache - if you’ve got a case-sensitive filesystem, if you’ve got / and \ directory separators mixed up, and so on.

But it should be easy for you to find out whats going on - set a breakpoint on the addSound call, and inspect the mFormatReader. Is it really as robust as you think it is?

Hi ibisum, thanks for your hints, mFormatReader is intialized with a nullprt, but is not anymore after
mFormatReader.createReaderFor(input);
After entering the if statement in my loadFile() func, the juce::AudioFormatReader::read returns true.

UPDATE: same very code works for my collegue, he has to hit a c3 note before hitting Load button, due to 60 in the mSampler.addSound() and then the audio is played.
Interesringly, in the tutorial there was no need to hit C3 first, but different plugin host was used, not a Juce one.

I am working on how to skip that hit-note (AND PRESS) step in JUCE plugin host and play audio just when Load button is pressed - > with MidiMessage class, possibly. Beyond this, seems like code is fine.