Mercurial > hg > sonic-visualiser
comparison audioio/PhaseVocoderTimeStretcher.h @ 15:cc566264c935
* timestretcher improvements -- simplify API (it can calculate its own
processing block sizes etc)
| author | Chris Cannam |
|---|---|
| date | Wed, 13 Sep 2006 11:56:44 +0000 |
| parents | 085f34c73939 |
| children | 3715efc38f95 |
comparison
equal
deleted
inserted
replaced
| 14:085f34c73939 | 15:cc566264c935 |
|---|---|
| 31 */ | 31 */ |
| 32 | 32 |
| 33 class PhaseVocoderTimeStretcher | 33 class PhaseVocoderTimeStretcher |
| 34 { | 34 { |
| 35 public: | 35 public: |
| 36 PhaseVocoderTimeStretcher(float ratio, | 36 PhaseVocoderTimeStretcher(float ratio, size_t maxProcessInputBlockSize); |
| 37 size_t maxProcessInputBlockSize, | |
| 38 size_t inputIncrement = 64, | |
| 39 size_t windowSize = 2048, | |
| 40 WindowType windowType = HanningWindow); | |
| 41 virtual ~PhaseVocoderTimeStretcher(); | 37 virtual ~PhaseVocoderTimeStretcher(); |
| 42 | 38 |
| 43 /** | 39 /** |
| 44 * Process a block. The input array contains the given number of | 40 * Process a block. The input array contains the given number of |
| 45 * samples; the output has enough space for samples * m_ratio. | 41 * samples; the output must have space for lrintf(samples * m_ratio). |
| 46 */ | 42 */ |
| 47 void process(float *input, float *output, size_t samples); | 43 void process(float *input, float *output, size_t samples); |
| 48 | 44 |
| 49 /** | 45 /** |
| 50 * Get the hop size for input. Smaller values may produce better | 46 * Get the hop size for input. |
| 51 * results, at a cost in processing time. Larger values are | |
| 52 * faster but increase the likelihood of echo-like effects. The | |
| 53 * default is 64, which is usually pretty good, though heavy on | |
| 54 * processor power. | |
| 55 */ | 47 */ |
| 56 size_t getInputIncrement() const { return m_n1; } | 48 size_t getInputIncrement() const { return m_n1; } |
| 57 | 49 |
| 58 /** | 50 /** |
| 59 * Get the window size for FFT processing. Must be larger than | 51 * Get the hop size for output. |
| 60 * the input and output increments. The default is 2048. | 52 */ |
| 53 size_t getOutputIncrement() const { return getInputIncrement() * getRatio(); } | |
| 54 | |
| 55 /** | |
| 56 * Get the window size for FFT processing. | |
| 61 */ | 57 */ |
| 62 size_t getWindowSize() const { return m_wlen; } | 58 size_t getWindowSize() const { return m_wlen; } |
| 63 | 59 |
| 64 /** | 60 /** |
| 65 * Get the window type. The default is a Hanning window. | 61 * Get the window type. |
| 66 */ | 62 */ |
| 67 WindowType getWindowType() const { return m_window->getType(); } | 63 WindowType getWindowType() const { return m_window->getType(); } |
| 68 | 64 |
| 65 /** | |
| 66 * Get the stretch ratio set in the constructor. | |
| 67 */ | |
| 69 float getRatio() const { return m_ratio; } | 68 float getRatio() const { return m_ratio; } |
| 70 size_t getOutputIncrement() const { return getInputIncrement() * getRatio(); } | 69 |
| 70 /** | |
| 71 * Get the latency added by the time stretcher, in sample frames. | |
| 72 */ | |
| 71 size_t getProcessingLatency() const; | 73 size_t getProcessingLatency() const; |
| 72 | 74 |
| 73 protected: | 75 protected: |
| 74 /** | 76 /** |
| 75 * Process a single phase vocoder frame. | 77 * Process a single phase vocoder frame. |
| 99 float *m_prevAdjustedPhase; | 101 float *m_prevAdjustedPhase; |
| 100 | 102 |
| 101 fftwf_plan m_plan; | 103 fftwf_plan m_plan; |
| 102 fftwf_plan m_iplan; | 104 fftwf_plan m_iplan; |
| 103 | 105 |
| 104 RingBuffer<float> m_inbuf; | 106 RingBuffer<float> *m_inbuf; |
| 105 RingBuffer<float> m_outbuf; | 107 RingBuffer<float> *m_outbuf; |
| 106 float *m_mashbuf; | 108 float *m_mashbuf; |
| 107 float *m_modulationbuf; | 109 float *m_modulationbuf; |
| 108 }; | 110 }; |
| 109 | 111 |
| 110 #endif | 112 #endif |
