Added button press to allow consistently recordable performances.

This commit is contained in:
yaw-man 2022-09-22 17:04:27 -05:00
parent ef0eec2721
commit a9d112d757
3 changed files with 14 additions and 3 deletions

View File

@ -101,6 +101,7 @@ protected:
synth.setVolume(val);
break;
case kParameterButtonA:
if(val > 0.5f) synth.resetPhase();
break;
case kParameterButtonB:
break;

View File

@ -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;

View File

@ -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;