Hello, my final goal is to be able to record audio at the same time that I play it back, in such a way that when the audio loops, the new recording is added on top of what is being played (basically standard looper pedal). However, this questions would be good to know for several projects outside of the the looper.
Imagine i had 100 drums, going to 25 mixers, going to 7 mixers, going to 2 mixers, then finally the combined output. Instead of laying out the patchchords manually on the gui(which would be fast enough) I was wondering if it would be possible to create an array of 100 drum objects, patch chord them all together with some coding, and end up with the final result. However, I am relatively new to c++, arduino, and coding in general.
Just in a test program before the actual one, I tried to have input from a mic, a regularly defined drum, and two drums which are in an array and patched in a for loop. However, I was running into issues with patching.
Relevant code:
(outside of setup)
AudioSynthSimpleDrum drumsArr[2];
AudioConnection connectionArr[2];
(in setup)
for(int i = 0; i < (sizeof(drumsArr)/sizeof(drumsArr[0])); i++){
drumsArr[i].length(250);
drumsArr[i].secondMix(0.0);
drumsArr[i].pitchMod(0.55);
connectionArr[i].connect(drumsArr[i],0,mixer1,i+2);
}
drumsArr[0].frequency(174);
drumsArr[1].frequency(196);
drum1.frequency(440);
drum1.length(250);
drum1.secondMix(0.0);
drum1.pitchMod(0.55);
loop:
drum1.noteOn();
for(int i = 0; i<2; i++){
Serial.print("i: "); Serial.println(i);
drumsArr[i].noteOn();
delay(2000);
}
error message:
Compilation error: no matching function for call to 'AudioConnection::AudioConnection()'
(at the line AudioConnection connectionArr[2];
)
I also tried writing it as
AudioConnection connectionArr2 and
AudioConnection connectionArr()[2]
neither worked.
Full code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioInputI2S input; //xy=112.00001525878906,148.00000190734863
AudioSynthSimpleDrum drum1; //xy=216.40000915527344,203.39999771118164
AudioMixer4 inputMixer; //xy=244,154
AudioMixer4 mixer1; //xy=448.00000762939453,233.4000129699707
AudioOutputI2S i2s1; //xy=632.0000076293945,171.00001335144043
AudioConnection patchCord1(input, 0, inputMixer, 0);
AudioConnection patchCord2(input, 1, inputMixer, 1);
AudioConnection patchCord3(drum1, 0, mixer1, 1);
AudioConnection patchCord4(inputMixer, 0, mixer1, 0);
AudioConnection patchCord5(mixer1, 0, i2s1, 0);
AudioConnection patchCord6(mixer1, 0, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=394.6000061035156,352.4000015258789
AudioSynthSimpleDrum drumsArr[2];
AudioConnection connectionArr[2];
void setup() {
Serial.begin(9600);
AudioMemory(20);
sgtl5000_1.enable();
sgtl5000_1.volume(.5);
sgtl5000_1.inputSelect(AUDIO_INPUT_LINEIN);
sgtl5000_1.autoVolumeControl(1,3,0,-18,6,8);
for(int i = 0; i < (sizeof(drumsArr)/sizeof(drumsArr[0])); i++){
drumsArr[i].length(250);
drumsArr[i].secondMix(0.0);
drumsArr[i].pitchMod(0.55);
connectionArr[i].connect(drumsArr[i],0,mixer1,i+2);
}
drumsArr[0].frequency(174);
drumsArr[1].frequency(196);
drum1.frequency(440);
drum1.length(250);
drum1.secondMix(0.0);
drum1.pitchMod(0.55);
}
void loop() {
drum1.noteOn();
for(int i = 0; i<2; i++){
Serial.print("i: "); Serial.println(i);
drumsArr[i].noteOn();
delay(2000);
}
}
in the recorder code, im planning on saving each "layer" of the recording in a different recording object, and I don't know how long or how many layers there will be. Hence, the need to create new recording object, patchchords, and mixers whenver the max is used.