huwhill Posted September 13, 2016 Share Posted September 13, 2016 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 Quote Link to comment Share on other sites More sharing options...
Atlas007 Posted September 13, 2016 Share Posted September 13, 2016 I think the Reset() function serves that very purpose... Quote Link to comment Share on other sites More sharing options...
ski Posted September 13, 2016 Share Posted September 13, 2016 (edited) 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 September 22, 2016 by ski Quote Link to comment Share on other sites More sharing options...
huwhill Posted September 13, 2016 Author Share Posted September 13, 2016 Thanks Atlas/Sky for your answers, that's a great help, sounds like that's exactly what I need, much appreciated. Quote Link to comment Share on other sites More sharing options...
Nseruame Posted April 5, 2017 Share Posted April 5, 2017 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?? Quote Link to comment Share on other sites More sharing options...
Unheardofski Posted April 5, 2017 Share Posted April 5, 2017 just and FYI; GetTimingInfo doesn't really report transport state accurately. Or at least hasn't historically, might have been fixed since but I doubt it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.