cannam@198: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ cannam@198: cannam@198: /* cannam@198: Vamp cannam@198: cannam@198: An API for audio analysis and feature extraction plugins. cannam@198: cannam@198: Centre for Digital Music, Queen Mary, University of London. cannam@290: Copyright 2006-2009 Chris Cannam and QMUL. cannam@198: cannam@198: Permission is hereby granted, free of charge, to any person cannam@198: obtaining a copy of this software and associated documentation cannam@198: files (the "Software"), to deal in the Software without cannam@198: restriction, including without limitation the rights to use, copy, cannam@198: modify, merge, publish, distribute, sublicense, and/or sell copies cannam@198: of the Software, and to permit persons to whom the Software is cannam@198: furnished to do so, subject to the following conditions: cannam@198: cannam@198: The above copyright notice and this permission notice shall be cannam@198: included in all copies or substantial portions of the Software. cannam@198: cannam@198: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, cannam@198: EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF cannam@198: MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND cannam@198: NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR cannam@198: ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF cannam@198: CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION cannam@198: WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. cannam@198: cannam@198: Except as contained in this notice, the names of the Centre for cannam@198: Digital Music; Queen Mary, University of London; and Chris Cannam cannam@198: shall not be used in advertising or otherwise to promote the sale, cannam@198: use or other dealings in this Software without prior written cannam@198: authorization. cannam@198: */ cannam@198: cannam@198: #include "FixedTempoEstimator.h" cannam@198: cannam@198: using std::string; cannam@198: using std::vector; cannam@198: using std::cerr; cannam@198: using std::endl; cannam@198: cannam@198: using Vamp::RealTime; cannam@198: cannam@198: #include cannam@301: #include cannam@198: cannam@198: cannam@243: class FixedTempoEstimator::D cannam@255: // this class just avoids us having to declare any data members in the header cannam@243: { cannam@243: public: cannam@243: D(float inputSampleRate); cannam@243: ~D(); cannam@243: cannam@243: size_t getPreferredStepSize() const { return 64; } cannam@243: size_t getPreferredBlockSize() const { return 256; } cannam@243: cannam@243: ParameterList getParameterDescriptors() const; cannam@243: float getParameter(string id) const; cannam@243: void setParameter(string id, float value); cannam@243: cannam@243: OutputList getOutputDescriptors() const; cannam@243: cannam@243: bool initialise(size_t channels, size_t stepSize, size_t blockSize); cannam@243: void reset(); cannam@243: FeatureSet process(const float *const *, RealTime); cannam@243: FeatureSet getRemainingFeatures(); cannam@243: cannam@243: private: cannam@243: void calculate(); cannam@243: FeatureSet assembleFeatures(); cannam@243: cannam@243: float lag2tempo(int); cannam@243: int tempo2lag(float); cannam@243: cannam@243: float m_inputSampleRate; cannam@243: size_t m_stepSize; cannam@243: size_t m_blockSize; cannam@243: cannam@243: float m_minbpm; cannam@243: float m_maxbpm; cannam@243: float m_maxdflen; cannam@243: cannam@243: float *m_priorMagnitudes; cannam@243: cannam@243: size_t m_dfsize; cannam@243: float *m_df; cannam@243: float *m_r; cannam@243: float *m_fr; cannam@243: float *m_t; cannam@243: size_t m_n; cannam@243: cannam@243: Vamp::RealTime m_start; cannam@243: Vamp::RealTime m_lasttime; cannam@243: }; cannam@243: cannam@243: FixedTempoEstimator::D::D(float inputSampleRate) : cannam@243: m_inputSampleRate(inputSampleRate), cannam@198: m_stepSize(0), cannam@198: m_blockSize(0), cannam@243: m_minbpm(50), cannam@243: m_maxbpm(190), cannam@243: m_maxdflen(10), cannam@198: m_priorMagnitudes(0), cannam@200: m_df(0), cannam@200: m_r(0), cannam@200: m_fr(0), cannam@204: m_t(0), cannam@200: m_n(0) cannam@198: { cannam@198: } cannam@198: cannam@243: FixedTempoEstimator::D::~D() cannam@198: { cannam@198: delete[] m_priorMagnitudes; cannam@198: delete[] m_df; cannam@200: delete[] m_r; cannam@200: delete[] m_fr; cannam@204: delete[] m_t; cannam@198: } cannam@198: cannam@198: FixedTempoEstimator::ParameterList cannam@243: FixedTempoEstimator::D::getParameterDescriptors() const cannam@198: { cannam@198: ParameterList list; cannam@243: cannam@243: ParameterDescriptor d; cannam@243: d.identifier = "minbpm"; cannam@243: d.name = "Minimum estimated tempo"; cannam@243: d.description = "Minimum beat-per-minute value which the tempo estimator is able to return"; cannam@243: d.unit = "bpm"; cannam@243: d.minValue = 10; cannam@243: d.maxValue = 360; cannam@243: d.defaultValue = 50; cannam@243: d.isQuantized = false; cannam@243: list.push_back(d); cannam@243: cannam@243: d.identifier = "maxbpm"; cannam@243: d.name = "Maximum estimated tempo"; cannam@243: d.description = "Maximum beat-per-minute value which the tempo estimator is able to return"; cannam@243: d.defaultValue = 190; cannam@243: list.push_back(d); cannam@243: cannam@243: d.identifier = "maxdflen"; cannam@243: d.name = "Input duration to study"; cannam@243: d.description = "Length of audio input, in seconds, which should be taken into account when estimating tempo. There is no need to supply the plugin with any further input once this time has elapsed since the start of the audio. The tempo estimator may use only the first part of this, up to eight times the slowest beat duration: increasing this value further than that is unlikely to improve results."; cannam@243: d.unit = "s"; cannam@243: d.minValue = 2; cannam@243: d.maxValue = 40; cannam@243: d.defaultValue = 10; cannam@243: list.push_back(d); cannam@243: cannam@198: return list; cannam@198: } cannam@198: cannam@198: float cannam@243: FixedTempoEstimator::D::getParameter(string id) const cannam@198: { cannam@243: if (id == "minbpm") { cannam@243: return m_minbpm; cannam@243: } else if (id == "maxbpm") { cannam@243: return m_maxbpm; cannam@243: } else if (id == "maxdflen") { cannam@243: return m_maxdflen; cannam@243: } cannam@198: return 0.f; cannam@198: } cannam@198: cannam@198: void cannam@243: FixedTempoEstimator::D::setParameter(string id, float value) cannam@198: { cannam@243: if (id == "minbpm") { cannam@243: m_minbpm = value; cannam@243: } else if (id == "maxbpm") { cannam@243: m_maxbpm = value; cannam@243: } else if (id == "maxdflen") { cannam@243: m_maxdflen = value; cannam@243: } cannam@198: } cannam@198: cannam@200: static int TempoOutput = 0; cannam@200: static int CandidatesOutput = 1; cannam@200: static int DFOutput = 2; cannam@200: static int ACFOutput = 3; cannam@200: static int FilteredACFOutput = 4; cannam@200: cannam@198: FixedTempoEstimator::OutputList cannam@243: FixedTempoEstimator::D::getOutputDescriptors() const cannam@198: { cannam@198: OutputList list; cannam@198: cannam@198: OutputDescriptor d; cannam@198: d.identifier = "tempo"; cannam@198: d.name = "Tempo"; cannam@198: d.description = "Estimated tempo"; cannam@198: d.unit = "bpm"; cannam@198: d.hasFixedBinCount = true; cannam@198: d.binCount = 1; cannam@198: d.hasKnownExtents = false; cannam@198: d.isQuantized = false; cannam@198: d.sampleType = OutputDescriptor::VariableSampleRate; cannam@198: d.sampleRate = m_inputSampleRate; cannam@198: d.hasDuration = true; // our returned tempo spans a certain range cannam@198: list.push_back(d); cannam@198: cannam@200: d.identifier = "candidates"; cannam@200: d.name = "Tempo candidates"; cannam@200: d.description = "Possible tempo estimates, one per bin with the most likely in the first bin"; cannam@200: d.unit = "bpm"; cannam@200: d.hasFixedBinCount = false; cannam@200: list.push_back(d); cannam@200: cannam@198: d.identifier = "detectionfunction"; cannam@198: d.name = "Detection Function"; cannam@198: d.description = "Onset detection function"; cannam@198: d.unit = ""; cannam@198: d.hasFixedBinCount = 1; cannam@198: d.binCount = 1; cannam@198: d.hasKnownExtents = true; cannam@198: d.minValue = 0.0; cannam@198: d.maxValue = 1.0; cannam@198: d.isQuantized = false; cannam@198: d.quantizeStep = 0.0; cannam@198: d.sampleType = OutputDescriptor::FixedSampleRate; cannam@198: if (m_stepSize) { cannam@198: d.sampleRate = m_inputSampleRate / m_stepSize; cannam@198: } else { cannam@198: d.sampleRate = m_inputSampleRate / (getPreferredBlockSize()/2); cannam@198: } cannam@198: d.hasDuration = false; cannam@198: list.push_back(d); cannam@198: cannam@198: d.identifier = "acf"; cannam@198: d.name = "Autocorrelation Function"; cannam@198: d.description = "Autocorrelation of onset detection function"; cannam@198: d.hasKnownExtents = false; cannam@201: d.unit = "r"; cannam@198: list.push_back(d); cannam@198: cannam@198: d.identifier = "filtered_acf"; cannam@198: d.name = "Filtered Autocorrelation"; cannam@198: d.description = "Filtered autocorrelation of onset detection function"; cannam@201: d.unit = "r"; cannam@198: list.push_back(d); cannam@198: cannam@198: return list; cannam@198: } cannam@198: cannam@243: bool cannam@271: FixedTempoEstimator::D::initialise(size_t, size_t stepSize, size_t blockSize) cannam@243: { cannam@243: m_stepSize = stepSize; cannam@243: m_blockSize = blockSize; cannam@243: cannam@243: float dfLengthSecs = m_maxdflen; cannam@243: m_dfsize = (dfLengthSecs * m_inputSampleRate) / m_stepSize; cannam@243: cannam@243: m_priorMagnitudes = new float[m_blockSize/2]; cannam@243: m_df = new float[m_dfsize]; cannam@243: cannam@243: for (size_t i = 0; i < m_blockSize/2; ++i) { cannam@243: m_priorMagnitudes[i] = 0.f; cannam@243: } cannam@243: for (size_t i = 0; i < m_dfsize; ++i) { cannam@243: m_df[i] = 0.f; cannam@243: } cannam@243: cannam@243: m_n = 0; cannam@243: cannam@243: return true; cannam@243: } cannam@243: cannam@243: void cannam@243: FixedTempoEstimator::D::reset() cannam@243: { cannam@243: if (!m_priorMagnitudes) return; cannam@243: cannam@243: for (size_t i = 0; i < m_blockSize/2; ++i) { cannam@243: m_priorMagnitudes[i] = 0.f; cannam@243: } cannam@243: for (size_t i = 0; i < m_dfsize; ++i) { cannam@243: m_df[i] = 0.f; cannam@243: } cannam@243: cannam@243: delete[] m_r; cannam@243: m_r = 0; cannam@243: cannam@243: delete[] m_fr; cannam@243: m_fr = 0; cannam@243: cannam@243: delete[] m_t; cannam@243: m_t = 0; cannam@243: cannam@243: m_n = 0; cannam@243: cannam@243: m_start = RealTime::zeroTime; cannam@243: m_lasttime = RealTime::zeroTime; cannam@243: } cannam@243: cannam@198: FixedTempoEstimator::FeatureSet cannam@243: FixedTempoEstimator::D::process(const float *const *inputBuffers, RealTime ts) cannam@198: { cannam@198: FeatureSet fs; cannam@198: cannam@198: if (m_stepSize == 0) { cannam@198: cerr << "ERROR: FixedTempoEstimator::process: " cannam@198: << "FixedTempoEstimator has not been initialised" cannam@198: << endl; cannam@198: return fs; cannam@198: } cannam@198: cannam@198: if (m_n == 0) m_start = ts; cannam@198: m_lasttime = ts; cannam@198: cannam@198: if (m_n == m_dfsize) { cannam@255: // If we have seen enough input, do the estimation and return cannam@200: calculate(); cannam@200: fs = assembleFeatures(); cannam@198: ++m_n; cannam@198: return fs; cannam@198: } cannam@198: cannam@255: // If we have seen more than enough, just discard and return! cannam@198: if (m_n > m_dfsize) return FeatureSet(); cannam@198: cannam@207: float value = 0.f; cannam@207: cannam@255: // m_df will contain an onset detection function based on the rise cannam@255: // in overall power from one spectral frame to the next -- cannam@255: // simplistic but reasonably effective for our purposes. cannam@255: cannam@198: for (size_t i = 1; i < m_blockSize/2; ++i) { cannam@198: cannam@198: float real = inputBuffers[0][i*2]; cannam@198: float imag = inputBuffers[0][i*2 + 1]; cannam@198: cannam@198: float sqrmag = real * real + imag * imag; cannam@207: value += fabsf(sqrmag - m_priorMagnitudes[i]); cannam@198: cannam@198: m_priorMagnitudes[i] = sqrmag; cannam@198: } cannam@198: cannam@207: m_df[m_n] = value; cannam@207: cannam@198: ++m_n; cannam@198: return fs; cannam@243: } cannam@198: cannam@198: FixedTempoEstimator::FeatureSet cannam@243: FixedTempoEstimator::D::getRemainingFeatures() cannam@198: { cannam@198: FeatureSet fs; cannam@198: if (m_n > m_dfsize) return fs; cannam@200: calculate(); cannam@200: fs = assembleFeatures(); cannam@198: ++m_n; cannam@198: return fs; cannam@198: } cannam@198: cannam@198: float cannam@243: FixedTempoEstimator::D::lag2tempo(int lag) cannam@199: { cannam@198: return 60.f / ((lag * m_stepSize) / m_inputSampleRate); cannam@198: } cannam@198: cannam@207: int cannam@243: FixedTempoEstimator::D::tempo2lag(float tempo) cannam@207: { cannam@207: return ((60.f / tempo) * m_inputSampleRate) / m_stepSize; cannam@207: } cannam@207: cannam@200: void cannam@243: FixedTempoEstimator::D::calculate() cannam@200: { cannam@200: if (m_r) { cannam@207: cerr << "FixedTempoEstimator::calculate: calculation already happened?" << endl; cannam@200: return; cannam@200: } cannam@200: cannam@243: if (m_n < m_dfsize / 9 && cannam@243: m_n < (1.0 * m_inputSampleRate) / m_stepSize) { // 1 second cannam@243: cerr << "FixedTempoEstimator::calculate: Input is too short" << endl; cannam@243: return; cannam@200: } cannam@200: cannam@255: // This function takes m_df (the detection function array filled cannam@255: // out in process()) and calculates m_r (the raw autocorrelation) cannam@255: // and m_fr (the filtered autocorrelation from whose peaks tempo cannam@255: // estimates will be taken). cannam@200: cannam@255: int n = m_n; // length of actual df array (m_dfsize is the theoretical max) cannam@255: cannam@255: m_r = new float[n/2]; // raw autocorrelation cannam@255: m_fr = new float[n/2]; // filtered autocorrelation cannam@255: m_t = new float[n/2]; // averaged tempo estimate for each lag value cannam@200: cannam@200: for (int i = 0; i < n/2; ++i) { cannam@255: m_r[i] = 0.f; cannam@200: m_fr[i] = 0.f; cannam@255: m_t[i] = lag2tempo(i); cannam@200: } cannam@200: cannam@255: // Calculate the raw autocorrelation of the detection function cannam@255: cannam@200: for (int i = 0; i < n/2; ++i) { cannam@200: cannam@271: for (int j = i; j < n; ++j) { cannam@200: m_r[i] += m_df[j] * m_df[j - i]; cannam@200: } cannam@200: cannam@200: m_r[i] /= n - i - 1; cannam@200: } cannam@200: cannam@255: // Filter the autocorrelation and average out the tempo estimates cannam@255: cannam@246: float related[] = { 0.5, 2, 4, 8 }; cannam@208: cannam@209: for (int i = 1; i < n/2-1; ++i) { cannam@204: cannam@209: m_fr[i] = m_r[i]; cannam@204: cannam@200: int div = 1; cannam@200: cannam@215: for (int j = 0; j < int(sizeof(related)/sizeof(related[0])); ++j) { cannam@204: cannam@255: // Check for an obvious peak at each metrically related lag cannam@255: cannam@215: int k0 = int(i * related[j] + 0.5); cannam@209: cannam@215: if (k0 >= 0 && k0 < int(n/2)) { cannam@204: Chris@398: int kmax = 0; cannam@207: float kvmax = 0, kvmin = 0; cannam@209: bool have = false; cannam@204: cannam@209: for (int k = k0 - 1; k <= k0 + 1; ++k) { cannam@204: cannam@209: if (k < 0 || k >= n/2) continue; cannam@209: Chris@398: if (!have || (m_r[k] > kvmax)) { kvmax = m_r[k]; kmax = k; } Chris@398: if (!have || (m_r[k] < kvmin)) { kvmin = m_r[k]; } cannam@209: cannam@209: have = true; cannam@204: } cannam@209: cannam@255: // Boost the original lag according to the strongest cannam@255: // value found close to this related lag cannam@255: cannam@215: m_fr[i] += m_r[kmax] / 5; cannam@209: cannam@209: if ((kmax == 0 || m_r[kmax] > m_r[kmax-1]) && cannam@209: (kmax == n/2-1 || m_r[kmax] > m_r[kmax+1]) && cannam@207: kvmax > kvmin * 1.05) { cannam@255: cannam@255: // The strongest value close to the related lag is cannam@255: // also a pretty good looking peak, so use it to cannam@255: // improve our tempo estimate for the original lag cannam@209: cannam@207: m_t[i] = m_t[i] + lag2tempo(kmax) * related[j]; cannam@207: ++div; cannam@207: } cannam@204: } cannam@204: } cannam@209: cannam@204: m_t[i] /= div; cannam@204: cannam@255: // Finally apply a primitive perceptual weighting (to prefer cannam@255: // tempi of around 120-130) cannam@255: cannam@255: float weight = 1.f - fabsf(128.f - lag2tempo(i)) * 0.005; cannam@255: if (weight < 0.f) weight = 0.f; cannam@255: weight = weight * weight * weight; cannam@255: cannam@215: m_fr[i] += m_fr[i] * (weight / 3); cannam@207: } cannam@200: } cannam@200: cannam@198: FixedTempoEstimator::FeatureSet cannam@243: FixedTempoEstimator::D::assembleFeatures() cannam@198: { cannam@198: FeatureSet fs; cannam@255: if (!m_r) return fs; // No autocorrelation: no results cannam@200: cannam@198: Feature feature; cannam@198: feature.hasTimestamp = true; cannam@198: feature.hasDuration = false; cannam@198: feature.label = ""; cannam@198: feature.values.clear(); cannam@198: feature.values.push_back(0.f); cannam@198: cannam@200: char buffer[40]; cannam@198: cannam@198: int n = m_n; cannam@198: cannam@198: for (int i = 0; i < n; ++i) { cannam@255: cannam@255: // Return the detection function in the DF output cannam@255: cannam@208: feature.timestamp = m_start + cannam@208: RealTime::frame2RealTime(i * m_stepSize, m_inputSampleRate); cannam@200: feature.values[0] = m_df[i]; cannam@198: feature.label = ""; cannam@200: fs[DFOutput].push_back(feature); cannam@198: } cannam@198: cannam@199: for (int i = 1; i < n/2; ++i) { cannam@255: cannam@255: // Return the raw autocorrelation in the ACF output, each cannam@255: // value labelled according to its corresponding tempo cannam@255: cannam@208: feature.timestamp = m_start + cannam@208: RealTime::frame2RealTime(i * m_stepSize, m_inputSampleRate); cannam@200: feature.values[0] = m_r[i]; cannam@199: sprintf(buffer, "%.1f bpm", lag2tempo(i)); cannam@200: if (i == n/2-1) feature.label = ""; cannam@200: else feature.label = buffer; cannam@200: fs[ACFOutput].push_back(feature); cannam@198: } cannam@198: cannam@243: float t0 = m_minbpm; // our minimum detected tempo cannam@243: float t1 = m_maxbpm; // our maximum detected tempo cannam@216: cannam@207: int p0 = tempo2lag(t1); cannam@207: int p1 = tempo2lag(t0); cannam@198: cannam@200: std::map candidates; cannam@198: cannam@271: for (int i = p0; i <= p1 && i+1 < n/2; ++i) { cannam@198: cannam@209: if (m_fr[i] > m_fr[i-1] && cannam@209: m_fr[i] > m_fr[i+1]) { cannam@255: cannam@255: // This is a peak in the filtered autocorrelation: stick cannam@255: // it into the map from filtered autocorrelation to lag cannam@255: // index -- this sorts our peaks by filtered acf value cannam@255: cannam@209: candidates[m_fr[i]] = i; cannam@209: } cannam@198: cannam@255: // Also return the filtered autocorrelation in its own output cannam@255: cannam@208: feature.timestamp = m_start + cannam@208: RealTime::frame2RealTime(i * m_stepSize, m_inputSampleRate); cannam@200: feature.values[0] = m_fr[i]; cannam@199: sprintf(buffer, "%.1f bpm", lag2tempo(i)); cannam@200: if (i == p1 || i == n/2-2) feature.label = ""; cannam@200: else feature.label = buffer; cannam@200: fs[FilteredACFOutput].push_back(feature); cannam@198: } cannam@198: cannam@200: if (candidates.empty()) { cannam@207: cerr << "No tempo candidates!" << endl; cannam@200: return fs; cannam@200: } cannam@198: cannam@198: feature.hasTimestamp = true; cannam@198: feature.timestamp = m_start; cannam@198: cannam@198: feature.hasDuration = true; cannam@198: feature.duration = m_lasttime - m_start; cannam@198: cannam@255: // The map contains only peaks and is sorted by filtered acf cannam@255: // value, so the final element in it is our "best" tempo guess cannam@255: cannam@200: std::map::const_iterator ci = candidates.end(); cannam@200: --ci; cannam@200: int maxpi = ci->second; cannam@198: cannam@204: if (m_t[maxpi] > 0) { cannam@255: cannam@255: // This lag has an adjusted tempo from the averaging process: cannam@255: // use it cannam@255: cannam@204: feature.values[0] = m_t[maxpi]; cannam@255: cannam@204: } else { cannam@255: cannam@255: // shouldn't happen -- it would imply that this high value was cannam@255: // not a peak! cannam@255: cannam@204: feature.values[0] = lag2tempo(maxpi); cannam@207: cerr << "WARNING: No stored tempo for index " << maxpi << endl; cannam@204: } cannam@204: cannam@204: sprintf(buffer, "%.1f bpm", feature.values[0]); cannam@199: feature.label = buffer; cannam@199: cannam@255: // Return the best tempo in the main output cannam@255: cannam@200: fs[TempoOutput].push_back(feature); cannam@198: cannam@255: // And return the other estimates (up to the arbitrarily chosen cannam@255: // number of 10 of them) in the candidates output cannam@255: cannam@200: feature.values.clear(); cannam@200: feature.label = ""; cannam@200: cannam@255: while (feature.values.size() < 10) { cannam@207: if (m_t[ci->second] > 0) { cannam@207: feature.values.push_back(m_t[ci->second]); cannam@207: } else { cannam@207: feature.values.push_back(lag2tempo(ci->second)); cannam@207: } cannam@200: if (ci == candidates.begin()) break; cannam@200: --ci; cannam@200: } cannam@200: cannam@200: fs[CandidatesOutput].push_back(feature); cannam@200: cannam@198: return fs; cannam@198: } cannam@243: cannam@243: cannam@243: cannam@243: FixedTempoEstimator::FixedTempoEstimator(float inputSampleRate) : cannam@243: Plugin(inputSampleRate), cannam@243: m_d(new D(inputSampleRate)) cannam@243: { cannam@243: } cannam@243: cannam@243: FixedTempoEstimator::~FixedTempoEstimator() cannam@243: { cannam@271: delete m_d; cannam@243: } cannam@243: cannam@243: string cannam@243: FixedTempoEstimator::getIdentifier() const cannam@243: { cannam@243: return "fixedtempo"; cannam@243: } cannam@243: cannam@243: string cannam@243: FixedTempoEstimator::getName() const cannam@243: { cannam@243: return "Simple Fixed Tempo Estimator"; cannam@243: } cannam@243: cannam@243: string cannam@243: FixedTempoEstimator::getDescription() const cannam@243: { cannam@243: return "Study a short section of audio and estimate its tempo, assuming the tempo is constant"; cannam@243: } cannam@243: cannam@243: string cannam@243: FixedTempoEstimator::getMaker() const cannam@243: { cannam@243: return "Vamp SDK Example Plugins"; cannam@243: } cannam@243: cannam@243: int cannam@243: FixedTempoEstimator::getPluginVersion() const cannam@243: { cannam@243: return 1; cannam@243: } cannam@243: cannam@243: string cannam@243: FixedTempoEstimator::getCopyright() const cannam@243: { cannam@243: return "Code copyright 2008 Queen Mary, University of London. Freely redistributable (BSD license)"; cannam@243: } cannam@243: cannam@243: size_t cannam@243: FixedTempoEstimator::getPreferredStepSize() const cannam@243: { cannam@243: return m_d->getPreferredStepSize(); cannam@243: } cannam@243: cannam@243: size_t cannam@243: FixedTempoEstimator::getPreferredBlockSize() const cannam@243: { cannam@243: return m_d->getPreferredBlockSize(); cannam@243: } cannam@243: cannam@243: bool cannam@243: FixedTempoEstimator::initialise(size_t channels, size_t stepSize, size_t blockSize) cannam@243: { cannam@243: if (channels < getMinChannelCount() || cannam@243: channels > getMaxChannelCount()) return false; cannam@243: cannam@243: return m_d->initialise(channels, stepSize, blockSize); cannam@243: } cannam@243: cannam@243: void cannam@243: FixedTempoEstimator::reset() cannam@243: { cannam@243: return m_d->reset(); cannam@243: } cannam@243: cannam@243: FixedTempoEstimator::ParameterList cannam@243: FixedTempoEstimator::getParameterDescriptors() const cannam@243: { cannam@243: return m_d->getParameterDescriptors(); cannam@243: } cannam@243: cannam@243: float cannam@243: FixedTempoEstimator::getParameter(std::string id) const cannam@243: { cannam@243: return m_d->getParameter(id); cannam@243: } cannam@243: cannam@243: void cannam@243: FixedTempoEstimator::setParameter(std::string id, float value) cannam@243: { cannam@243: m_d->setParameter(id, value); cannam@243: } cannam@243: cannam@243: FixedTempoEstimator::OutputList cannam@243: FixedTempoEstimator::getOutputDescriptors() const cannam@243: { cannam@243: return m_d->getOutputDescriptors(); cannam@243: } cannam@243: cannam@243: FixedTempoEstimator::FeatureSet cannam@243: FixedTempoEstimator::process(const float *const *inputBuffers, RealTime ts) cannam@243: { cannam@243: return m_d->process(inputBuffers, ts); cannam@243: } cannam@243: cannam@243: FixedTempoEstimator::FeatureSet cannam@243: FixedTempoEstimator::getRemainingFeatures() cannam@243: { cannam@243: return m_d->getRemainingFeatures(); cannam@243: }