Circular Labs Forums  

Go Back   Circular Labs Forums > Mobius Discussion > Scripting

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-09-2012, 04:22 AM
glynndub's Avatar
glynndub glynndub is offline
Senior Member
 
Join Date: Oct 2009
Location: Sunshine Coast Queensland Australia
Posts: 148
Send a message via MSN to glynndub
Default Continuously scroll back & forth

I’m using 3 loops per track and I would like the feature of continuously scrolling back and forth between loops 1 and 2 until I give it a key press to stop and return to loop 1?
So far I’ve achieved…
Code:
!name Continuos-Scroll-L1-L2
# If on loops 2 or 3 then go to loop 1
if 	LoopNumber = 2
	for *
	loop 1
next
elseif	LoopNumber = 3
	for *
	loop 1
next
endif
wait last
# If on loop 1 go to loop2 or if on loop 2 go to loop 1
if 	LoopNumber = 1
wait last
wait loop
	for *
	loop 2
next
endif
wait last
if	LoopNumber = 2
wait last
wait loop
	for *
	loop 1
next
endif
end
But how would I keep L1 to L2 scrolling (part in blue text) until a key press to stop?
__________________
Be Lucky In Life... Glynn

Cakewalk Sonar Producer 8.5.3, and Sonar X2a, HP pavilion dv6 3031TX, Win7-64-bit,
2x Behringer FCB1010, Edirol UA-25, Edirol Quad UA-55, Edirol PCR-500, Rode NT1A, KRK Rokit 8 Monitors, PODxt, AKG520 Cans, too many guitars to list and a Dog
Reply With Quote
  #2  
Old 06-09-2012, 09:12 PM
Jeff's Avatar
Jeff Jeff is offline
Benevolent Dictator
 
Join Date: Oct 2009
Location: Austin, Texas
Posts: 715
Default

First let's talk about a general script technique I usualy call Modal Scripts. When you run the script
the first time it does something and then enters a "mode" by setting a global variable. When you run the
script again we cancel the mode by clearing the global variable. Here's a basic example:

Code:
!name Modal Example

Variable global inMode false

if inMode
   Message Leaving Mode
   set inMode false
else
   Message Entering Mode
   set inMode true
endif
While we're in the mode the script can be looping on something. Here is an example close to
what you want, we'll continuously switch between loop 1 and loop 2.

Code:
!name Loop 1/2 Cycle Mode

Variable global inMode false

if inMode
   set inMode false
else
   set inMode true

   while inMode
      wait loop
      if loopNumber == 1
         loop2
      else
         loop1
      endif
   next
endif
The first time you run this inMode is false so we start running the else block. We set inMode to true then enter a while loop that will continue until something sets inMode to false. Within the loop we wait until the end of whatever loop we're in and then go to either loop1 or loop 1. inMode is a global variable so any script can set it to false, but in this case we'll just run the same script a second time. The script sees that inMode is true so it sets it to false.

It's kind of hard to explain how this works without dragging in some programming concepts. When you run a script is like starting an application or more accurately starting a "thread" within an application. You have many scripts running at the same time and they can communicate with each other with global variables.

Extending this to loop swap on all tracks is more complicated because the tracks are not necessarily the same length.
If you are absolutely sure they are the same size you can do this:

Code:
!name Loop 1/2 Cycle Mode All

Variable global inMode false

if inMode
   set inMode false
else
   set inMode true

   while inMode
      wait loop
      for *
        if loopNumber == 1
           loop2
        else
           loop1
        endif
      next
   next
endif
The track you are in when the loop runs for the first time becomes the "timer" track, we will use the length of the loops in this track to determine when to switch.

If the tracks loops can be of different lengths, it is more complicated. We can't use "Wait loop" in a single script because we need to wait different amounts of time in each track. For this to work we can't run one script we have to run parallel scripts in each track. One way to do that is to assign all tracks to a group, then bind a trigger to the script giving it a scope of that track group. For example give all tracks group A and in the binding window select A in the scope selector. Now when you press the trigger, it will run one copy of the script in each track in the group. The problem now is the global variable. There is only one set of global variables, you need to have a different one for each track. To solve this change the variable declation to be a track variable:

Code:
Variable track inMode false
So the final script that supports tracks of variable size is:

Code:
!name Loop 1/2 Cycle

