What's new

Array for storing notes

Colin Hopkins

New Member
Hi All,

I'm trying to create a 16*8 array to store 16 randomly generated chords of 8 notes each and then access these during playback via a type of arpeggiator.

The only issue I have is not being able to correctly input/store and then access integers in a 2D array. I did see another post on this , but I'm still not able to set up to work well...

Sketchy outline of the area where I'm having problems attached.

Many thanks for any help.

CH
Code:
{on init etc etc...}

declare %Chords_Store[16*8]

end on

{other code etc etc...}

function ChordsCollect()
    $a := 0
    $b := 0
    while($a < 16)
        while($b < 8)
            %Notes[$b] := random(0, 127)
            %Chords_Store[$a*$b] := %Notes[$b]
            inc($b)
        end while
        inc($a)
    end while
end function

{later on in another Play() function do the reverse to access notes in array}

{$a is increased through a step counter etc}

    $b := 0
    while($b < 8)
        %Notes[$b] := %Chords_Store[$a*$b]
        inc($b)
    end while
 
OK, so there were some brain-dead moments here.

Fully solved.

Obviuosly I had $b in the wrong location and in a 16*8 array the relevant addresses would be
$a*8 + $b ....
 
Top Bottom