# HG changeset patch # User cannam # Date 1213969335 0 # Node ID 3d19286703296032e27aa12daac402597d5409bd # Parent 635e8745ccc932e486333b3561bb436ae1492134 * Commit Dan's patch for threshold parameter diff -r 635e8745ccc9 -r 3d1928670329 onsetsdsplugin.cpp --- a/onsetsdsplugin.cpp Thu Jun 19 12:30:15 2008 +0000 +++ b/onsetsdsplugin.cpp Fri Jun 20 13:42:15 2008 +0000 @@ -35,9 +35,10 @@ m_ods(0), m_odsdata(0), m_dfType(ODS_ODF_RCOMPLEX), + m_threshold(0.5), m_medspan(11), - m_stepSize(512), - m_fftSize(1024) + m_stepSize(256), + m_fftSize(512) { } @@ -106,6 +107,16 @@ desc.valueNames.push_back("Modified Kullback-Liebler deviation"); list.push_back(desc); + desc.identifier = "threshold"; + desc.name = "Detection threshold"; + desc.description = "Onsets trigger when the function beats this value"; + desc.minValue = 0; + desc.maxValue = 1; + desc.defaultValue = 0.5; + desc.isQuantized = false; + desc.valueNames.clear(); + list.push_back(desc); + desc.identifier = "medspan"; desc.name = "Median frame span"; desc.description = "Number of past frames used in median calculation"; @@ -133,6 +144,8 @@ case ODS_ODF_WPHASE: return 5; case ODS_ODF_MKL: return 6; } + } else if (name == "threshold") { + return m_threshold; } else if (name == "medspan") { return m_medspan; } @@ -155,6 +168,8 @@ } if (dfType == m_dfType) return; m_dfType = dfType; + } else if (name == "threshold") { + m_threshold = value; } else if (name == "medspan") { m_medspan = lrintf(value); } @@ -191,7 +206,8 @@ memset(m_ods, 0, sizeof(OnsetsDS)); onsetsds_init(m_ods, m_odsdata, ODS_FFT_FFTW3_R2C, m_dfType, m_fftSize, m_medspan, m_inputSampleRate); - + m_ods->thresh = m_threshold; + return true; } @@ -209,13 +225,13 @@ size_t OnsetsDSPlugin::getPreferredStepSize() const { - return 512; + return 256; } size_t OnsetsDSPlugin::getPreferredBlockSize() const { - return 1024; + return 512; } OnsetsDSPlugin::OutputList diff -r 635e8745ccc9 -r 3d1928670329 onsetsdsplugin.h --- a/onsetsdsplugin.h Thu Jun 19 12:30:15 2008 +0000 +++ b/onsetsdsplugin.h Fri Jun 20 13:42:15 2008 +0000 @@ -64,6 +64,7 @@ OnsetsDS *m_ods; float *m_odsdata; onsetsds_odf_types m_dfType; + float m_threshold; size_t m_medspan; size_t m_stepSize; size_t m_fftSize;