Mercurial > hg > pyin
comparison Yin.cpp @ 61:d501b52f95b6 tony
Move these initialisers out, don't fill up the stack with them
author | Chris Cannam |
---|---|
date | Tue, 01 Apr 2014 10:38:39 +0100 |
parents | 60eb8771d340 |
children | 01057d57dd9a |
comparison
equal
deleted
inserted
replaced
60:60eb8771d340 | 61:d501b52f95b6 |
---|---|
55 | 55 |
56 double interpolatedTau; | 56 double interpolatedTau; |
57 double aperiodicity; | 57 double aperiodicity; |
58 double f0; | 58 double f0; |
59 | 59 |
60 if (tau!=0 && tau!=m_yinBufferSize-1) | 60 if (tau!=0 && tau!=int(m_yinBufferSize)-1) |
61 { | 61 { |
62 interpolatedTau = YinUtil::parabolicInterpolation(yinBuffer, abs(tau), m_yinBufferSize); | 62 interpolatedTau = YinUtil::parabolicInterpolation(yinBuffer, abs(tau), m_yinBufferSize); |
63 f0 = m_inputSampleRate * (1.0 / interpolatedTau); | 63 f0 = m_inputSampleRate * (1.0 / interpolatedTau); |
64 } else { | 64 } else { |
65 interpolatedTau = 0; | 65 interpolatedTau = 0; |
91 | 91 |
92 vector<double> peakProbability = YinUtil::yinProb(yinBuffer, m_threshDistr, m_yinBufferSize); | 92 vector<double> peakProbability = YinUtil::yinProb(yinBuffer, m_threshDistr, m_yinBufferSize); |
93 | 93 |
94 // basic yin output | 94 // basic yin output |
95 Yin::YinOutput yo(0,0,0); | 95 Yin::YinOutput yo(0,0,0); |
96 for (size_t iBuf = 1; iBuf < m_yinBufferSize-1; ++iBuf) | 96 for (int iBuf = 1; iBuf < int(m_yinBufferSize)-1; ++iBuf) |
97 { | 97 { |
98 if (peakProbability[iBuf] > 0) | 98 if (peakProbability[iBuf] > 0) |
99 { | 99 { |
100 double currentF0 = | 100 double currentF0 = |
101 m_inputSampleRate * (1.0 / | 101 m_inputSampleRate * (1.0 / |
155 YinUtil::cumulativeDifference(yinBuffer, m_yinBufferSize); | 155 YinUtil::cumulativeDifference(yinBuffer, m_yinBufferSize); |
156 | 156 |
157 int minPeriod = m_inputSampleRate / maxFreq; | 157 int minPeriod = m_inputSampleRate / maxFreq; |
158 int maxPeriod = m_inputSampleRate / minFreq; | 158 int maxPeriod = m_inputSampleRate / minFreq; |
159 | 159 |
160 if (minPeriod < 0 || maxPeriod > m_yinBufferSize || minPeriod > maxPeriod) { | 160 if (minPeriod < 0 || maxPeriod > int(m_yinBufferSize) || minPeriod > maxPeriod) { |
161 delete [] yinBuffer; | 161 delete [] yinBuffer; |
162 return 0.f; | 162 return 0.f; |
163 } | 163 } |
164 | 164 |
165 float bestVal = 1000; | 165 float bestVal = 1000; |