help reseting the phase of sine

Status
Not open for further replies.

francis1661

New member
hi there, posting for the first time so nice to meet you all!
i have a question regarding reseting the phase of the sine object from the audio lib, im pretty much new to the teensy so i ask for your kind forgiveness if i ask obvious / stupied stuff ,
im attempting to set the phase of sine to 0 upon midi note receive,

Code:
AudioNoInterrupts();
sine1.amplitude(amp_env_exp);
 sine1.frequency(200*pitch_env_exp+60); 
  sine1.phase(sphase);   
      AudioInterrupts();

whereas (sphase) is basically 0 which is sent to the object everytime midi note 60 is received

this resides in a loop and the outcome is a saw wave because i assume that im doing something wrong and the phase resets everytime the loop is executed

how could i "tell" the phase to reset to 0 momentarily when the midi note is received and proceed from there?

thank you very much!
 
Hello, if you want to reset to the start (0 degrees phase) you'll probably need to modify the AudioSynthWaveformSine object (synth_sine.h and synth_sine.cpp) because I believe, setting phase(0) doesn't work like this. Have a look at the sync() function I wrote in a modified version of AudioSynthWaveformMod, it resets the phase_accumulator when the sync function is called, I use it to retrigger LFOs when they receive note on messages:

https://github.com/ElectroTechnique/TSynth/blob/master/Modified Libraries/synth_waveform.h
https://github.com/ElectroTechnique/TSynth/blob/master/Modified%20Libraries/synth_waveform.cpp
 
@UHF for some reason i cant see my other reply so thank you very much! just to make sure, i call it using "waveform1.sync();" when ever i want and it should restart the phase?

thanks again!
 
I had trouble with this also but lucky a helpful user pointed me to this thread.
So it appears phase() doesn't work?
 
Status
Not open for further replies.
Back
Top