Mercurial > hg > sonic-visualiser
diff transform/FeatureExtractionPluginTransform.cpp @ 134:7a5ba9dadbf7
* Fix #1706927 NaNs from plugin outputs should not be used
author | Chris Cannam |
---|---|
date | Fri, 27 Apr 2007 15:39:48 +0000 |
parents | b4110b17bca8 |
children | 006c90387f40 |
line wrap: on
line diff
--- a/transform/FeatureExtractionPluginTransform.cpp Fri Apr 27 14:37:48 2007 +0000 +++ b/transform/FeatureExtractionPluginTransform.cpp Fri Apr 27 15:39:48 2007 +0000 @@ -123,6 +123,7 @@ int binCount = 1; float minValue = 0.0, maxValue = 0.0; + bool haveExtents = false; if (m_descriptor->hasFixedBinCount) { binCount = m_descriptor->binCount; @@ -134,6 +135,7 @@ if (binCount > 0 && m_descriptor->hasKnownExtents) { minValue = m_descriptor->minValue; maxValue = m_descriptor->maxValue; + haveExtents = true; } size_t modelRate = m_input->getSampleRate(); @@ -163,8 +165,14 @@ } else if (binCount == 1) { - SparseTimeValueModel *model = new SparseTimeValueModel - (modelRate, modelResolution, minValue, maxValue, false); + SparseTimeValueModel *model; + if (haveExtents) { + model = new SparseTimeValueModel + (modelRate, modelResolution, minValue, maxValue, false); + } else { + model = new SparseTimeValueModel + (modelRate, modelResolution, false); + } model->setScaleUnits(outputs[m_outputFeatureNo].unit.c_str()); m_output = model; @@ -180,15 +188,22 @@ // yet store velocity.) //!!! todo: ask the user! - NoteModel *model = new NoteModel - (modelRate, modelResolution, minValue, maxValue, false); + NoteModel *model; + if (haveExtents) { + model = new NoteModel + (modelRate, modelResolution, minValue, maxValue, false); + } else { + model = new NoteModel + (modelRate, modelResolution, false); + } model->setScaleUnits(outputs[m_outputFeatureNo].unit.c_str()); m_output = model; } else { - - m_output = new EditableDenseThreeDimensionalModel + + EditableDenseThreeDimensionalModel *model = + new EditableDenseThreeDimensionalModel (modelRate, modelResolution, binCount, false); if (!m_descriptor->binNames.empty()) { @@ -196,9 +211,10 @@ for (size_t i = 0; i < m_descriptor->binNames.size(); ++i) { names.push_back(m_descriptor->binNames[i].c_str()); } - (dynamic_cast<EditableDenseThreeDimensionalModel *>(m_output)) - ->setBinNames(names); + model->setBinNames(names); } + + m_output = model; } }