Hi,
I’m not very good in C++, so I got stuck on this for too long:
I’m trying to write a code that would change the patchCord on the fly.
I managed to make a sample code for that, while using a specific audio filter in each patchCord.connect command.
Now I wish to get the name of the audio filter from a variable, and I’m stuck there.
The “filter” can be from all of the possible audio filters types, so how do I define this variable?
I’m not very good in C++, so I got stuck on this for too long:
I’m trying to write a code that would change the patchCord on the fly.
I managed to make a sample code for that, while using a specific audio filter in each patchCord.connect command.
Now I wish to get the name of the audio filter from a variable, and I’m stuck there.
The “filter” can be from all of the possible audio filters types, so how do I define this variable?
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioSynthWaveformSine sine1; //xy=158,74
AudioEffectEnvelope envelope1; //xy=232,156
AudioOutputI2S i2s1; //xy=611,61
AudioConnection patchCord1(sine1, envelope1);
AudioConnection patchCord2(envelope1, 0, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=195,272
// GUItool: end automatically generated code
void setup() {
AudioMemory(120);
sgtl5000_1.enable();
// connectiong to specific filter works:
patchCord2.disconnect();
patchCord2.connect(sine1, 0, i2s1, 1);
// but how to use a variable to make the connection?
AudioStream filter;
// ^^^ which type I should use?
filter = sine1;
patchCord2.disconnect();
patchCord2.connect(filter, 0, i2s1, 1);
delay (2000);
filter = envelope1;
patchCord2.disconnect();
patchCord2.connect(filter, 0, i2s1, 1);
}
void loop() {
// put your main code here, to run repeatedly:
}