Hello ! I am trying to use two granular objects with two Freverbs (in order to have stereo input-output reverb) by using Teensy 4 . Everything works fine however I can not achieve having larger grains than 740msec, as Teensy 4 looks like is being drained from memory by this setup . I was wondering if there is any option to down sample momentary the audio just when I use the granular.beginFreeze, from 16bit/44100hz to 12bit/22050hz in order to be able to store longer grain duration and after granular.stop to stop also downsampling and use again 16bit/44100hz. Is this any way to do this ? Thank you for any help . This is the code that I use .
Code:
#include <Audio.h>
#include <Wire.h>
#include <SD.h>
#include <SPI.h>
#include <SerialFlash.h>
#include <Bounce.h>
// GUItool: begin automatically generated code
AudioInputI2S i2s2; //xy=92,464
AudioAmplifier amp1; //xy=244.28573608398438,447.1427917480469
AudioAmplifier amp2; //xy=244.28573608398438,495.7143249511719
AudioEffectFreeverb freeverb2; //xy=366,530
AudioEffectGranular granular2; //xy=381,471
AudioEffectFreeverb freeverb1; //xy=387.28570556640625,298.4285888671875
AudioEffectGranular granular1; //xy=398,376
AudioMixer4 mixer1; //xy=562.8571166992188,357.14276123046875
AudioMixer4 mixer2; //xy=565.7142944335938,443.4285583496094
AudioOutputI2S i2s1; //xy=750.7142333984375,416.142822265625
AudioConnection patchCord1(i2s2, 0, amp1, 0);
AudioConnection patchCord2(i2s2, 1, amp2, 0);
AudioConnection patchCord3(amp1, freeverb1);
AudioConnection patchCord4(amp1, granular1);
AudioConnection patchCord5(amp2, freeverb2);
AudioConnection patchCord6(amp2, granular2);
AudioConnection patchCord7(freeverb2, 0, mixer2, 0);
AudioConnection patchCord8(granular2, 0, mixer2, 1);
AudioConnection patchCord9(freeverb1, 0, mixer1, 0);
AudioConnection patchCord10(granular1, 0, mixer1, 1);
AudioConnection patchCord11(mixer1, 0, i2s1, 0);
AudioConnection patchCord12(mixer2, 0, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=741.3571166992188,458.21435546875
// GUItool: end automatically generated code
Bounce button0 = Bounce(0, 15);
Bounce button1 = Bounce(1, 15);
Bounce button2 = Bounce(2, 15);
const int myInput = AUDIO_INPUT_LINEIN;
#define GRANULAR_MEMORY_SIZE 32640 //
int16_t granularMemory[GRANULAR_MEMORY_SIZE];
void setup() {
AudioMemory(255);
pinMode(0, INPUT_PULLUP);
pinMode(1, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
delay(2000);
Serial.begin(115200);
sgtl5000_1.enable();
sgtl5000_1.volume(0.5);
granular1.begin(granularMemory, GRANULAR_MEMORY_SIZE);
granular2.begin(granularMemory, GRANULAR_MEMORY_SIZE);
amp1.gain(1);
amp2.gain(1);
}
void loop() {
button0.update();
button1.update();
button2.update();
float knobA2 = ((float)analogRead(A2) / 1023.0);
freeverb1.roomsize(knobA2);
freeverb2.roomsize(knobA2);
float knobA1 = analogRead(A1);
float gain1 = (float)knobA1 / 1023.0;
float gain2 = 1.0 - gain1;
mixer1.gain(0, gain1);
mixer1.gain(1, gain2);
mixer2.gain(0, gain1);
mixer2.gain(1, gain2);
if (button2.fallingEdge()){
amp1.gain(0);
amp2.gain(0);
}
if (button2.risingEdge()){
amp1.gain(1);
amp2.gain(1);
}
if (button0.fallingEdge()) {
//float msec = 100.0 + (knobA4 * 190.0);
granular1.beginFreeze(740);
granular2.beginFreeze(740);
}
if (button0.risingEdge()) {
granular1.stop();
granular2.stop();
//delay1.disable(200);
}
}