cfredisded
Active member
Hey All,
I'm working on a project that has multiple wave forms and I'd like to be able to push a button to reset all of the waveforms to start at once. I remember in June waveform.begin would restart the wave form. I remember because back in June I had the opposite problem ....
https://forum.pjrc.com/threads/52750-Teensy-Audio-Library-Synth-Waveform-change-waveshape?p=181444
... and Paul helped me figure out a work around for my amateur code.
It appears maybe Paul updated the waveform begin to not reset at 0? Is there anyway to reset the waveforms 'phase' back to zero now?
Here's some example code. Even without the if button pressed statements the waveforms sounds just fine. Yet 6 months ago they would have just kept resetting.
I'm working on a project that has multiple wave forms and I'd like to be able to push a button to reset all of the waveforms to start at once. I remember in June waveform.begin would restart the wave form. I remember because back in June I had the opposite problem ....
https://forum.pjrc.com/threads/52750-Teensy-Audio-Library-Synth-Waveform-change-waveshape?p=181444
... and Paul helped me figure out a work around for my amateur code.
It appears maybe Paul updated the waveform begin to not reset at 0? Is there anyway to reset the waveforms 'phase' back to zero now?
Here's some example code. Even without the if button pressed statements the waveforms sounds just fine. Yet 6 months ago they would have just kept resetting.
Code:
#include <Bounce.h>
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioSynthWaveform waveform2; //xy=480,575
AudioSynthWaveform waveform1; //xy=482,630
AudioMixer4 mixer1; //xy=751,615
AudioOutputI2S i2s1; //xy=937,614
AudioConnection patchCord1(waveform2, 0, mixer1, 0);
AudioConnection patchCord2(waveform1, 0, mixer1, 1);
AudioConnection patchCord3(mixer1, 0, i2s1, 0);
AudioConnection patchCord4(mixer1, 0, i2s1, 1);
// GUItool: end automatically generated code
const int shiftPin = 28;
Bounce SHIFTbutton = Bounce(shiftPin, 10); // 10 ms debounce
const int ratioPin = 27;
Bounce RATIObutton = Bounce(ratioPin, 10); // 10 ms debounce
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
AudioMemory(50);
waveform1.begin(.1 ,2 ,WAVEFORM_SINE);
waveform2.begin(.1 ,2 ,WAVEFORM_SINE);
mixer1.gain(0, .25);
mixer1.gain(1, .25);
pinMode(shiftPin, INPUT_PULLUP);
pinMode(ratioPin, INPUT_PULLUP);
}
void loop() {
// put your main code here, to run repeatedly:
if (SHIFTbutton.update()){
if (SHIFTbutton.fallingEdge()){
waveform1.begin(.5 ,40 ,WAVEFORM_SINE);
waveform2.begin(.5 ,80 ,WAVEFORM_SINE);
Serial.println("shift pressed");
}
}
}