which gives the following error when compiling : unimplemented pure virtual method ‘readSamples’ in ‘AudioFormatReader’
virtual bool readSamples (int** destChannels…)
What is the recommended way then to use AudioFormatReader* object returned by createReaderFor method ?
The createReaderFor returns a raw pointer already, so you cannot use make_unique (as you found out).
Option one is to use .reset (reader) to let the unique_ptr point to the new generated object (I don’t like that), or you create the unique_ptr with the raw pointer as argument:
std::unique_ptr<AudioFormatReader> formatReader (fFormatManager.createReaderFor (File (path_name)));
// or for almost always auto fans:
auto formatReader = std::unique_ptr<AudioFormatReader>(fFormatManager.createReaderFor (File (path_name)));