fix up file renaming code a little bit
[ArdourMidi.git] / libs / rubberband / src / StretcherChannelData.h
blobb56a6e07dc6262e1b53384129825b89b69a37fb8
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
3 /*
4 Rubber Band
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"
20 #include <set>
22 //#define EXPERIMENT 1
24 namespace RubberBand
27 class Resampler;
29 class RubberBandStretcher::Impl::ChannelData
31 public:
32 /**
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);
46 /**
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);
60 ~ChannelData();
62 /**
63 * Reset buffers
65 void reset();
67 /**
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);
75 /**
76 * Set the outbufSize for the channel data. Reallocation will
77 * occur.
79 void setOutbufSize(size_t outbufSize);
81 /**
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;
90 double *mag;
91 double *phase;
93 double *prevPhase;
94 double *prevError;
95 double *unwrappedPhase;
98 size_t *freqPeak;
100 float *accumulator;
101 size_t accumulatorFill;
102 float *windowAccumulator;
104 float *fltbuf;
105 double *dblbuf; // owned by FFT object, only used for time domain FFT i/o
106 double *envelope; // for cepstral formant shift
107 bool unchanged;
109 size_t prevIncrement; // only used in RT mode
111 size_t chunkCount;
112 size_t inCount;
113 long inputSize; // set only after known (when data ended); -1 previously
114 size_t outCount;
116 bool draining;
117 bool outputComplete;
119 FFT *fft;
120 std::map<size_t, FFT *> ffts;
122 Resampler *resampler;
123 float *resamplebuf;
124 size_t resamplebufSize;
126 int oversample;
128 private:
129 void construct(const std::set<size_t> &windowSizes,
130 size_t initialWindowSize, size_t outbufSize);
135 #endif