Jump to content

Scripter code


huwhill

Recommended Posts

I have a Scripter script that generates pitch patterns.  The problem is every time I stop and re-start the playhead, Scripter continues to generate output from where it was stopped (i.e. mid-pattern), even if the playhead is at the beginning of my arrangement.  Whereas I'd like the generated patterns to start from the beginning of their cycle every time I press play, so that every time I press play this triggers Scripter to start generating a new pattern from the beginning.  Is there a simple piece of code I need to tweak to do this?

 

Many thanks.

 

H

Link to comment
Share on other sites

Yes, you can use Reset() to reset variables.

 

You can also specifically detect when the transport is started and stopped, but it requires a more complicated approach. 

 

Here's a typical example of how to implement Reset( )....

 

Reset( ) // start your code by calling this function 

 

// Next come Global Variables

var firstPitch = 36;

// etc...

 

function HandleMIDI..... // goes here

// within this code, firstPitch gets changed as you output your pattern

// end of HandleMIDI code

 

function Reset( ) {    // declare this function here, which is coded to reset the variable

firstPitch = 36;

}

Edited by ski
Link to comment
Share on other sites

  • 6 months later...
You can also specifically detect when the transport is started and stopped, but it requires a more complicated approach. 

Hey Ski, I'd like to find out more about that if you've got the time. I'm finding Reset to be a very strangely implemented callback ( or I'm just not getting it).

Reset() is invoked when Scripter is bypassed

Reset() is invoked when playback starts

EDIT: 

Reset() is also invoked when playback starts and Scripter is bypassed

... yet there is no 'default state' as a script can be run when Scripter is either bypassed or not and there is no global scope condition to refer to that I can see.

 

Are you using a variable to set an initial state then updating it with each call to Reset or correlating it with TimingInfo??

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...