Variable track inMode false

if inMode
   set inMode false
else
   set inMode true

   while inMode
      wait loop
      if loopNumber == 1
         loop2
      else
         loop1
      next
   next
endif
Which is just like the first example except for using a track variable. Then you use a track group binding to run it. There are several other technicques to accomplish the same thing but this is the easiest.

Jeff
Reply With Quote
  #3  
Old 06-11-2012, 12:43 AM
glynndub's Avatar
glynndub glynndub is offline
Senior Member
 
Join Date: Oct 2009
Location: Sunshine Coast Queensland Australia
Posts: 148
Send a message via MSN to glynndub
Default

Jeff, firstly a big thankyou for the effort you have put into my recent questions, and I get the concept of Modal Scripts. Real Cool!

With regards to script, “Loop 1/2 Cycle Mode All” I get the following results…
  • If loops have been previously manipulated using “Instant multiply/Instant divide”, then red outline appears on next loop but Mobius fails to move to next loop.
  • If I trigger “Global Pause” while script is running all loops stop, re-triggering “Global Pause” causes Mobius to ether freezes or Crashes.
  • When running script without using “Instant multiply/Instant divide”, tracks to left of “Active track” wait an extra loop before changing.
e.g. If on T5-L1 and run script; T5,T6,T7,T8 will move to loop 2 and T1,T2,T3,T4 will stay on loop 1 and wait extra loop.
e.g. If on T6-L1 and run script; T6,T7,T8 will move to loop 2 and T1,T2,T3,T4,T5 will stay on loop 1 and wait extra loop.
The causation would seems to be “track irregular lengths” but can this be so if…
  • Empty Loop Action = Copy Timing
  • Empty Track Action = Copy Timing
  • All additional tracks are derived from the original track, using the script concept below?
Code:
Variable cyclesIn3
for 3
set cyclesIn3 cycleCount
wait last
next
		for 1
		InstantMultiply cyclesIn3
next
		for 2
		InstantMultiply cyclesIn3
next
		for 4
		InstantMultiply cyclesIn3
Next
……………..and so on till T8
Also if “track irregular lengths” were the causation, why would results vary only to tracks left of active track?

Because they’re no tracks left of track 1, a workaround is to add at start of your script…
Variable saveTrack track
Track 1

To some degree this is a gremlin remover, but with more testing I find this only works if loops 1& 2 are both even numbered. That is to say…

Loop 1 = 2 cycles and loop 2 = 2 cycles it works
Loop 1 = 3 cycles and loop 2 = 3 cycles it works
Loop 1 = 2 cycles and loop 2 = 3 cycles Loops out of sync left of active track.
Loop 1 = 3 cycles and loop 2 = 5 cycles Loops out of sync left of active track.


With regards to script, “Loop 1/2 Cycle” I get the following results…
After assigning all tracks to a group-A, and setting scope selector, script Works unless…
  • Project has been previously manipulated using “Instant multiply/Instant divide”, as stated above.
  • Only if loops 1&2 are both even numbered, as stated above.
  • Also freezes/crashes, if “Global Pause” triggered while script is running, as stated above.

Jeff, I would really like to get to the bottom of this out of sync left of active track problem. I have encountered it before and is holding me back perfecting some other script concepts.
__________________
Be Lucky In Life... Glynn

Cakewalk Sonar Producer 8.5.3, and Sonar X2a, HP pavilion dv6 3031TX, Win7-64-bit,
2x Behringer FCB1010, Edirol UA-25, Edirol Quad UA-55, Edirol PCR-500, Rode NT1A, KRK Rokit 8 Monitors, PODxt, AKG520 Cans, too many guitars to list and a Dog
Reply With Quote
  #4  
Old 06-18-2012, 08:44 AM
glynndub's Avatar
glynndub glynndub is offline
Senior Member
 
Join Date: Oct 2009
Location: Sunshine Coast Queensland Australia
Posts: 148
Send a message via MSN to glynndub
Default

Dead thread, awh!
Just when it was getting interesting too! Sigh,

Have you ever seen a dalek turning left or right on full lock?
Wow they know how to loop!
__________________
Be Lucky In Life... Glynn

