scaffold new classes
This commit is contained in:
36
src/synth/Voice.hpp
Normal file
36
src/synth/Voice.hpp
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "Instrument.hpp"
|
||||
|
||||
// a voice is a tone generator that the synth uses for polyphony
|
||||
// the synth mixes multiple voices together into a polyphonic audio. calculations for samples are handled in the instrument
|
||||
class Voice {
|
||||
|
||||
public:
|
||||
|
||||
Voice() = default;
|
||||
~Voice() = default;
|
||||
|
||||
void noteOn(int8_t midiNote, float velocity);
|
||||
void noteOff();
|
||||
bool isActive();
|
||||
|
||||
float process(bool& scopeTrigger);
|
||||
uint8_t note() { return note_; }
|
||||
|
||||
private:
|
||||
|
||||
float sampleRate_ = 44100.0f;
|
||||
|
||||
inline float noteToFrequency(uint8_t note);
|
||||
|
||||
uint8_t note_ = 0;
|
||||
float velocity_ = 1.0f;
|
||||
bool active_ = false;
|
||||
|
||||
Instrument* instrument;
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user