diff --git a/src/yaw-shepard/dsp.cpp b/src/yaw-shepard/dsp.cpp index c3629d1..430bbe5 100644 --- a/src/yaw-shepard/dsp.cpp +++ b/src/yaw-shepard/dsp.cpp @@ -101,6 +101,7 @@ protected: synth.setVolume(val); break; case kParameterButtonA: + if(val > 0.5f) synth.resetPhase(); break; case kParameterButtonB: break; diff --git a/src/yaw-shepard/synth.cpp b/src/yaw-shepard/synth.cpp index 523f9f4..4a8136e 100644 --- a/src/yaw-shepard/synth.cpp +++ b/src/yaw-shepard/synth.cpp @@ -4,6 +4,10 @@ Synth::Synth(double sampleRate){ setSampleRate(48000.0, sampleRate); } +inline void Synth::resetPhase(){ + spectrumPhase = 0.0; +} + #define frac(x) ((x) - ((long)x)) constexpr double MIN_VOLUME = 0.00001; diff --git a/src/yaw-shepard/synth.h b/src/yaw-shepard/synth.h index 90250b3..84ee00c 100644 --- a/src/yaw-shepard/synth.h +++ b/src/yaw-shepard/synth.h @@ -13,16 +13,22 @@ public: void setPitchOffset(double in); void setSampleRate(double oldRate, double newRate); void setVolume(double in); - void shiftUp(); - void shiftDown(); + + //For recordable performances. + //For now it requires a button push, but perhaps + //we should require time position and have the phase reset automatically + //on song start? + void resetPhase(); + //Current fundamental frequency of blit. double hzFund = fMin; private: + void shiftUp(); + void shiftDown(); //Phase of wavetable. double tablePhase = 0.0; - double fmPhase = 0.0; float volume = 0.0f; //Parameter in unit circle controlling pitch (varies by one octave). double spectrumPhase = 1.0f;