If like me and you're dealing with lots of simultaneous voices (eg synth project) you're probably a bit frustrated with AudioMixer4 having only 4 inputs. Then you'll have the large cascade of patchcords to stitch together to join everything up. Super messy code and inflexible. Well, I've templatized AudioMixer4 to create AudioMixerN (attached).
Just include that at the top of your sketch.
So, if I want a mixer for 64 sources then declare as follows for 64 voices:
AudioMixerN<64> mixerN;
you'll have to patch its output as usual to whatever. Then let's say I've got a bunch of wavetable generators:
AudioSynthWavetable wavetable[64];
and their patchcords (which will be dynamically allocated - you don't have to but you can):
AudioConnection *patchCords[NUM_VOICES];
Then initialisation in your setup() is simply:
for (int i = 0; i < 64; i++)
{
patchCords = new AudioConnection(wavetable, 0, mixerN, i);
mixerN.gain(i, 0.75);
}
enjoy! Happy for PJRC to add it to their libraries if this proves useful. I did bugger all work just munging the AudioMixer4 and templating it.
Teik
Just include that at the top of your sketch.
So, if I want a mixer for 64 sources then declare as follows for 64 voices:
AudioMixerN<64> mixerN;
you'll have to patch its output as usual to whatever. Then let's say I've got a bunch of wavetable generators:
AudioSynthWavetable wavetable[64];
and their patchcords (which will be dynamically allocated - you don't have to but you can):
AudioConnection *patchCords[NUM_VOICES];
Then initialisation in your setup() is simply:
for (int i = 0; i < 64; i++)
{
patchCords = new AudioConnection(wavetable, 0, mixerN, i);
mixerN.gain(i, 0.75);
}
enjoy! Happy for PJRC to add it to their libraries if this proves useful. I did bugger all work just munging the AudioMixer4 and templating it.
Teik