polyphony checkpoint
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
|
||||
#include "Instrument.hpp"
|
||||
|
||||
#include "string"
|
||||
|
||||
Instrument::Instrument(ConfigService* config, LoggerService* logger) :
|
||||
config_(config), logger_(logger) {
|
||||
|
||||
}
|
||||
|
||||
void Instrument::noteOn(float frequency, float velocity) {
|
||||
|
||||
// std::string msg = "NoteOn Frequency = " + std::to_string(frequency);
|
||||
// if(logger_ != nullptr) logger_->log("Instrument", LogFlag::Debug, msg);
|
||||
|
||||
phaseIncrement_ = 2.0f * pi * frequency / sampleRate_;
|
||||
|
||||
active_ = true;
|
||||
}
|
||||
|
||||
void Instrument::noteOff() {
|
||||
active_ = false;
|
||||
}
|
||||
|
||||
bool Instrument::isActive() {
|
||||
return active_;
|
||||
}
|
||||
|
||||
float Instrument::process(bool& scopeTrigger) {
|
||||
|
||||
phase_ += phaseIncrement_;
|
||||
if(phase_ > 2.0f * pi) phase_ -= 2.0f * pi;
|
||||
|
||||
return sin(phase_);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user