createFileWave returns a boolean
This commit is contained in:
parent
f71e0b4f21
commit
fbf2785211
3 changed files with 8 additions and 9 deletions
|
|
@ -367,8 +367,7 @@ bool sfz::Synth::loadSfzFile(const fs::path& file)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto fileWave = resources.wavePool.createFileWave(resources.filePool, region->sample);
|
if (!resources.wavePool.createFileWave(resources.filePool, region->sample)) {
|
||||||
if (!fileWave) {
|
|
||||||
removeCurrentRegion();
|
removeCurrentRegion();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -352,14 +352,14 @@ void WavetablePool::clearFileWaves()
|
||||||
_fileWaves.clear();
|
_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))
|
if (_fileWaves.contains(filename))
|
||||||
return wave;
|
return true;
|
||||||
|
|
||||||
auto fileHandle = filePool.loadFile(filename);
|
auto fileHandle = filePool.loadFile(filename);
|
||||||
if (!fileHandle)
|
if (!fileHandle)
|
||||||
return nullptr;
|
return false;
|
||||||
|
|
||||||
if (fileHandle->information.numChannels > 1)
|
if (fileHandle->information.numChannels > 1)
|
||||||
DBG("[sfizz] Only the first channel of " << filename << " will be used to create the wavetable");
|
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));
|
WavetableMulti::createForHarmonicProfile(hp, 1.0));
|
||||||
|
|
||||||
_fileWaves[filename] = wave;
|
_fileWaves[filename] = wave;
|
||||||
return wave.get();
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace sfz
|
} // namespace sfz
|
||||||
|
|
|
||||||
|
|
@ -208,9 +208,9 @@ struct WavetablePool {
|
||||||
*
|
*
|
||||||
* @param filePool the file pool to use to load the file
|
* @param filePool the file pool to use to load the file
|
||||||
* @param filename the file name to load
|
* @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.
|
* @brief Removes all the stored file waves from the wavetable pool.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue