Mercurial > hg > svapp
changeset 649:284cb118368e single-point
Further updates for new API - but we still need some more support in the API itself
author | Chris Cannam |
---|---|
date | Tue, 19 Mar 2019 13:06:58 +0000 |
parents | eec0c50bb44f |
children | ed9cb577eb7c |
files | audio/AudioGenerator.cpp framework/Align.cpp framework/MainWindowBase.cpp framework/SVFileReader.cpp |
diffstat | 4 files changed, 43 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/audio/AudioGenerator.cpp Fri Mar 15 14:24:46 2019 +0000 +++ b/audio/AudioGenerator.cpp Tue Mar 19 13:06:58 2019 +0000 @@ -712,36 +712,31 @@ bufferIndexes[c] = buffer[c] + i * m_processingBlockSize; } - SparseTimeValueModel::PointList points = - stvm->getPoints(reqStart, reqStart + m_processingBlockSize); + EventVector points = + stvm->getEventsStartingWithin(reqStart, m_processingBlockSize); // by default, repeat last frequency float f0 = 0.f; - // go straight to the last freq that is genuinely in this range - for (SparseTimeValueModel::PointList::const_iterator itr = points.end(); - itr != points.begin(); ) { - --itr; - if (itr->frame >= reqStart && - itr->frame < reqStart + m_processingBlockSize) { - f0 = itr->value; - break; - } + // go straight to the last freq in this range + if (!points.empty()) { + f0 = points.rbegin()->getValue(); } - // if we found no such frequency and the next point is further + // if there is no such frequency and the next point is further // away than twice the model resolution, go silent (same // criterion TimeValueLayer uses for ending a discrete curve // segment) + /*!!! todo: restore if (f0 == 0.f) { - SparseTimeValueModel::PointList nextPoints = + EventVector nextPoints = stvm->getNextPoints(reqStart + m_processingBlockSize); if (nextPoints.empty() || nextPoints.begin()->frame > reqStart + 2 * stvm->getResolution()) { f0 = -1.f; } } - + */ // cerr << "f0 = " << f0 << endl; synth->mix(bufferIndexes,
--- a/framework/Align.cpp Fri Mar 15 14:24:46 2019 +0000 +++ b/framework/Align.cpp Tue Mar 19 13:06:58 2019 +0000 @@ -136,7 +136,7 @@ (transformOutput); if (!path) { - cerr << "Align::alignModel: ERROR: Failed to create alignment path (no MATCH plugin?)" << endl; + SVCERR << "Align::alignModel: ERROR: Failed to create alignment path (no MATCH plugin?)" << endl; delete transformOutput; delete aggregateModel; m_error = message; @@ -189,7 +189,7 @@ ReadOnlyWaveFileModel *roref = qobject_cast<ReadOnlyWaveFileModel *>(reference); ReadOnlyWaveFileModel *rorm = qobject_cast<ReadOnlyWaveFileModel *>(rm); if (!roref || !rorm) { - cerr << "ERROR: Align::alignModelViaProgram: Can't align non-read-only models via program (no local filename available)" << endl; + SVCERR << "ERROR: Align::alignModelViaProgram: Can't align non-read-only models via program (no local filename available)" << endl; return false; } @@ -219,8 +219,8 @@ bool success = process->waitForStarted(); if (!success) { - cerr << "ERROR: Align::alignModelViaProgram: Program did not start" - << endl; + SVCERR << "ERROR: Align::alignModelViaProgram: Program did not start" + << endl; m_error = "Alignment program could not be started"; m_processModels.erase(process); rm->setAlignment(nullptr); // deletes alignmentModel as well @@ -233,13 +233,13 @@ void Align::alignmentProgramFinished(int exitCode, QProcess::ExitStatus status) { - cerr << "Align::alignmentProgramFinished" << endl; + SVCERR << "Align::alignmentProgramFinished" << endl; QProcess *process = qobject_cast<QProcess *>(sender()); if (m_processModels.find(process) == m_processModels.end()) { - cerr << "ERROR: Align::alignmentProgramFinished: Process " << process - << " not found in process model map!" << endl; + SVCERR << "ERROR: Align::alignmentProgramFinished: Process " << process + << " not found in process model map!" << endl; return; } @@ -265,8 +265,8 @@ CSVFileReader reader(process, format, alignmentModel->getSampleRate()); if (!reader.isOK()) { - cerr << "ERROR: Align::alignmentProgramFinished: Failed to parse output" - << endl; + SVCERR << "ERROR: Align::alignmentProgramFinished: Failed to parse output" + << endl; m_error = QString("Failed to parse output of program: %1") .arg(reader.getError()); goto done; @@ -276,30 +276,30 @@ SparseTimeValueModel *path = qobject_cast<SparseTimeValueModel *>(csvOutput); if (!path) { - cerr << "ERROR: Align::alignmentProgramFinished: Output did not convert to sparse time-value model" - << endl; + SVCERR << "ERROR: Align::alignmentProgramFinished: Output did not convert to sparse time-value model" + << endl; m_error = QString("Output of program did not produce sparse time-value model"); goto done; } - if (path->getPoints().empty()) { - cerr << "ERROR: Align::alignmentProgramFinished: Output contained no mappings" - << endl; + if (path->isEmpty()) { + SVCERR << "ERROR: Align::alignmentProgramFinished: Output contained no mappings" + << endl; m_error = QString("Output of alignment program contained no mappings"); goto done; } - - cerr << "Align::alignmentProgramFinished: Setting alignment path (" - << path->getPoints().size() << " point(s))" << endl; - +/* + SVCERR << "Align::alignmentProgramFinished: Setting alignment path (" + << path->getAllEvents().size() << " point(s))" << endl; +*/ alignmentModel->setPathFrom(path); emit alignmentComplete(alignmentModel); } else { - cerr << "ERROR: Align::alignmentProgramFinished: Aligner program " - << "failed: exit code " << exitCode << ", status " << status - << endl; + SVCERR << "ERROR: Align::alignmentProgramFinished: Aligner program " + << "failed: exit code " << exitCode << ", status " << status + << endl; m_error = "Aligner process returned non-zero exit status"; }
--- a/framework/MainWindowBase.cpp Fri Mar 15 14:24:46 2019 +0000 +++ b/framework/MainWindowBase.cpp Tue Mar 19 13:06:58 2019 +0000 @@ -1162,14 +1162,14 @@ m_labeller->setSampleRate(sodm->getSampleRate()); - if (m_labeller->actingOnPrevPoint() && havePrevPoint) { + if (m_labeller->actingOnPrevEvent() && havePrevPoint) { command->deletePoint(prevPoint); } - +/*!!! to be updated after we have switched SODM to new API m_labeller->label<SparseOneDimensionalModel::Point> (point, havePrevPoint ? &prevPoint : nullptr); - - if (m_labeller->actingOnPrevPoint() && havePrevPoint) { +*/ + if (m_labeller->actingOnPrevEvent() && havePrevPoint) { command->addPoint(prevPoint); } } @@ -1282,9 +1282,10 @@ Labeller labeller(*m_labeller); labeller.setSampleRate(sodm->getSampleRate()); - +/*!!! to be updated after SODM API update Command *c = labeller.labelAll<SparseOneDimensionalModel::Point>(*sodm, &ms); if (c) CommandHistory::getInstance()->addCommand(c, false); +*/ } void @@ -1308,9 +1309,12 @@ Labeller labeller(*m_labeller); labeller.setSampleRate(sodm->getSampleRate()); + (void)n; +/*!!! to be updated after SODM API update Command *c = labeller.subdivide<SparseOneDimensionalModel::Point> (*sodm, &ms, n); if (c) CommandHistory::getInstance()->addCommand(c, false); +*/ } void @@ -1334,9 +1338,12 @@ Labeller labeller(*m_labeller); labeller.setSampleRate(sodm->getSampleRate()); + (void)n; +/*!!! to be updated after SODM API update Command *c = labeller.winnow<SparseOneDimensionalModel::Point> (*sodm, &ms, n); if (c) CommandHistory::getInstance()->addCommand(c, false); +*/ } MainWindowBase::FileOpenStatus
--- a/framework/SVFileReader.cpp Fri Mar 15 14:24:46 2019 +0000 +++ b/framework/SVFileReader.cpp Tue Mar 19 13:06:58 2019 +0000 @@ -1098,7 +1098,7 @@ float value = 0.0; value = attributes.value("value").trimmed().toFloat(&ok); QString label = attributes.value("label"); - stvm->addPoint(SparseTimeValueModel::Point(frame, value, label)); + stvm->add(Event(frame, value, label)); return ok; }