wip: oscillator fine-tune

This commit is contained in:
2023-09-10 07:13:51 +04:00
parent c76f3ef3f8
commit 71e1622627
6 changed files with 49 additions and 49 deletions

View File

@@ -54,10 +54,9 @@ class KeyBoard {
}
public:
KeyBoard(/* args */);
~KeyBoard();
static float GetHzBySemitone(int semitone) {
static float GetHzBySemitone(float semitone) {
//440 * Math.Pow(2, (note - 69) / 12.0) would it be better?
return PITCH_STANDARD * powf(powf(2.f, (1.f / 12.f)), semitone);
}
@@ -71,7 +70,3 @@ class KeyBoard {
return result;
}
};
KeyBoard::KeyBoard(/* args */) {}
KeyBoard::~KeyBoard() {}

View File

@@ -5,31 +5,34 @@
class Oscillator {
private:
OscillatorType m_osc;
float m_freq;
float m_fine;
float m_key;
float m_volume;
float m_phase;
float m_phase_dt;
float (Oscillator::*m_osc_function)(void);
float (Oscillator::*m_dt_function)(float freq);
void sine_osc_phase_incr();
void saw_osc_phase_incr();
float calc_saw_phase_delta(float freq);
float calc_sine_phase_delta(float freq);
float sawosc();
float triangleosc();
float squareosc();
float sign(float v);
float sineosc();
void SineOscPhaseIncr();
void SawOscPhaseIncr();
float CalcSawPhaseDelta(float freq);
float CalcSinePhaseDelta(float freq);
float SawOsc();
float TriangleOsc();
float SquareOsc();
float Sign(float v);
float SineOsc();
public:
Oscillator(OscillatorType osc, float freq, float volume);
Oscillator(OscillatorType osc, float fine, float volume);
~Oscillator();
OscillatorType GetType() { return m_osc; }
void SetType(OscillatorType osc);
float GetVolume() { return m_volume; }
void SetVolume(float volume) { m_volume = volume; }
float GetFreq() { return m_freq; }
void SetFreq(float freq);
float GetKey() { return m_key; }
void SetKey(float key);
float GetFine() { return m_fine; }
void SetFine(float fine) { assert(fine >= -2.f && fine <= 2.f); m_fine = fine; }
void Reset();
float Process();
};

View File

@@ -6,7 +6,7 @@
struct OscillatorGuiState {
float volume;
float freq; // todo: remove or change to pitch shift
float fine;
OscillatorType waveshape;
bool is_dropdown_open;
Rectangle shape_dropdown_rect;