Load equal temperament if scl loading fails

This commit is contained in:
Jean Pierre Cimalando 2021-02-23 20:02:11 +01:00
parent 6dbdd1bb14
commit 45bab7289f

View file

@ -162,50 +162,59 @@ Tuning::~Tuning()
bool Tuning::loadScalaFile(const fs::path& path)
{
Tunings::Scale scl;
fs::ifstream stream(path);
if (stream.bad()) {
DBG("Cannot open scale file: " << path);
return false;
goto failure;
}
Tunings::Scale scl;
try {
scl = Tunings::readSCLStream(stream);
}
catch (Tunings::TuningError& error) {
DBG("Tuning: " << error.what());
return false;
goto failure;
}
if (scl.count <= 0) {
DBG("The scale file is empty: " << path);
return false;
goto failure;
}
impl_->updateScale(scl, path);
return true;
failure:
loadEqualTemperamentScale();
return false;
}
bool Tuning::loadScalaString(const std::string& text)
{
Tunings::Scale scl;
std::istringstream stream(text);
Tunings::Scale scl;
try {
scl = Tunings::readSCLStream(stream);
}
catch (Tunings::TuningError& error) {
DBG("Tuning: " << error.what());
return false;
goto failure;
}
if (scl.count <= 0) {
DBG("Error loading scala string: " << text);
return false;
goto failure;
}
impl_->updateScale(scl);
return true;
failure:
loadEqualTemperamentScale();
return false;
}
void Tuning::setScalaRootKey(int rootKey)