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 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"
27 class RubberBandStretcher::Impl::ChannelData
31 * Construct a ChannelData structure.
33 * The window size passed in here is the size for the FFT
34 * calculation, and most of the buffer sizes also depend on
35 * it. In practice it is always a power of two and except for
36 * very extreme stretches is always either 1024, 2048 or 4096.
38 * The outbuf size depends on other factors as well, including
39 * the pitch scale factor and any maximum processing block
40 * size specified by the user of the code.
42 ChannelData(size_t windowSize, size_t outbufSize);
45 * Construct a ChannelData structure that can process at
46 * different FFT sizes without requiring reallocation when the
47 * size changes. The size can subsequently be changed with a
48 * call to setWindowSize. Reallocation will only be necessary
49 * if setWindowSize is called with a value not equal to one of
50 * those passed in to the constructor.
52 * The outbufSize should be the maximum possible outbufSize to
53 * avoid reallocation, which will happen if setOutbufSize is
54 * called subsequently.
56 ChannelData(const std::set<size_t> &windowSizes,
57 size_t initialWindowSize, size_t outbufSize);
66 * Set the FFT and buffer sizes from the given processing
67 * window size. If this ChannelData was constructed with a set
68 * of window sizes and the given window size here was among
69 * them, no reallocation will be required.
71 void setWindowSize(size_t windowSize);
74 * Set the outbufSize for the channel data. Reallocation will
77 void setOutbufSize(size_t outbufSize);
79 RingBuffer<float> *inbuf;
80 RingBuffer<float> *outbuf;
86 double *unwrappedPhase;
91 size_t accumulatorFill;
92 float *windowAccumulator;
95 double *dblbuf; // owned by FFT object, only used for time domain FFT i/o
97 size_t prevIncrement; // only used in RT mode
101 long inputSize; // set only after known (when data ended); -1 previously
108 std::map<size_t, FFT *> ffts;
110 Resampler *resampler;
112 size_t resamplebufSize;
115 void construct(const std::set<size_t> &windowSizes,
116 size_t initialWindowSize, size_t outbufSize);