Home Forums Logelloop 6 (English spoken) How to create arrays in macros ?

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #6695
    Patrick KiznyPacocreative
    Participant

    Hey,

    Is there a way to declare and manipulate arrays in LL macro?
    I thought about adding an euclidean rhythm generator for Granulaterre, but getting stuck on arrays.

    #6696
    Christophe BChristophe B
    Keymaster

    Hello, here are some hints to manipulate arrays:
    (first, initialize Logelloop’s metronome in order to have a value other than zero in the system variable $metro_bar_beats$)

    // Declare a variable as array
    Declare int $beats[0]$ = 0
    
    Declare int $n$ = 0
    
    // Initialize
    DoRepeat
    
    	$beats[n]$ = { randomBool(0.5) ? 1 : 0 }
    	$n$ = { $n$ + 1 }
    
    While { $n$ < $metro_bar_beats$ }
    // Display in console
    $n$ = 0
    DoRepeat
    
    	Post $beats[n]$
    	$n$ = { $n$ + 1 }
    
    While { $n$ < $metro_bar_beats$ }
    // Access an unitizialized position will return a default value
    $n$ = $metro_bar_beats$
    Post { "Uninitialized: " + $beats[n]$ }

    1- Declare a variable as array with proper data type.
    2- Use it. Unitialized cells will have a default value.
    3- There is no notion of array length.

    #6705
    Patrick KiznyPacocreative
    Participant

    That’s very helpful. Thank you, Chris.
    I guess there are no methods for things like array.push() array.sort() etc…?
    Is there a way to define functions in macros?

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.