Texteditor to initialise Arrays – Cabbage Stew

So the issue is that those arrays aren’t known when instrument 3 is compiled. So you either

  1. Declare the global arrays in your main .csd file, and then populate them in the instrument you compile with compilestr
    gkArray1[] init 4
    gkArray2[] init 4
    gkArray3[] init 4

    instr 1 
        iRes compilestr  {{
            instr 2
                gkArray1[0] = 99
                gkArray1[1] = 99
                gkArray1[2] = 99
                gkArray1[3] = 99
            endin
            schedule(2, 0, 1)
        }}
    endin

    instr 3
      printarray gkArray1, metro(1)
    endin
  1. Hold off compiling any instruments that need access to the arrays until after you have compiled instr 2
    iRes1 compilestr  {{
        instr 2
            gkArray1[] init 4
        endin
        schedule(2, 0, 1)
    }}
    
    iRes2 compilestr {{
        instr 3
            printarray gkArray1, metro(1)
        endin
        schedule(3, 1, 1)
    }}
endin

I guess option 1 is probably the simplest as you’re going to need to know the global variables names anyway.

Read more here: Source link