From 6802f1ada9b136cf9ed1afca6245cafd3c168847 Mon Sep 17 00:00:00 2001 From: Chris Kiefer Date: Thu, 27 Sep 2012 13:12:57 +0100 Subject: maxiTimestretch efficiency / stress test --- .../UserInterfaceState.xcuserstate | Bin 0 -> 9898 bytes .../xcdebugger/Breakpoints.xcbkptlist | 18 +++++ .../xcschemes/maximilianTest.xcscheme | 85 +++++++++++++++++++++ .../xcschemes/xcschememanagement.plist | 22 ++++++ ofxMaxim/ofxMaxim/libs/maxiGrains.h | 41 ++++++---- .../project.xcworkspace/contents.xcworkspacedata | 7 ++ .../UserInterfaceState.xcuserstate | Bin 0 -> 9446 bytes .../xcschemes/maximilian_fft.xcscheme | 84 ++++++++++++++++++++ .../xcschemes/xcschememanagement.plist | 22 ++++++ 9 files changed, 266 insertions(+), 13 deletions(-) create mode 100644 maximilianTest.xcodeproj/project.xcworkspace/xcuserdata/chris.xcuserdatad/UserInterfaceState.xcuserstate create mode 100644 maximilianTest.xcodeproj/xcuserdata/chris.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist create mode 100644 maximilianTest.xcodeproj/xcuserdata/chris.xcuserdatad/xcschemes/maximilianTest.xcscheme create mode 100644 maximilianTest.xcodeproj/xcuserdata/chris.xcuserdatad/xcschemes/xcschememanagement.plist create mode 100644 ofxMaxim/ofxMaximExamples0062OSX/ofMaxim_example_fft/ofMaximilian_fft.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 ofxMaxim/ofxMaximExamples0062OSX/ofMaxim_example_fft/ofMaximilian_fft.xcodeproj/project.xcworkspace/xcuserdata/chris.xcuserdatad/UserInterfaceState.xcuserstate create mode 100644 ofxMaxim/ofxMaximExamples0062OSX/ofMaxim_example_fft/ofMaximilian_fft.xcodeproj/xcuserdata/chris.xcuserdatad/xcschemes/maximilian_fft.xcscheme create mode 100644 ofxMaxim/ofxMaximExamples0062OSX/ofMaxim_example_fft/ofMaximilian_fft.xcodeproj/xcuserdata/chris.xcuserdatad/xcschemes/xcschememanagement.plist diff --git a/maximilianTest.xcodeproj/project.xcworkspace/xcuserdata/chris.xcuserdatad/UserInterfaceState.xcuserstate b/maximilianTest.xcodeproj/project.xcworkspace/xcuserdata/chris.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..c070d2a Binary files /dev/null and b/maximilianTest.xcodeproj/project.xcworkspace/xcuserdata/chris.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/maximilianTest.xcodeproj/xcuserdata/chris.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist b/maximilianTest.xcodeproj/xcuserdata/chris.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist new file mode 100644 index 0000000..298fcca --- /dev/null +++ b/maximilianTest.xcodeproj/xcuserdata/chris.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist @@ -0,0 +1,18 @@ + + + + + + + diff --git a/maximilianTest.xcodeproj/xcuserdata/chris.xcuserdatad/xcschemes/maximilianTest.xcscheme b/maximilianTest.xcodeproj/xcuserdata/chris.xcuserdatad/xcschemes/maximilianTest.xcscheme new file mode 100644 index 0000000..d891c7f --- /dev/null +++ b/maximilianTest.xcodeproj/xcuserdata/chris.xcuserdatad/xcschemes/maximilianTest.xcscheme @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/maximilianTest.xcodeproj/xcuserdata/chris.xcuserdatad/xcschemes/xcschememanagement.plist b/maximilianTest.xcodeproj/xcuserdata/chris.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..f2cc5e9 --- /dev/null +++ b/maximilianTest.xcodeproj/xcuserdata/chris.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ + + + + + SchemeUserState + + maximilianTest.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + 8DD76F620486A84900D96B5E + + primary + + + + + diff --git a/ofxMaxim/ofxMaxim/libs/maxiGrains.h b/ofxMaxim/ofxMaxim/libs/maxiGrains.h index e3b7664..c4b2ccc 100644 --- a/ofxMaxim/ofxMaxim/libs/maxiGrains.h +++ b/ofxMaxim/ofxMaxim/libs/maxiGrains.h @@ -286,15 +286,17 @@ class maxiTimestretch { protected: double position; public: - long cycles; maxiSample *sample; maxiGrainPlayer *grainPlayer; maxiGrainWindowCache windowCache; double randomOffset; + double looper; + + maxiTimestretch(maxiSample *sample) : sample(sample) { position=0; - cycles=0; + looper = 0; grainPlayer = new maxiGrainPlayer(sample); randomOffset=0; } @@ -303,19 +305,29 @@ public: delete grainPlayer; } + double getNormalisedPosition() { + return position / (double) sample->length; + } + + double getPosition() { + return position; + } + void setPosition(double pos) { - position = pos; + position = pos * sample->length; + position = maxiMap::clamp(position, 0, sample->length-1); } + //play at a speed - double play(double speed, double grainLength, int overlaps, double posMod=0.0) { + inline double play(double speed, double grainLength, int overlaps, double posMod=0.0) { position = position + speed; - cycles++; - if (position > sample->length) position=0; - if (position < 0) position = sample->length; + looper++; + if (position > sample->length) position-= sample->length; + if (position < 0) position += sample->length; double cycleLength = grainLength * maxiSettings::sampleRate / overlaps; - double cycleMod = fmod(cycles, cycleLength + randomOffset); - if (0 == floor(cycleMod)) { + if (looper > cycleLength + randomOffset) { + looper -= (cycleLength + randomOffset); speed = (speed > 0 ? 1 : -1); maxiGrain *g = new maxiGrain(sample, max(min(1.0,(position / sample->length) + posMod),0.0), grainLength, speed, &windowCache); grainPlayer->addGrain(g); @@ -326,10 +338,10 @@ public: //provide your own position iteration - double play2(double pos, double grainLength, int overlaps) { - cycles++; + inline double play2(double pos, double grainLength, int overlaps) { + looper++; pos *= sample->length; - if (0 == floor(fmod(cycles, grainLength * maxiSettings::sampleRate / overlaps))) { + if (0 == floor(fmod(looper, grainLength * maxiSettings::sampleRate / overlaps))) { maxiGrain *g = new maxiGrain(sample, max(min(1.0,(pos / sample->length)),0.0), grainLength, 1, &windowCache); grainPlayer->addGrain(g); } @@ -397,7 +409,6 @@ public: double randomOffset; long loopStart, loopEnd, loopLength; double looper; - long cycles; maxiPitchStretch(maxiSample *sample) : sample(sample) { grainPlayer = new maxiGrainPlayer(sample); @@ -413,6 +424,10 @@ public: return position / (double) sample->length; } + double getPosition() { + return position; + } + void setPosition(double pos) { position = pos * sample->length; position = maxiMap::clamp(position, 0, sample->length-1); diff --git a/ofxMaxim/ofxMaximExamples0062OSX/ofMaxim_example_fft/ofMaximilian_fft.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/ofxMaxim/ofxMaximExamples0062OSX/ofMaxim_example_fft/ofMaximilian_fft.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..a96b15e --- /dev/null +++ b/ofxMaxim/ofxMaximExamples0062OSX/ofMaxim_example_fft/ofMaximilian_fft.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/ofxMaxim/ofxMaximExamples0062OSX/ofMaxim_example_fft/ofMaximilian_fft.xcodeproj/project.xcworkspace/xcuserdata/chris.xcuserdatad/UserInterfaceState.xcuserstate b/ofxMaxim/ofxMaximExamples0062OSX/ofMaxim_example_fft/ofMaximilian_fft.xcodeproj/project.xcworkspace/xcuserdata/chris.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..49d9781 Binary files /dev/null and b/ofxMaxim/ofxMaximExamples0062OSX/ofMaxim_example_fft/ofMaximilian_fft.xcodeproj/project.xcworkspace/xcuserdata/chris.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/ofxMaxim/ofxMaximExamples0062OSX/ofMaxim_example_fft/ofMaximilian_fft.xcodeproj/xcuserdata/chris.xcuserdatad/xcschemes/maximilian_fft.xcscheme b/ofxMaxim/ofxMaximExamples0062OSX/ofMaxim_example_fft/ofMaximilian_fft.xcodeproj/xcuserdata/chris.xcuserdatad/xcschemes/maximilian_fft.xcscheme new file mode 100644 index 0000000..35996e8 --- /dev/null +++ b/ofxMaxim/ofxMaximExamples0062OSX/ofMaxim_example_fft/ofMaximilian_fft.xcodeproj/xcuserdata/chris.xcuserdatad/xcschemes/maximilian_fft.xcscheme @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ofxMaxim/ofxMaximExamples0062OSX/ofMaxim_example_fft/ofMaximilian_fft.xcodeproj/xcuserdata/chris.xcuserdatad/xcschemes/xcschememanagement.plist b/ofxMaxim/ofxMaximExamples0062OSX/ofMaxim_example_fft/ofMaximilian_fft.xcodeproj/xcuserdata/chris.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..552925a --- /dev/null +++ b/ofxMaxim/ofxMaximExamples0062OSX/ofMaxim_example_fft/ofMaximilian_fft.xcodeproj/xcuserdata/chris.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ + + + + + SchemeUserState + + maximilian_fft.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + E4B69B5A0A3A1756003C02F2 + + primary + + + + + -- cgit v1.3