Mercurial > hg > qm-dsp
comparison dsp/onsets/DetectionFunction.cpp @ 115:f3c69325cca2 pvoc
Do actual phase unwrapping in the phase vocoder!
| author | Chris Cannam |
|---|---|
| date | Wed, 02 Oct 2013 15:05:34 +0100 |
| parents | f976d7609700 |
| children | 2020c73dc997 |
comparison
equal
deleted
inserted
replaced
| 114:f6ccde089491 | 115:f3c69325cca2 |
|---|---|
| 38 | 38 |
| 39 | 39 |
| 40 void DetectionFunction::initialise( DFConfig Config ) | 40 void DetectionFunction::initialise( DFConfig Config ) |
| 41 { | 41 { |
| 42 m_dataLength = Config.frameLength; | 42 m_dataLength = Config.frameLength; |
| 43 m_halfLength = m_dataLength/2; | 43 m_halfLength = m_dataLength/2 + 1; |
| 44 | 44 |
| 45 m_DFType = Config.DFType; | 45 m_DFType = Config.DFType; |
| 46 m_stepSize = Config.stepSize; | 46 m_stepSize = Config.stepSize; |
| 47 | 47 |
| 48 m_whiten = Config.adaptiveWhitening; | 48 m_whiten = Config.adaptiveWhitening; |
| 63 m_magPeaks = new double[ m_halfLength ]; | 63 m_magPeaks = new double[ m_halfLength ]; |
| 64 memset(m_magPeaks,0, m_halfLength*sizeof(double)); | 64 memset(m_magPeaks,0, m_halfLength*sizeof(double)); |
| 65 | 65 |
| 66 // See note in process(const double *) below | 66 // See note in process(const double *) below |
| 67 int actualLength = MathUtilities::previousPowerOfTwo(m_dataLength); | 67 int actualLength = MathUtilities::previousPowerOfTwo(m_dataLength); |
| 68 m_phaseVoc = new PhaseVocoder(actualLength); | 68 m_phaseVoc = new PhaseVocoder(actualLength, m_stepSize); |
| 69 | 69 |
| 70 m_DFWindowedFrame = new double[ m_dataLength ]; | 70 m_DFWindowedFrame = new double[ m_dataLength ]; |
| 71 m_magnitude = new double[ m_halfLength ]; | 71 m_magnitude = new double[ m_halfLength ]; |
| 72 m_thetaAngle = new double[ m_halfLength ]; | 72 m_thetaAngle = new double[ m_halfLength ]; |
| 73 m_unwrapped = new double[ m_halfLength ]; | |
| 73 | 74 |
| 74 m_window = new Window<double>(HanningWindow, m_dataLength); | 75 m_window = new Window<double>(HanningWindow, m_dataLength); |
| 75 } | 76 } |
| 76 | 77 |
| 77 void DetectionFunction::deInitialise() | 78 void DetectionFunction::deInitialise() |
| 109 m_magnitude[i] = 0; | 110 m_magnitude[i] = 0; |
| 110 m_thetaAngle[0] = 0; | 111 m_thetaAngle[0] = 0; |
| 111 } | 112 } |
| 112 } | 113 } |
| 113 | 114 |
| 114 m_phaseVoc->process(m_DFWindowedFrame, m_magnitude, m_thetaAngle); | 115 m_phaseVoc->process(m_DFWindowedFrame, m_magnitude, |
| 116 m_thetaAngle, m_unwrapped); | |
| 115 | 117 |
| 116 if (m_whiten) whiten(); | 118 if (m_whiten) whiten(); |
| 117 | 119 |
| 118 return runDF(); | 120 return runDF(); |
| 119 } | 121 } |
