comparison audioio/PhaseVocoderTimeStretcher.h @ 22:80126455d169

* add samplerate parameter to timestretcher (not properly used yet), and update credits
author Chris Cannam
date Fri, 15 Sep 2006 13:35:37 +0000
parents 7da85e0b85e9
children a2ad974b0c8c
comparison
equal deleted inserted replaced
21:7da85e0b85e9 22:80126455d169
21 21
22 #include <fftw3.h> 22 #include <fftw3.h>
23 23
24 /** 24 /**
25 * A time stretcher that alters the performance speed of audio, 25 * A time stretcher that alters the performance speed of audio,
26 * preserving pitch. This uses the simple phase vocoder technique 26 * preserving pitch.
27 * from DAFX pp275-276, adding a block-based stream oriented API.
28 * 27 *
29 * Causes significant transient smearing, but sounds good for steady 28 * This is based on the straightforward phase vocoder with phase
30 * notes and is generally predictable. 29 * unwrapping (as in e.g. the DAFX book pp275-), with optional
30 * percussive transient detection to avoid smearing percussive notes
31 * and resynchronise phases, and adding a stream API for real-time
32 * use. Principles and methods from Chris Duxbury, AES 2002 and 2004
33 * thesis; Emmanuel Ravelli, DAFX 2005; Dan Barry, ISSC 2005 on
34 * percussion detection; code by Chris Cannam.
31 */ 35 */
32 36
33 class PhaseVocoderTimeStretcher 37 class PhaseVocoderTimeStretcher
34 { 38 {
35 public: 39 public:
36 PhaseVocoderTimeStretcher(size_t channels, 40 PhaseVocoderTimeStretcher(size_t sampleRate,
41 size_t channels,
37 float ratio, 42 float ratio,
38 bool sharpen, 43 bool sharpen,
39 size_t maxProcessInputBlockSize); 44 size_t maxProcessInputBlockSize);
40 virtual ~PhaseVocoderTimeStretcher(); 45 virtual ~PhaseVocoderTimeStretcher();
41 46
129 bool isTransient(); // operates on m_freq[0..m_channels-1] 134 bool isTransient(); // operates on m_freq[0..m_channels-1]
130 135
131 void synthesiseBlock(size_t channel, float *out, float *modulation, 136 void synthesiseBlock(size_t channel, float *out, float *modulation,
132 size_t lastStep); 137 size_t lastStep);
133 138
139 size_t m_sampleRate;
134 size_t m_channels; 140 size_t m_channels;
135 float m_ratio; 141 float m_ratio;
136 bool m_sharpen; 142 bool m_sharpen;
137 size_t m_n1; 143 size_t m_n1;
138 size_t m_n2; 144 size_t m_n2;
147 float **m_prevPhase; 153 float **m_prevPhase;
148 float **m_prevAdjustedPhase; 154 float **m_prevAdjustedPhase;
149 155
150 float *m_prevTransientMag; 156 float *m_prevTransientMag;
151 int m_prevTransientScore; 157 int m_prevTransientScore;
158 int m_transientThreshold;
152 bool m_prevTransient; 159 bool m_prevTransient;
153 160
154 float *m_tempbuf; 161 float *m_tempbuf;
155 float **m_time; 162 float **m_time;
156 fftwf_complex **m_freq; 163 fftwf_complex **m_freq;