Now I understand. Thanks for your patience. Have you tried running multiples instances of the sequencer script? CsoundUnity can run as many .csd files as you like, simply attach a new CsoundUnity component to another GameObject, then you should have another layer no? Note, there might be a slight issue with timing this way, but it migh tbe worth a try.
Alternatively you could just create 64 instances of ROW_SEQUENCER. They each use a unique array to hold notes and states, you can create as many of them as a you wish. It might also be a good idea to pass the layer number to each instance using a pfield, although it may not be absolutely necessary. So your score will look like this.
<CsScore>
;layer 1
i"ROW_SEQUENCER" 0 [3600*12] 1 1
i"ROW_SEQUENCER" 0 [3600*12] 2 1
i"ROW_SEQUENCER" 0 [3600*12] 3 1
i"ROW_SEQUENCER" 0 [3600*12] 4 1
i"ROW_SEQUENCER" 0 [3600*12] 5 1
i"ROW_SEQUENCER" 0 [3600*12] 6 1
i"ROW_SEQUENCER" 0 [3600*12] 7 1
i"ROW_SEQUENCER" 0 [3600*12] 8 1
;layer 2
i"ROW_SEQUENCER" 0 [3600*12] 1 2
i"ROW_SEQUENCER" 0 [3600*12] 2 2
i"ROW_SEQUENCER" 0 [3600*12] 3 2
i"ROW_SEQUENCER" 0 [3600*12] 4 2
i"ROW_SEQUENCER" 0 [3600*12] 5 2
i"ROW_SEQUENCER" 0 [3600*12] 6 2
i"ROW_SEQUENCER" 0 [3600*12] 7 2
i"ROW_SEQUENCER" 0 [3600*12] 8 2
;layer 3
i"ROW_SEQUENCER" 0 [3600*12] 1 3
i"ROW_SEQUENCER" 0 [3600*12] 2 3
i"ROW_SEQUENCER" 0 [3600*12] 3 3
i"ROW_SEQUENCER" 0 [3600*12] 4 3
i"ROW_SEQUENCER" 0 [3600*12] 5 3
i"ROW_SEQUENCER" 0 [3600*12] 6 3
i"ROW_SEQUENCER" 0 [3600*12] 7 3
i"ROW_SEQUENCER" 0 [3600*12] 8 3
(...)
And if you need to know which layer an instrument belongs to you can add this to the ROW_SEQUENCER instrument def:
iLayerNumber = p5
Changing the sound of each layer should also be quite straightforward. You are already do this:
kInst chnget "inst"
So can’t you simply use that to determine which sounds is played back? If you pass the kInst variable to the sf instrument you should be able to change the sound:
(...)
kInst chnget "inst"
if metro(kTempo) == 1 then
if kNotesAmps[kBeat] == 1 && kNotesInsts[kBeat] == 0 then
event "i", "SYNTH", 0, 3, kNoteValues[p4-1]
elseif kNotesAmps[kBeat] == 1 && kNotesInsts[kBeat] == 1 then
event "i", "sf2inst", 0, 3, kNoteValues[p4-1],75, kInst
(...)
Then in your sf instrument you do something like this:
(...)
iInstr = p6
a1,a2 sfinstr ivel, inum, kamp*ivel, kfreq, iInstr, gisf
outs a1, a2
(...)
Panning and what not can also be passed to the event call, in much the same way as we just added kInstr.
I hope I am finally understanding this…