Mercurial > hg > sonic-visualiser
comparison audioio/IntegerTimeStretcher.h @ 12:ee967635c728
* Some work on making the time stretcher squash as well as stretch
author | Chris Cannam |
---|---|
date | Tue, 12 Sep 2006 16:43:00 +0000 |
parents | cd5d7ff8ef38 |
children | 00ed645f4175 |
comparison
equal
deleted
inserted
replaced
11:0dbd08e365ce | 12:ee967635c728 |
---|---|
32 */ | 32 */ |
33 | 33 |
34 class IntegerTimeStretcher | 34 class IntegerTimeStretcher |
35 { | 35 { |
36 public: | 36 public: |
37 IntegerTimeStretcher(size_t ratio, | 37 IntegerTimeStretcher(float ratio, |
38 size_t maxProcessInputBlockSize, | 38 size_t maxProcessInputBlockSize, |
39 size_t inputIncrement = 64, | 39 size_t inputIncrement = 64, |
40 size_t windowSize = 2048, | 40 size_t windowSize = 2048, |
41 WindowType windowType = HanningWindow); | 41 WindowType windowType = HanningWindow); |
42 virtual ~IntegerTimeStretcher(); | 42 virtual ~IntegerTimeStretcher(); |
43 | 43 |
44 /** | |
45 * Process a block. The input array contains the given number of | |
46 * samples; the output has enough space for samples * m_ratio. | |
47 */ | |
44 void process(float *input, float *output, size_t samples); | 48 void process(float *input, float *output, size_t samples); |
45 | 49 |
46 /** | 50 /** |
47 * Get the hop size for input. Smaller values may produce better | 51 * Get the hop size for input. Smaller values may produce better |
48 * results, at a cost in processing time. Larger values are | 52 * results, at a cost in processing time. Larger values are |
61 /** | 65 /** |
62 * Get the window type. The default is a Hanning window. | 66 * Get the window type. The default is a Hanning window. |
63 */ | 67 */ |
64 WindowType getWindowType() const { return m_window->getType(); } | 68 WindowType getWindowType() const { return m_window->getType(); } |
65 | 69 |
66 size_t getRatio() const { return m_ratio; } | 70 float getRatio() const { return m_ratio; } |
67 size_t getOutputIncrement() const { return getInputIncrement() * getRatio(); } | 71 size_t getOutputIncrement() const { return getInputIncrement() * getRatio(); } |
68 size_t getProcessingLatency() const; | 72 size_t getProcessingLatency() const; |
69 | 73 |
70 protected: | 74 protected: |
71 void processBlock(float *in, float *out); | 75 void processBlock(float *in, float *out); |
72 | 76 |
73 size_t m_ratio; | 77 float m_ratio; |
74 size_t m_n1; | 78 size_t m_n1; |
75 size_t m_n2; | 79 size_t m_n2; |
76 size_t m_wlen; | 80 size_t m_wlen; |
77 Window<float> *m_window; | 81 Window<float> *m_window; |
78 | 82 |
79 fftwf_complex *m_time; | 83 fftwf_complex *m_time; |
80 fftwf_complex *m_freq; | 84 fftwf_complex *m_freq; |
81 float *m_dbuf; | 85 float *m_dbuf; |
86 float *m_prevPhase; | |
87 float *m_prevAdjustedPhase; | |
82 | 88 |
83 fftwf_plan m_plan; | 89 fftwf_plan m_plan; |
84 fftwf_plan m_iplan; | 90 fftwf_plan m_iplan; |
85 | 91 |
86 RingBuffer<float> m_inbuf; | 92 RingBuffer<float> m_inbuf; |