-
Notifications
You must be signed in to change notification settings - Fork 185
/
LentPitShift.cpp
52 lines (41 loc) · 1.92 KB
/
LentPitShift.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/***************************************************/
/*! \class LentPitShift
\brief Pitch shifter effect class based on the Lent algorithm.
This class implements a pitch shifter using pitch
tracking and sample windowing and shifting.
by Francois Germain, 2009.
*/
/***************************************************/
#include "LentPitShift.h"
namespace stk {
LentPitShift::LentPitShift( StkFloat periodRatio, int tMax )
: inputFrames(0.,tMax,1), outputFrames(0.,tMax,1), ptrFrames(0), inputPtr(0), outputPtr(0.), tMax_(tMax), periodRatio_(periodRatio), zeroFrame(0., tMax, 1)
{
window = new StkFloat[2*tMax_]; // Allocation of the array for the hamming window
threshold_ = 0.1; // Default threshold for pitch tracking
dt = new StkFloat[tMax+1]; // Allocation of the euclidian distance coefficient array. The first one is never used.
cumDt = new StkFloat[tMax+1]; // Allocation of the cumulative sum array
cumDt[0] = 0.; // Initialization of the first coefficient of the cumulative sum
dpt = new StkFloat[tMax+1]; // Allocation of the pitch tracking function coefficient array
dpt[0] = 1.; // Initialization of the first coefficient of dpt which is always the same
// Initialisation of the input and output delay lines
inputLine_.setMaximumDelay( 3 * tMax_ );
// The delay is choosed such as the coefficients are not read before being finalised.
outputLine_.setMaximumDelay( 3 * tMax_ );
outputLine_.setDelay( 3 * tMax_ );
//Initialization of the delay line of pitch tracking coefficients
//coeffLine_ = new Delay[512];
//for(int i=0;i<tMax_;i++)
// coeffLine_[i] = new Delay( tMax_, tMax_ );
}
void LentPitShift :: clear()
{
inputLine_.clear();
outputLine_.clear();
}
void LentPitShift :: setShift( StkFloat shift )
{
if ( shift <= 0.0 ) periodRatio_ = 1.0;
periodRatio_ = 1.0 / shift;
}
} // stk namespace