its a monosynth now

This commit is contained in:
2026-06-10 21:23:55 -05:00
parent 38dee08ab7
commit 6817c0e700
2 changed files with 11 additions and 5 deletions

View File

@@ -72,19 +72,23 @@ int32_t AudioEngine::process(float* out, size_t nFrames) {
NoteEvent noteEvent;
while(noteQueue_->pop(noteEvent)) {
std::string msg = "[NoteEvent] Type: " + std::to_string(noteEvent.type) +" Velocity: " + std::to_string(noteEvent.velocity) + " Note:" + std::to_string(noteEvent.note);
logger_->log("Audio", LogFlag::Debug, msg);
//std::string msg = "[NoteEvent] Type: " + std::to_string(noteEvent.type) +" Velocity: " + std::to_string(noteEvent.velocity) + " Note:" + std::to_string(noteEvent.note);
//logger_->log("Audio", LogFlag::Debug, msg);
noteOn_ = (noteEvent.type == NoteEventType::NoteOn) ? true : false;
freq_ = 440.0f * pow(2.0f, (static_cast<float>(noteEvent.note) - 69.0f) / 12.0f);
}
const float twoPi = 2.0f*std::numbers::pi_v<float>;
float phaseIncrement = twoPi * freq_ / sampleRate_;
for(size_t i = 0; i < nFrames; i++) {
// simulate a sine wave
phase_ += 0.04f;
const float twoPi = 2.0f*std::numbers::pi_v<float>;
phase_ += phaseIncrement;
if(phase_ > twoPi) {
phase_ -= twoPi;
}
float outSample = std::sin(phase_) / 4.0f;
float outSample = std::sin(phase_) / 4.0f * noteOn_;
out[2*i] = outSample;
out[2*i+1] = outSample;

View File

@@ -40,6 +40,8 @@ private:
uint32_t channels_ = 2;
float phase_ = 0.0f;
float freq_ = 0.0f;
bool noteOn_ = false;
LoggerService* logger_;
ConfigService* config_;