Read up on structures and type definitions. You'll most likely end up with an array of 200 instrument structures, an array of output values, and a few simple support functions.
You can fill arrays of structures with data like this (where INSTRUMENT is your type definition label):
Code:
typedef struct {
int val1;
int val2;
int val3;
} INSTRUMENT;
INSTRUMENT instruments[200]; // array of instruments
instrument[0] = (INSTRUMENT) { 0, 9, 1 }; // fill structure
Pass the value of J onto the oscillator function, which then uses J to look up the appropriate array index. For example, to read one of the instrument parameters use:
Code:
x = instrument[j].val1;
y = instrument[j].val2;
z = instrument[j].val3;
Also, read up on function pointers. They can be used as variables in structures, like this:
Code:
typedef struct {
int val1;
int val2;
int val3;
void (*waveform)(); // helper function
} INSTRUMENT;
INSTRUMENT instruments[200]; // array of instruments
instrument[0] = (INSTRUMENT) { 0, 9, 1, sine };
instrument[1] = (INSTRUMENT) { 0, 9, 1, square };
instrument[2] = (INSTRUMENT) { 0, 9, 1, sawtooth };
The oscillator function can then call the appropriate function like this:
Code:
(*instrument[j].waveform)();
The functions can accept and return values, of course. This sort of stuff helps you break things down into chewable chunks, instead of cut & paste coding.