In the AudioThumbnailTutorial_04.h line 307 there’s a AudioFormatReaderSource (variablename: newSource) created.
In the next line newSource is transformed (perhaps the wrong word?) to a PositionableAudioSource using a .get() method. How does this work? I don’t understand what’s happening there. What’s the purpose of get() and why can I not find it in the Juce reference?
I found there’s a std::get but I’m not sure I get the relation and functionality here.
Also, since newSource, reader and file goes out of scope when launchAsync is finished where’s the actual audiosample data stored/referenced for the remainder of the session?
chooser->launchAsync (chooserFlags, [this] (const FileChooser& fc)
{
auto file = fc.getResult();
if (file != File{})
{
auto* reader = formatManager.createReaderFor (file);
if (reader != nullptr)
{
auto newSource = std::make_unique<juce::AudioFormatReaderSource> (reader, true);
transportSource.setSource (newSource.get(), 0, nullptr, reader->sampleRate);
playButton.setEnabled (true);
thumbnailComp.setFile (file);
readerSource.reset (newSource.release());
}
}
});
