Array handling in the audio tool.

Status
Not open for further replies.

RABB17

Well-known member
Is array declaration on the roadmap for audio tool development? It would be of some use for more complicated designs, as currently you can't declare arrays of wavetables and fill that array with declared wavetables and have it work... the only workaround I have found is to manually instantiate the arrays and patch chords, which when you have hundreds of these connections can be quite tedious.
 
the audio tool does not support arrays of objects, but you could manage anything done with the design tool making an array of pointers,

Code:
AudioSynthSimpleDrum     drum0;          //xy=219,42
AudioSynthSimpleDrum     drum1;          //xy=219,162
AudioSynthSimpleDrum     drum2;          //xy=219,282
AudioSynthSimpleDrum     drum3;          //xy=219,402
AudioSynthSimpleDrum     drum4;          //xy=219,522
AudioSynthSimpleDrum     drum5;          //xy=219,642
AudioSynthSimpleDrum     drum6;          //xy=219,762
AudioSynthSimpleDrum     drum7;          //xy=219,882

AudioSynthSimpleDrum     *drum[8] = {
  &drum0, &drum1, &drum2, &drum3, &drum4, &drum5, &drum6, &drum7 };

and then use it like this

Code:
  drum[x]->frequency( y );
  drum[x]->noteOn();

does it help?
 
Yes, ty. I realized this the other day when I started working on my wavetable project again. It would be nice to add this info somewhere in the audio tool documentation because it seems a common issue. Given the processing power of the t4 4.1 platforms array support would be nice but the workarounds presented on the forum are helpful. IDK why I'm always asking the forum for things I could prob do my lazy self, lol. I imagine PJRC has their hands full with well designing teensy and writing large swathes of the library. Ty for your reply and cheers!
 
In the designer tool you can declare names like mixer[1] instead of mixer1, mixer2, etc. The design tool still sucks for this when copying and pasting, requiring you to manually go back and change all the mixer[0]1 (for example) to mixer[2] because the copy paste doesn't understand the notation. Aside form this limitation, the design tool will properly create all the wire connections and such. However, when I tried this I could not get it to work even after a MyControlArray* = new MyControlArray[n] declaration. If you could make a simple sketch that shows this working I can build a python script to handle the rest of the automation. Python and bash are my forte.
 
In the designer tool you can declare names like mixer[1] instead of mixer1, mixer2, etc. The design tool still sucks for this when copying and pasting, requiring you to manually go back and change all the mixer[0]1 (for example) to mixer[2] because the copy paste doesn't understand the notation. Aside form this limitation, the design tool will properly create all the wire connections and such. However, when I tried this I could not get it to work even after a MyControlArray* = new MyControlArray[n] declaration. If you could make a simple sketch that shows this working I can build a python script to handle the rest of the automation. Python and bash are my forte.

So like this:

in audio tool you make mixer[1] mixer[2] mixer[3] mixer[4]

comment out the auto gui declared mixer[1] mixer[2] mixer[3] mixer[4]

do not comment out the patchchord connections, only the variable declarations

then right below your */*/ block

declare the pointer array like this: AudioMixer4* mixer = new AudioMixer4[4];

it must have the same name as the dummy audio tool declarations.

Hope that clarifies it!
 
Is array declaration on the roadmap for audio tool development? It would be of some use for more complicated designs, as currently you can't declare arrays of wavetables and fill that array with declared wavetables and have it work... the only workaround I have found is to manually instantiate the arrays and patch chords, which when you have hundreds of these connections can be quite tedious.

There's nothing inherently different dealing with arrays inside vs outside audio library from my experience.
I find it's easier to declare and initialize the array in the .cpp file of your audio object, and reference it outside with extern.

i.e inside audio object .cpp;

Code:
float variable1[16];

outside;

Code:
extern float variable1[];
 
Status
Not open for further replies.
Back
Top