Cakewalk Sonar Producer 8.5.3, and Sonar X2a, HP pavilion dv6 3031TX, Win7-64-bit,
2x Behringer FCB1010, Edirol UA-25, Edirol Quad UA-55, Edirol PCR-500, Rode NT1A, KRK Rokit 8 Monitors, PODxt, AKG520 Cans, too many guitars to list and a Dog
Reply With Quote
  #5  
Old 07-15-2012, 02:16 AM
glynndub's Avatar
glynndub glynndub is offline
Senior Member
 
Join Date: Oct 2009
Location: Sunshine Coast Queensland Australia
Posts: 148
Send a message via MSN to glynndub
Question This has to be a bug!

This has to be a bug!

Test Conditions
In tracks 1 to 8 / Loop 1, I loaded the same wave 908 KB in size
In tracks 1 to 8 / Loop 2, I loaded the same wave 679 KB in size
Then I run the following script…
Code:
name Loops 1-2-Cycle-Mode
Variable global inMode false
if inMode
   set inMode false
else
   set inMode true

   while inMode
      wait loop
      for *
      if loopNumber = 1
         loop2
      else
         loop1
      endif
   next
 next
endif
Results
Tracks to left of active track wait an additional cycle before advancing to next loop
__________________
Be Lucky In Life... Glynn

Cakewalk Sonar Producer 8.5.3, and Sonar X2a, HP pavilion dv6 3031TX, Win7-64-bit,
2x Behringer FCB1010, Edirol UA-25, Edirol Quad UA-55, Edirol PCR-500, Rode NT1A, KRK Rokit 8 Monitors, PODxt, AKG520 Cans, too many guitars to list and a Dog
Reply With Quote
  #6  
Old 07-26-2012, 05:04 AM
glynndub's Avatar
glynndub glynndub is offline
Senior Member
 
Join Date: Oct 2009
Location: Sunshine Coast Queensland Australia
Posts: 148
Send a message via MSN to glynndub
Default

I don’t know if anyone has been following this thread but here is my solution.
Firstly I’ll recapitulate with My Matrix setup, Objective, Problem and Solution.

My Matrix Setup
I dedicated 9 different instruments to each of 9 Mobius tracks.
Each track has 3 loops. I usually but not always follow the pattern below
Loop 1 = verse,
Loop 2 = chorus,
Loop 3 = bridge,

Objective.
Once I have instruments recorded as above, I like to jam away over the top and want to be able to initiate all 9 tracks to toggle verse, chorus, verse, chorus, until I’m jammed out.
So once again I became a scriptwriting masochist.

Problem.
It’s all laid out in the previous posts. Thanks to Jeff ‘s explanation and coding of “Modal Scripts” I all but achieved my goal.
When the script was executed, the active track and all tracks to the right togged Verse/Chorus beautifully.
Problem was that tracks to the left of the active track waited an additional cycle before advancing to next loop.
Catastrophic results! resembling dismembered Non-musical thoughts.

Solution.
Hardly elegant and a little quirky but it works! I added code so the script would make track 1 the active track. (so there’s no tracks to the left to go out of sync)
Also note, moving to track 1 is OK because I only want to jam and not overdub. So now the script does the following…

On first button press…
Remember track I’m on. (Variable saveTrack track)
Go to track 1
Then toggle all tracks Loop 1/Loop 2 (Verse/Chorus)
On second button press…
Stop toggling
Return to the original active track I was on before running script (Track saveTrack)
Return all tracks 1-9 to loop 1 (usually = verse)
Code:
!name Cool Bananas!
#!autoload
message Cool Bananas!

Variable saveTrack track
Track 1
Variable global inMode false
if inMode
   set inMode false
else
   set inMode true

   while inMode
     wait loop

#######
      for *
        if LoopNumber == 1
           loop 2
        else
           loop 1
        endif

      next
   next
endif
next
for *
   Loop 1
next
Track saveTrack
END END END END END END END END END END END END
Hope this helps someone!
__________________
Be Lucky In Life... Glynn

Cakewalk Sonar Producer 8.5.3, and Sonar X2a, HP pavilion dv6 3031TX, Win7-64-bit,
2x Behringer FCB1010, Edirol UA-25, Edirol Quad UA-55, Edirol PCR-500, Rode NT1A, KRK Rokit 8 Monitors, PODxt, AKG520 Cans, too many guitars to list and a Dog
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:45 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.