Hello every one, i am super new with the teensy, arduino and all the digital stuffs, now im trying to program a simple granular effect, until now im usin two 20K knobs on A1 and A2 to control beginFreeze and setSpeed and so far everything kinda work (even tho the speed changes weirdly), now im trying to add a push button for the beginFreeze but cant really write the code for it. Also my teensy 4.0 board doesent detect A4/5/6 etc only until A3 is this normal, same for digital inputs.
here is the code i have made so far
Please feel free to edit it if you feel it, any advice would be higly appreciated.
Thanks
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioInputI2S i2s1; //xy=440,372
AudioMixer4 mixer1; //xy=660,396
AudioEffectGranular granular1; //xy=901,444
AudioOutputI2S i2s2; //xy=1089,399
AudioConnection patchCord1(i2s1, 0, mixer1, 0);
AudioConnection patchCord2(mixer1, granular1);
AudioConnection patchCord3(granular1, 0, i2s2, 0);
AudioConnection patchCord4(granular1, 0, i2s2, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=526,143
#define GRANULAR_MEMORY_SIZE 12800 // enough for 290 ms at 44.1 kHz
int16_t granularMemory[GRANULAR_MEMORY_SIZE];
// inputs
#define pot1 A1 // beginFreeze
#define pot2 A2 // setSpeed
void setup() {
Serial.begin(9600);
// Audio connections require memory to work. For more
// detailed information, see the MemoryAndCpuUsage example
AudioMemory(10);
// I2S audio init
sgtl5000_1.enable();
sgtl5000_1.volume(5);
AudioInterrupts();
}
void loop() {
// read pot levels
float knob1 = (float)analogRead(pot1) / 1023.0; // beginFreeze
float knob2 = (float)analogRead(pot2) / 1023.0; // setSpeed
mixer1.gain(0, 5); // unused, gain 0
mixer1.gain(1,0.5); // granular1 (wet) gain
mixer1.gain(3, 5); // unused, gain 0
// the Granular effect requires memory to operate
granular1.begin(granularMemory, GRANULAR_MEMORY_SIZE);
granular1.beginFreeze(knob1);
granular1.beginPitchShift(knob2);
Serial.print("%, beginFreeze: ");
Serial.print(knob1 * 100.0);
Serial.print("%, setSpeed: ");
Serial.print(knob2 * 100.0);
Serial.print("%, Dry Level: ");
Serial.print("% / ");
}
here is the code i have made so far
Please feel free to edit it if you feel it, any advice would be higly appreciated.
Thanks
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioInputI2S i2s1; //xy=440,372
AudioMixer4 mixer1; //xy=660,396
AudioEffectGranular granular1; //xy=901,444
AudioOutputI2S i2s2; //xy=1089,399
AudioConnection patchCord1(i2s1, 0, mixer1, 0);
AudioConnection patchCord2(mixer1, granular1);
AudioConnection patchCord3(granular1, 0, i2s2, 0);
AudioConnection patchCord4(granular1, 0, i2s2, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=526,143
#define GRANULAR_MEMORY_SIZE 12800 // enough for 290 ms at 44.1 kHz
int16_t granularMemory[GRANULAR_MEMORY_SIZE];
// inputs
#define pot1 A1 // beginFreeze
#define pot2 A2 // setSpeed
void setup() {
Serial.begin(9600);
// Audio connections require memory to work. For more
// detailed information, see the MemoryAndCpuUsage example
AudioMemory(10);
// I2S audio init
sgtl5000_1.enable();
sgtl5000_1.volume(5);
AudioInterrupts();
}
void loop() {
// read pot levels
float knob1 = (float)analogRead(pot1) / 1023.0; // beginFreeze
float knob2 = (float)analogRead(pot2) / 1023.0; // setSpeed
mixer1.gain(0, 5); // unused, gain 0
mixer1.gain(1,0.5); // granular1 (wet) gain
mixer1.gain(3, 5); // unused, gain 0
// the Granular effect requires memory to operate
granular1.begin(granularMemory, GRANULAR_MEMORY_SIZE);
granular1.beginFreeze(knob1);
granular1.beginPitchShift(knob2);
Serial.print("%, beginFreeze: ");
Serial.print(knob1 * 100.0);
Serial.print("%, setSpeed: ");
Serial.print(knob2 * 100.0);
Serial.print("%, Dry Level: ");
Serial.print("% / ");
}