Hi John,
Thanks a lot for this work. Your crazy instrument does sound very good ! (great video btw !)
I'd love to use all that new objects you gave us but...sorry, I'm still asking some noob question (I wish I could just solve it by myself) but it's been hours that I'm searching for how to use your library...
I just added the zip file though the "include librarie .zip" tool in arduino but when I'm trying to modulate one waveform to another, nothing's happening.
I used this code :
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioSynthWaveform waveform1; //xy=79,121
AudioEffectEnvelope envelope1; //xy=219,121
AudioSynthWaveform waveform2; //xy=234,220
AudioEffectEnvelope envelope2; //xy=380,219
AudioOutputI2S i2s1; //xy=668,153
AudioConnection patchCord1(waveform1, envelope1);
AudioConnection patchCord2(waveform2, envelope2);
AudioConnection patchCord3(envelope2, 0, i2s1, 0);
AudioConnection patchCord4(envelope2, 0, i2s1, 1);
AudioConnection patchCord5(envelope1, 0, waveform2, 0);
AudioControlSGTL5000 sgtl5000_1; //xy=668,211
// GUItool: end automatically generated code
int randomValue;
int NoteOffTrig = 0 ;
uint32_t noteTime;
uint32_t resetNoteOffTime = 0;
bool NoteOffStateTime = 0;
bool NoteOffStateTimePrevious = 0;
void setup() {
Serial.begin(9600);
randomSeed(analogRead(A9)); //passer la fonction random en réelle fonction aléatoire.
AudioMemory(70); // Audio connections require memory to work. For more detailed information, see the MemoryAndCpuUsage example
// setup audio board
sgtl5000_1.enable();
sgtl5000_1.volume(0.7);
waveform1.begin(1, 15, WAVEFORM_SQUARE);
waveform2.begin(1, 80, WAVEFORM_SAWTOOTH);
envelope1.attack(2000);
envelope1.decay(300);
envelope1.sustain(0.5);
envelope1.release(4000);
envelope2.attack(50);
envelope2.decay(50);
envelope2.sustain(0.4);
envelope2.release(500);
}
void loop() {
randomValue = random(0, 100);
// TRIG RANDOM SOUNDS
if (randomValue > 92) {
Serial.println(">>>>>>>> NOTE ON !! <<<<<<<<");
AudioNoInterrupts() ;
envelope1.noteOn();
envelope2.noteOn();
resetNoteOffTime = millis();
NoteOffTrig = random(0, 500);
AudioInterrupts();
}
NoteOffStateTime = millis() - resetNoteOffTime > NoteOffTrig;
// TRIG ENVELOPPES NOTE OFF
if (NoteOffStateTime) {
if (NoteOffStateTimePrevious == 0) {
Serial.println(">>>>>>>> NOTE OFF !! <<<<<<<<");
envelope1.noteOff();
envelope2.noteOff();
NoteOffStateTimePrevious = 1;
}
}
else {
NoteOffStateTimePrevious = 0;
}
Serial.println();
Serial.print(AudioProcessorUsageMax());
Serial.print(" ");
Serial.println(AudioMemoryUsageMax());
AudioProcessorUsageMaxReset();
AudioMemoryUsageMaxReset();
delay(50);
}
Any suggestion ? Is there something I'm doing totally wrong ?