Hello, I'm back after a few tests. I didn't solve my issue but, as I tought it would come from envelopes, I happened to be the opposite. Well, simple sketch doesn't work, others more complicated does and it is still confusing. However I found a sketch which does the same thing each time. So if anyone can run it and confirm what I am hearing, that will be great. I still think I may have an hardware issue...
The below sketch only play a note every second. It is working fine with an envelope but not with the other version without envelope (commented #define WITH_ENVELOPE).
Thanks for the help.
Code:
#include <Audio.h>
//#define WITH_ENVELOPE // works fine with this defined, not if commented
AudioSynthWaveform waveform1; //xy=110,75
AudioOutputPT8211 pt8211_1; //xy=303,78
#ifdef WITH_ENVELOPE
AudioEffectEnvelope ampEnvelope1;
AudioConnection patchCord10(waveform1, ampEnvelope1);
AudioConnection patchCord7(ampEnvelope1, 0, pt8211_1, 0);
AudioConnection patchCord8(ampEnvelope1, 0, pt8211_1, 1);
#else
AudioConnection patchCord1(waveform1, 0, pt8211_1, 0);
AudioConnection patchCord2(waveform1, 0, pt8211_1, 1);
#endif
void setup() {
AudioMemory(15);
waveform1.begin(WAVEFORM_SINE);
waveform1.frequency(220);
waveform1.amplitude(0.05);
#ifdef WITH_ENVELOPE
ampEnvelope1.attack(2);
ampEnvelope1.release(500);
#endif
}
int myTime = millis();
void loop() {
if (millis() - myTime > 1000) {
Serial.println("note on !");
#ifdef WITH_ENVELOPE
ampEnvelope1.noteOn();
#else
waveform1.amplitude(0.5);
#endif
delay(200);
Serial.println("note off !");
#ifdef WITH_ENVELOPE
ampEnvelope1.noteOff();
#else
waveform1.amplitude(0);
#endif
myTime = millis();
}
}