diff options
Diffstat (limited to 'ofxMaxim')
5 files changed, 141 insertions, 13 deletions
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<F> 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<double>(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<F> *g = new maxiGrain<F>(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<F> *g = new maxiGrain<F>(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<double>(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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Workspace + version = "1.0"> + <FileRef + location = "self:ofMaximilian_fft.xcodeproj"> + </FileRef> +</Workspace> 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 Binary files differnew file mode 100644 index 0000000..49d9781 --- /dev/null +++ b/ofxMaxim/ofxMaximExamples0062OSX/ofMaxim_example_fft/ofMaximilian_fft.xcodeproj/project.xcworkspace/xcuserdata/chris.xcuserdatad/UserInterfaceState.xcuserstate 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Scheme + version = "1.3"> + <BuildAction + parallelizeBuildables = "YES" + buildImplicitDependencies = "YES"> + <BuildActionEntries> + <BuildActionEntry + buildForTesting = "YES" + buildForRunning = "YES" + buildForProfiling = "YES" + buildForArchiving = "YES" + buildForAnalyzing = "YES"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2" + BuildableName = "maximilian_fft.app" + BlueprintName = "maximilian_fft" + ReferencedContainer = "container:ofMaximilian_fft.xcodeproj"> + </BuildableReference> + </BuildActionEntry> + </BuildActionEntries> + </BuildAction> + <TestAction + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" + shouldUseLaunchSchemeArgsEnv = "YES" + buildConfiguration = "Debug"> + <Testables> + </Testables> + <MacroExpansion> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2" + BuildableName = "maximilian_fft.app" + BlueprintName = "maximilian_fft" + ReferencedContainer = "container:ofMaximilian_fft.xcodeproj"> + </BuildableReference> + </MacroExpansion> + </TestAction> + <LaunchAction + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" + launchStyle = "0" + useCustomWorkingDirectory = "NO" + buildConfiguration = "Debug" + debugDocumentVersioning = "YES" + allowLocationSimulation = "YES"> + <BuildableProductRunnable> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2" + BuildableName = "maximilian_fft.app" + BlueprintName = "maximilian_fft" + ReferencedContainer = "container:ofMaximilian_fft.xcodeproj"> + </BuildableReference> + </BuildableProductRunnable> + <AdditionalOptions> + </AdditionalOptions> + </LaunchAction> + <ProfileAction + shouldUseLaunchSchemeArgsEnv = "YES" + savedToolIdentifier = "" + useCustomWorkingDirectory = "NO" + buildConfiguration = "Release" + debugDocumentVersioning = "YES"> + <BuildableProductRunnable> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2" + BuildableName = "maximilian_fft.app" + BlueprintName = "maximilian_fft" + ReferencedContainer = "container:ofMaximilian_fft.xcodeproj"> + </BuildableReference> + </BuildableProductRunnable> + </ProfileAction> + <AnalyzeAction + buildConfiguration = "Debug"> + </AnalyzeAction> + <ArchiveAction + buildConfiguration = "Release" + revealArchiveInOrganizer = "YES"> + </ArchiveAction> +</Scheme> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>SchemeUserState</key> + <dict> + <key>maximilian_fft.xcscheme</key> + <dict> + <key>orderHint</key> + <integer>0</integer> + </dict> + </dict> + <key>SuppressBuildableAutocreation</key> + <dict> + <key>E4B69B5A0A3A1756003C02F2</key> + <dict> + <key>primary</key> + <true/> + </dict> + </dict> +</dict> +</plist> |
