Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: help reseting the phase of sine

  1. #1
    Junior Member
    Join Date
    Jan 2020
    Posts
    2

    help reseting the phase of sine

    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!

  2. #2
    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/...nth_waveform.h
    https://github.com/ElectroTechnique/...h_waveform.cpp

  3. #3
    Junior Member
    Join Date
    Jan 2020
    Posts
    2
    @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!

  4. #4
    Yes that's correct.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •