createFileWave returns a boolean

This commit is contained in:
Paul Ferrand 2020-03-28 21:03:03 +01:00
parent f71e0b4f21
commit fbf2785211
3 changed files with 8 additions and 9 deletions

View file

@ -367,8 +367,7 @@ bool sfz::Synth::loadSfzFile(const fs::path& file)
continue;
}
const auto fileWave = resources.wavePool.createFileWave(resources.filePool, region->sample);
if (!fileWave) {
if (!resources.wavePool.createFileWave(resources.filePool, region->sample)) {
removeCurrentRegion();
continue;
}

View file

@ -352,14 +352,14 @@ void WavetablePool::clearFileWaves()
_fileWaves.clear();
}
const WavetableMulti* WavetablePool::createFileWave(FilePool& filePool, const std::string& filename)
bool WavetablePool::createFileWave(FilePool& filePool, const std::string& filename)
{
if (const WavetableMulti* wave = getFileWave(filename))
return wave;
if (_fileWaves.contains(filename))
return true;
auto fileHandle = filePool.loadFile(filename);
if (!fileHandle)
return nullptr;
return false;
if (fileHandle->information.numChannels > 1)
DBG("[sfizz] Only the first channel of " << filename << " will be used to create the wavetable");
@ -391,7 +391,7 @@ const WavetableMulti* WavetablePool::createFileWave(FilePool& filePool, const st
WavetableMulti::createForHarmonicProfile(hp, 1.0));
_fileWaves[filename] = wave;
return wave.get();
return true;
}
} // namespace sfz

View file

@ -208,9 +208,9 @@ struct WavetablePool {
*
* @param filePool the file pool to use to load the file
* @param filename the file name to load
* @return the wavetable
* @return true if the wavetable was correctly created (or existed already)
*/
const WavetableMulti* createFileWave(FilePool& filePool, const std::string& filename);
bool createFileWave(FilePool& filePool, const std::string& filename);
/**
* @brief Removes all the stored file waves from the wavetable pool.
*/