annotate dsp/tonal/TonalEstimator.cpp @ 96:88f3cfcff55f

A threshold (delta) is added in the peak picking parameters structure (PPickParams). It is used as an offset when computing the smoothed detection function. A constructor for the structure PPickParams is also added to set the parameters to 0 when a structure instance is created. Hence programmes using the peak picking parameter structure and which do not set the delta parameter (e.g. QM Vamp note onset detector) won't be affected by the modifications. Functions modified: - dsp/onsets/PeakPicking.cpp - dsp/onsets/PeakPicking.h - dsp/signalconditioning/DFProcess.cpp - dsp/signalconditioning/DFProcess.h
author mathieub <mathieu.barthet@eecs.qmul.ac.uk>
date Mon, 20 Jun 2011 19:01:48 +0100
parents e5907ae6de17
children cbe668c7d724
rev   line source
cannam@0 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
cannam@0 2
cannam@0 3 /*
cannam@0 4 QM DSP Library
cannam@0 5
cannam@0 6 Centre for Digital Music, Queen Mary, University of London.
cannam@0 7 This file copyright 2006 Martin Gasser.
Chris@84 8
Chris@84 9 This program is free software; you can redistribute it and/or
Chris@84 10 modify it under the terms of the GNU General Public License as
Chris@84 11 published by the Free Software Foundation; either version 2 of the
Chris@84 12 License, or (at your option) any later version. See the file
Chris@84 13 COPYING included with this distribution for more information.
cannam@0 14 */
cannam@0 15
cannam@0 16 #include "TonalEstimator.h"
cannam@0 17
cannam@0 18 #include <cmath>
cannam@0 19 #include <iostream>
cannam@0 20
cannam@0 21 #ifndef PI
cannam@0 22 #define PI (3.14159265358979232846)
cannam@0 23 #endif
cannam@0 24
cannam@0 25 TonalEstimator::TonalEstimator()
cannam@0 26 {
cannam@0 27 m_Basis.resize(6);
cannam@0 28
cannam@0 29 int i = 0;
cannam@0 30
cannam@0 31
cannam@0 32 // circle of fifths
cannam@0 33 m_Basis[i].resize(12);
cannam@0 34 for (int iP = 0; iP < 12; iP++)
cannam@0 35 {
cannam@0 36 m_Basis[i][iP] = std::sin( (7.0 / 6.0) * iP * PI);
cannam@0 37 }
cannam@0 38
cannam@0 39 i++;
cannam@0 40
cannam@0 41 m_Basis[i].resize(12);
cannam@0 42 for (int iP = 0; iP < 12; iP++)
cannam@0 43 {
cannam@0 44 m_Basis[i][iP] = std::cos( (7.0 / 6.0) * iP * PI);
cannam@0 45 }
cannam@0 46
cannam@0 47 i++;
cannam@0 48
cannam@0 49
cannam@0 50 // circle of major thirds
cannam@0 51 m_Basis[i].resize(12);
cannam@0 52 for (int iP = 0; iP < 12; iP++)
cannam@0 53 {
cannam@0 54 m_Basis[i][iP] = 0.6 * std::sin( (2.0 / 3.0) * iP * PI);
cannam@0 55 }
cannam@0 56
cannam@0 57 i++;
cannam@0 58
cannam@0 59 m_Basis[i].resize(12);
cannam@0 60 for (int iP = 0; iP < 12; iP++)
cannam@0 61 {
cannam@0 62 m_Basis[i][iP] = 0.6 * std::cos( (2.0 / 3.0) * iP * PI);
cannam@0 63 }
cannam@0 64
cannam@0 65 i++;
cannam@0 66
cannam@0 67
cannam@0 68 // circle of minor thirds
cannam@0 69 m_Basis[i].resize(12);
cannam@0 70 for (int iP = 0; iP < 12; iP++)
cannam@0 71 {
cannam@0 72 m_Basis[i][iP] = 1.1 * std::sin( (3.0 / 2.0) * iP * PI);
cannam@0 73 }
cannam@0 74
cannam@0 75 i++;
cannam@0 76
cannam@0 77 m_Basis[i].resize(12);
cannam@0 78 for (int iP = 0; iP < 12; iP++)
cannam@0 79 {
cannam@0 80 m_Basis[i][iP] = 1.1 * std::cos( (3.0 / 2.0) * iP * PI);
cannam@0 81 }
cannam@0 82
cannam@0 83 }
cannam@0 84
cannam@0 85 TonalEstimator::~TonalEstimator()
cannam@0 86 {
cannam@0 87 }
cannam@0 88
cannam@0 89 TCSVector TonalEstimator::transform2TCS(const ChromaVector& rVector)
cannam@0 90 {
cannam@0 91 TCSVector vaRetVal;
cannam@0 92 vaRetVal.resize(6, 0.0);
cannam@0 93
cannam@0 94 for (int i = 0; i < 6; i++)
cannam@0 95 {
cannam@0 96 for (int iP = 0; iP < 12; iP++)
cannam@0 97 {
cannam@0 98 vaRetVal[i] += m_Basis[i][iP] * rVector[iP];
cannam@0 99 }
cannam@0 100 }
cannam@0 101
cannam@0 102 return vaRetVal;
cannam@0 103 }