-Added command line flag to disable time-stretch

This commit is contained in:
Harry van Haaren 2015-01-24 11:24:31 +00:00
parent 421786e7d9
commit 61a45d13e4
5 changed files with 39 additions and 10 deletions

View file

@ -50,6 +50,7 @@ int AudioBuffer::privateID = 0;
// static pointers from main
extern Gui* gui;
extern Jack* jack;
bool Jack::noTimetstretching = false;
void Jack::setup(std::string name)
{
@ -201,6 +202,8 @@ Jack::Jack( std::string name ) :
* In this case, the track's Looper instance.
**/
loopers.push_back( new Looper(i) );
loopers.back()->timestretch( !noTimetstretching );
trackOutputs.push_back( new TrackOutput(i, loopers.back() ) );
buffers.audio[Buffers::TRACK_0 + i] = new float[ buffers.nframes ];

View file

@ -58,6 +58,10 @@ class Jack
Jack(std::string name);
~Jack();
// hack to pass time stretch enable into JACK before setup
static bool noTimetstretching;
static void setup(std::string name);
void activate();

View file

@ -33,7 +33,8 @@ extern Jack* jack;
Looper::Looper(int t) :
AudioProcessor(),
TimeObserver(),
track(t)
track(t),
timeStretchEnabled( true )
{
uiUpdateConstant= jack->getSamplerate() / 30.f;
uiUpdateCounter = jack->getSamplerate() / 30.f;
@ -66,6 +67,11 @@ Looper::Looper(int t) :
crossfadeSize = 1000;
}
void Looper::timestretch( bool ts )
{
timeStretchEnabled = ts;
}
LooperClip* Looper::getClip(int scene)
{
return clips[scene];
@ -110,7 +116,8 @@ void Looper::process(unsigned int nframes, Buffers* buffers)
long actualFrames = clips[clip]->getBufferLenght();
float playSpeed = 1.0;
if ( targetFrames != 0 && actualFrames != 0 )
if ( timeStretchEnabled &&
targetFrames != 0 && actualFrames != 0 )
{
playSpeed = float(actualFrames) / targetFrames;
}
@ -122,11 +129,14 @@ void Looper::process(unsigned int nframes, Buffers* buffers)
// REFACTOR into system that is better than per sample function calls
float tmp = clips[clip]->getSample(playSpeed);
float deltaPitch = 12 * log ( playSpeed ) / log (2);
semitoneShift = -deltaPitch;
// write the pitch-shifted signal to the track buffer
pitchShift( 1, &tmp, &out[i] );
//if ( timeStretchEnabled )
{
float deltaPitch = 12 * log ( playSpeed ) / log (2);
semitoneShift = -deltaPitch;
// write the pitch-shifted signal to the track buffer
pitchShift( 1, &tmp, &out[i] );
}
}
//printf("Looper %i playing(), speed = %f\n", track, playSpeed );
@ -138,10 +148,8 @@ void Looper::process(unsigned int nframes, Buffers* buffers)
}
uiUpdateCounter += nframes;
}
}
}
void Looper::pitchShift(int count, float* input, float* output)

View file

@ -47,6 +47,9 @@ class Looper : public AudioProcessor, public TimeObserver
/// stores the framesPerBeat from TimeManager. Used to stretch audio
void setFpb(int f);
/// sets if time stretching is used or not
void timestretch( bool ts );
/// Retrieve a clip from the Looper
LooperClip* getClip(int scene);
@ -62,6 +65,8 @@ class Looper : public AudioProcessor, public TimeObserver
int fpb;
bool timeStretchEnabled;
//vector<float> tmpRecordBuffer;
LooperClip* clips[10];

View file

@ -63,13 +63,19 @@ int main(int argc, char** argv)
LUPPP_NOTE("Git: %s", GIT_VERSION );
bool runTests = false;
if ( runTests ){} // remove unused warning if not built with BUILD_TESTS
bool noTimetstretching = false;
// remove unused warning if not built with BUILD_TESTS
if ( runTests );
if ( noTimetstretching );
for(int i = 0; i < argc; i++)
{
if ( strcmp(argv[i], "-test" ) == 0 ) {
runTests = true;
}
else if ( strcmp(argv[i], "-no-ts" ) == 0 ) {
noTimetstretching = true;
}
else if ( i != 0 ) // don't try load with the program name!
{
// assume filename, try load it
@ -99,6 +105,8 @@ int main(int argc, char** argv)
// setup the testing Gui / JACK: Jack first, then GUI
gui = new Gui( argv[0] );
Jack::noTimetstretching = noTimetstretching;
Jack::setup("LupppTEST");
// test offline functionality
@ -131,6 +139,7 @@ int main(int argc, char** argv)
}
else
{
Jack::noTimetstretching = noTimetstretching;
Jack::setup("Luppp");
jack->activate();
}