polyphony checkpoint

This commit is contained in:
2026-06-12 23:13:18 -05:00
parent 347f585630
commit 9f79f11a19
10 changed files with 218 additions and 39 deletions

View File

@@ -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_);
}