Added button press to allow consistently recordable performances.
This commit is contained in:
parent
ef0eec2721
commit
a9d112d757
|
@ -101,6 +101,7 @@ protected:
|
||||||
synth.setVolume(val);
|
synth.setVolume(val);
|
||||||
break;
|
break;
|
||||||
case kParameterButtonA:
|
case kParameterButtonA:
|
||||||
|
if(val > 0.5f) synth.resetPhase();
|
||||||
break;
|
break;
|
||||||
case kParameterButtonB:
|
case kParameterButtonB:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -4,6 +4,10 @@ Synth::Synth(double sampleRate){
|
||||||
setSampleRate(48000.0, sampleRate);
|
setSampleRate(48000.0, sampleRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void Synth::resetPhase(){
|
||||||
|
spectrumPhase = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
#define frac(x) ((x) - ((long)x))
|
#define frac(x) ((x) - ((long)x))
|
||||||
constexpr double MIN_VOLUME = 0.00001;
|
constexpr double MIN_VOLUME = 0.00001;
|
||||||
|
|
||||||
|
|
|
@ -13,16 +13,22 @@ public:
|
||||||
void setPitchOffset(double in);
|
void setPitchOffset(double in);
|
||||||
void setSampleRate(double oldRate, double newRate);
|
void setSampleRate(double oldRate, double newRate);
|
||||||
void setVolume(double in);
|
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.
|
//Current fundamental frequency of blit.
|
||||||
double hzFund = fMin;
|
double hzFund = fMin;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void shiftUp();
|
||||||
|
void shiftDown();
|
||||||
//Phase of wavetable.
|
//Phase of wavetable.
|
||||||
double tablePhase = 0.0;
|
double tablePhase = 0.0;
|
||||||
double fmPhase = 0.0;
|
|
||||||
float volume = 0.0f;
|
float volume = 0.0f;
|
||||||
//Parameter in unit circle controlling pitch (varies by one octave).
|
//Parameter in unit circle controlling pitch (varies by one octave).
|
||||||
double spectrumPhase = 1.0f;
|
double spectrumPhase = 1.0f;
|
||||||
|
|
Loading…
Reference in New Issue