1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
5 An audio time-stretching and pitch-shifting library.
6 Copyright 2007-2008 Chris Cannam.
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of the
11 License, or (at your option) any later version. See the file
12 COPYING included with this distribution for more information.
15 #ifndef _RUBBERBAND_STRETCHERCHANNELDATA_H_
16 #define _RUBBERBAND_STRETCHERCHANNELDATA_H_
18 #include "StretcherImpl.h"
22 //#define EXPERIMENT 1
29 class RubberBandStretcher::Impl::ChannelData
33 * Construct a ChannelData structure.
35 * The window size passed in here is the size for the FFT
36 * calculation, and most of the buffer sizes also depend on
37 * it. In practice it is always a power of two and except for
38 * very extreme stretches is always either 1024, 2048 or 4096.
40 * The outbuf size depends on other factors as well, including
41 * the pitch scale factor and any maximum processing block
42 * size specified by the user of the code.
44 ChannelData(size_t windowSize, int overSample, size_t outbufSize);
47 * Construct a ChannelData structure that can process at
48 * different FFT sizes without requiring reallocation when the
49 * size changes. The size can subsequently be changed with a
50 * call to setWindowSize. Reallocation will only be necessary
51 * if setWindowSize is called with a value not equal to one of
52 * those passed in to the constructor.
54 * The outbufSize should be the maximum possible outbufSize to
55 * avoid reallocation, which will happen if setOutbufSize is
56 * called subsequently.
58 ChannelData(const std::set<size_t> &windowSizes,
59 int overSample, size_t initialWindowSize, size_t outbufSize);
68 * Set the FFT and buffer sizes from the given processing
69 * window size. If this ChannelData was constructed with a set
70 * of window sizes and the given window size here was among
71 * them, no reallocation will be required.
73 void setWindowSize(size_t windowSize);
76 * Set the outbufSize for the channel data. Reallocation will
79 void setOutbufSize(size_t outbufSize);
82 * Set the resampler buffer size. Default if not called is no
83 * buffer allocated at all.
85 void setResampleBufSize(size_t resamplebufSize);
87 RingBuffer<float> *inbuf;
88 RingBuffer<float> *outbuf;
95 double *unwrappedPhase;
101 size_t accumulatorFill;
102 float *windowAccumulator;
105 double *dblbuf; // owned by FFT object, only used for time domain FFT i/o
106 double *envelope; // for cepstral formant shift
109 size_t prevIncrement; // only used in RT mode
113 long inputSize; // set only after known (when data ended); -1 previously
120 std::map<size_t, FFT *> ffts;
122 Resampler *resampler;
124 size_t resamplebufSize;
129 void construct(const std::set<size_t> &windowSizes,
130 size_t initialWindowSize, size_t outbufSize);