Mercurial > hg > vamp-plugin-sdk
comparison examples/ZeroCrossing.cpp @ 255:88ef5ffdbe8d
* docs
author | cannam |
---|---|
date | Wed, 12 Nov 2008 14:11:01 +0000 |
parents | 6b30e064cab7 |
children | 1ed95908a397 |
comparison
equal
deleted
inserted
replaced
254:e02c93c4de8f | 255:88ef5ffdbe8d |
---|---|
136 list.push_back(zc); | 136 list.push_back(zc); |
137 | 137 |
138 return list; | 138 return list; |
139 } | 139 } |
140 | 140 |
141 //static int scount = 0; | |
142 | |
143 ZeroCrossing::FeatureSet | 141 ZeroCrossing::FeatureSet |
144 ZeroCrossing::process(const float *const *inputBuffers, | 142 ZeroCrossing::process(const float *const *inputBuffers, |
145 Vamp::RealTime timestamp) | 143 Vamp::RealTime timestamp) |
146 { | 144 { |
147 if (m_stepSize == 0) { | 145 if (m_stepSize == 0) { |
149 << "ZeroCrossing has not been initialised" | 147 << "ZeroCrossing has not been initialised" |
150 << endl; | 148 << endl; |
151 return FeatureSet(); | 149 return FeatureSet(); |
152 } | 150 } |
153 | 151 |
154 // std::cerr << "ZeroCrossing::process: count = " << scount++ << ", timestamp = " << timestamp << ", rms = "; | |
155 | |
156 float prev = m_previousSample; | 152 float prev = m_previousSample; |
157 size_t count = 0; | 153 size_t count = 0; |
158 | 154 |
159 FeatureSet returnFeatures; | 155 FeatureSet returnFeatures; |
160 | |
161 // double acc = 0.0; | |
162 | 156 |
163 for (size_t i = 0; i < m_stepSize; ++i) { | 157 for (size_t i = 0; i < m_stepSize; ++i) { |
164 | 158 |
165 float sample = inputBuffers[0][i]; | 159 float sample = inputBuffers[0][i]; |
166 bool crossing = false; | 160 bool crossing = false; |
178 feature.timestamp = timestamp + | 172 feature.timestamp = timestamp + |
179 Vamp::RealTime::frame2RealTime(i, (size_t)m_inputSampleRate); | 173 Vamp::RealTime::frame2RealTime(i, (size_t)m_inputSampleRate); |
180 returnFeatures[1].push_back(feature); | 174 returnFeatures[1].push_back(feature); |
181 } | 175 } |
182 | 176 |
183 // acc += sample * sample; | |
184 | |
185 prev = sample; | 177 prev = sample; |
186 } | 178 } |
187 | |
188 // acc /= m_stepSize; | |
189 // std::cerr << sqrt(acc) << std::endl; | |
190 | 179 |
191 m_previousSample = prev; | 180 m_previousSample = prev; |
192 | 181 |
193 Feature feature; | 182 Feature feature; |
194 feature.hasTimestamp = false; | 183 feature.hasTimestamp = false; |