comparison audioio/PhaseVocoderTimeStretcher.h @ 31:37af203dbd15

* Buffer size fixes in the time stretcher, to avoid running out of input data for large or small ratios
author Chris Cannam
date Thu, 21 Sep 2006 09:43:41 +0000
parents d88d117e0c34
children e3b32dc5180b
comparison
equal deleted inserted replaced
30:56e1d4242bb4 31:37af203dbd15
41 public: 41 public:
42 PhaseVocoderTimeStretcher(size_t sampleRate, 42 PhaseVocoderTimeStretcher(size_t sampleRate,
43 size_t channels, 43 size_t channels,
44 float ratio, 44 float ratio,
45 bool sharpen, 45 bool sharpen,
46 size_t maxProcessInputBlockSize); 46 size_t maxOutputBlockSize);
47 virtual ~PhaseVocoderTimeStretcher(); 47 virtual ~PhaseVocoderTimeStretcher();
48
49 /**
50 * Process a block. The input array contains the given number of
51 * samples (on each channel); the output must have space for
52 * lrintf(samples * m_ratio).
53 *
54 * This function isn't really recommended, and I may yet remove it.
55 * It should work correctly for some ratios, e.g. small powers of
56 * two, if transient sharpening is off. For other ratios it may
57 * drop samples -- use putInput in a loop followed by getOutput
58 * (when getAvailableOutputSamples reports enough) instead.
59 *
60 * Do not mix process calls with putInput/getOutput calls.
61 */
62 void process(float **input, float **output, size_t samples);
63 48
64 /** 49 /**
65 * Return the number of samples that would need to be added via 50 * Return the number of samples that would need to be added via
66 * putInput in order to provoke the time stretcher into doing some 51 * putInput in order to provoke the time stretcher into doing some
67 * time stretching and making more output samples available. 52 * time stretching and making more output samples available.
68 * This will be an estimate, if transient sharpening is on. 53 * This will be an estimate, if transient sharpening is on; the
54 * caller may need to do the put/get/test cycle more than once.
69 */ 55 */
70 size_t getRequiredInputSamples() const; 56 size_t getRequiredInputSamples() const;
71 57
72 /** 58 /**
73 * Put (and possibly process) a given number of input samples. 59 * Put (and possibly process) a given number of input samples.
74 * Number must not exceed the maxProcessInputBlockSize passed to 60 * Number should usually equal the value returned from
75 * constructor. 61 * getRequiredInputSamples().
76 */ 62 */
77 void putInput(float **input, size_t samples); 63 void putInput(float **input, size_t samples);
78 64
79 /** 65 /**
80 * Get the number of processed samples ready for reading. 66 * Get the number of processed samples ready for reading.
157 void calculateParameters(); 143 void calculateParameters();
158 void cleanup(); 144 void cleanup();
159 145
160 size_t m_sampleRate; 146 size_t m_sampleRate;
161 size_t m_channels; 147 size_t m_channels;
162 size_t m_maxProcessInputBlockSize; 148 size_t m_maxOutputBlockSize;
163 float m_ratio; 149 float m_ratio;
164 bool m_sharpen; 150 bool m_sharpen;
165 size_t m_n1; 151 size_t m_n1;
166 size_t m_n2; 152 size_t m_n2;
167 size_t m_wlen; 153 size_t m_wlen;