annotate ConstrainedHarmonicPeak.cpp @ 0:f559ab000b67

Initial skeleton
author Chris Cannam
date Fri, 07 Mar 2014 14:34:50 +0000
parents
children ab0b04e1c56b
rev   line source
Chris@0 1
Chris@0 2 #include "ConstrainedHarmonicPeak.h"
Chris@0 3
Chris@0 4 #include <cmath>
Chris@0 5 #include <cstdio>
Chris@0 6
Chris@0 7 using std::cerr;
Chris@0 8 using std::endl;
Chris@0 9 using std::vector;
Chris@0 10
Chris@0 11 ConstrainedHarmonicPeak::ConstrainedHarmonicPeak(float inputSampleRate) :
Chris@0 12 Plugin(inputSampleRate),
Chris@0 13 m_blockSize(0),
Chris@0 14 m_minFreq(0),
Chris@0 15 m_maxFreq(inputSampleRate/2)
Chris@0 16 {
Chris@0 17 }
Chris@0 18
Chris@0 19 ConstrainedHarmonicPeak::~ConstrainedHarmonicPeak()
Chris@0 20 {
Chris@0 21 }
Chris@0 22
Chris@0 23 string
Chris@0 24 ConstrainedHarmonicPeak::getIdentifier() const
Chris@0 25 {
Chris@0 26 return "constrainedharmonicpeak";
Chris@0 27 }
Chris@0 28
Chris@0 29 string
Chris@0 30 ConstrainedHarmonicPeak::getName() const
Chris@0 31 {
Chris@0 32 return "Frequency-Constrained Harmonic Peak";
Chris@0 33 }
Chris@0 34
Chris@0 35 string
Chris@0 36 ConstrainedHarmonicPeak::getDescription() const
Chris@0 37 {
Chris@0 38 //!!! Return something helpful here!
Chris@0 39 return "";
Chris@0 40 }
Chris@0 41
Chris@0 42 string
Chris@0 43 ConstrainedHarmonicPeak::getMaker() const
Chris@0 44 {
Chris@0 45 return "Queen Mary, University of London";
Chris@0 46 }
Chris@0 47
Chris@0 48 int
Chris@0 49 ConstrainedHarmonicPeak::getPluginVersion() const
Chris@0 50 {
Chris@0 51 return 1;
Chris@0 52 }
Chris@0 53
Chris@0 54 string
Chris@0 55 ConstrainedHarmonicPeak::getCopyright() const
Chris@0 56 {
Chris@0 57 return "GPL";
Chris@0 58 }
Chris@0 59
Chris@0 60 ConstrainedHarmonicPeak::InputDomain
Chris@0 61 ConstrainedHarmonicPeak::getInputDomain() const
Chris@0 62 {
Chris@0 63 return FrequencyDomain;
Chris@0 64 }
Chris@0 65
Chris@0 66 size_t
Chris@0 67 ConstrainedHarmonicPeak::getPreferredBlockSize() const
Chris@0 68 {
Chris@0 69 return 2048;
Chris@0 70 }
Chris@0 71
Chris@0 72 size_t
Chris@0 73 ConstrainedHarmonicPeak::getPreferredStepSize() const
Chris@0 74 {
Chris@0 75 return 512;
Chris@0 76 }
Chris@0 77
Chris@0 78 size_t
Chris@0 79 ConstrainedHarmonicPeak::getMinChannelCount() const
Chris@0 80 {
Chris@0 81 return 1;
Chris@0 82 }
Chris@0 83
Chris@0 84 size_t
Chris@0 85 ConstrainedHarmonicPeak::getMaxChannelCount() const
Chris@0 86 {
Chris@0 87 return 1;
Chris@0 88 }
Chris@0 89
Chris@0 90 ConstrainedHarmonicPeak::ParameterList
Chris@0 91 ConstrainedHarmonicPeak::getParameterDescriptors() const
Chris@0 92 {
Chris@0 93 ParameterList list;
Chris@0 94
Chris@0 95 ParameterDescriptor d;
Chris@0 96 d.identifier = "minfreq";
Chris@0 97 d.name = "Minimum frequency";
Chris@0 98 d.description = "";
Chris@0 99 d.unit = "Hz";
Chris@0 100 d.minValue = 0;
Chris@0 101 d.maxValue = m_inputSampleRate/2;
Chris@0 102 d.defaultValue = 0;
Chris@0 103 d.isQuantized = false;
Chris@0 104 list.push_back(d);
Chris@0 105
Chris@0 106 d.identifier = "maxfreq";
Chris@0 107 d.name = "Maximum frequency";
Chris@0 108 d.description = "";
Chris@0 109 d.unit = "Hz";
Chris@0 110 d.minValue = 0;
Chris@0 111 d.maxValue = m_inputSampleRate/2;
Chris@0 112 d.defaultValue = 0;
Chris@0 113 d.isQuantized = false;
Chris@0 114 list.push_back(d);
Chris@0 115
Chris@0 116 return list;
Chris@0 117 }
Chris@0 118
Chris@0 119 float
Chris@0 120 ConstrainedHarmonicPeak::getParameter(string identifier) const
Chris@0 121 {
Chris@0 122 if (identifier == "minfreq") {
Chris@0 123 return m_minFreq;
Chris@0 124 } else if (identifier == "maxfreq") {
Chris@0 125 return m_maxFreq;
Chris@0 126 }
Chris@0 127 return 0;
Chris@0 128 }
Chris@0 129
Chris@0 130 void
Chris@0 131 ConstrainedHarmonicPeak::setParameter(string identifier, float value)
Chris@0 132 {
Chris@0 133 if (identifier == "minfreq") {
Chris@0 134 m_minFreq = value;
Chris@0 135 } else if (identifier == "maxfreq") {
Chris@0 136 m_maxFreq = value;
Chris@0 137 }
Chris@0 138 }
Chris@0 139
Chris@0 140 ConstrainedHarmonicPeak::ProgramList
Chris@0 141 ConstrainedHarmonicPeak::getPrograms() const
Chris@0 142 {
Chris@0 143 ProgramList list;
Chris@0 144 return list;
Chris@0 145 }
Chris@0 146
Chris@0 147 string
Chris@0 148 ConstrainedHarmonicPeak::getCurrentProgram() const
Chris@0 149 {
Chris@0 150 return ""; // no programs
Chris@0 151 }
Chris@0 152
Chris@0 153 void
Chris@0 154 ConstrainedHarmonicPeak::selectProgram(string name)
Chris@0 155 {
Chris@0 156 }
Chris@0 157
Chris@0 158 ConstrainedHarmonicPeak::OutputList
Chris@0 159 ConstrainedHarmonicPeak::getOutputDescriptors() const
Chris@0 160 {
Chris@0 161 OutputList list;
Chris@0 162
Chris@0 163 OutputDescriptor d;
Chris@0 164 d.identifier = "peak";
Chris@0 165 d.name = "Peak frequency";
Chris@0 166 d.description = "";
Chris@0 167 d.unit = "Hz";
Chris@0 168 d.sampleType = OutputDescriptor::OneSamplePerStep;
Chris@0 169 d.hasDuration = false;
Chris@0 170 list.push_back(d);
Chris@0 171
Chris@0 172 return list;
Chris@0 173 }
Chris@0 174
Chris@0 175 bool
Chris@0 176 ConstrainedHarmonicPeak::initialise(size_t channels, size_t stepSize, size_t blockSize)
Chris@0 177 {
Chris@0 178 if (channels < getMinChannelCount() ||
Chris@0 179 channels > getMaxChannelCount()) {
Chris@0 180 cerr << "ConstrainedHarmonicPeak::initialise: ERROR: channels " << channels
Chris@0 181 << " out of acceptable range " << getMinChannelCount()
Chris@0 182 << " -> " << getMaxChannelCount() << endl;
Chris@0 183 return false;
Chris@0 184 }
Chris@0 185
Chris@0 186 m_blockSize = blockSize;
Chris@0 187
Chris@0 188 return true;
Chris@0 189 }
Chris@0 190
Chris@0 191 void
Chris@0 192 ConstrainedHarmonicPeak::reset()
Chris@0 193 {
Chris@0 194 }
Chris@0 195
Chris@0 196 ConstrainedHarmonicPeak::FeatureSet
Chris@0 197 ConstrainedHarmonicPeak::process(const float *const *inputBuffers, Vamp::RealTime timestamp)
Chris@0 198 {
Chris@0 199 FeatureSet fs;
Chris@0 200
Chris@0 201 return fs;
Chris@0 202 }
Chris@0 203
Chris@0 204 ConstrainedHarmonicPeak::FeatureSet
Chris@0 205 ConstrainedHarmonicPeak::getRemainingFeatures()
Chris@0 206 {
Chris@0 207 FeatureSet fs;
Chris@0 208
Chris@0 209 return fs;
Chris@0 210 }
Chris@0 211