cleanup envelope parameter mappings

This commit is contained in:
2025-12-26 18:42:14 -06:00
parent c5d0fe6091
commit cc11cfe63a
9 changed files with 51 additions and 8 deletions

View File

@@ -11,6 +11,8 @@ AudioEngine::AudioEngine() : synth_(params_) {
// TODO: get audio configurations
synth_.setSampleRate(sampleRate_);
synth_.setScopeBuffer(&scope_);
}
AudioEngine::~AudioEngine() {

View File

@@ -23,6 +23,7 @@ public:
// getters
ParameterStore* parameters() { return &params_; }
NoteQueue& noteQueue() { return noteQueue_; }
ScopeBuffer& scopeBuffer() { return scope_; }
private:
@@ -35,6 +36,7 @@ private:
ParameterStore params_; // stores the control parameters
NoteQueue noteQueue_; // stores note events for passing between threads
Synth synth_; // generates audio
ScopeBuffer scope_ { 1024 }; // stores audio samples for visualization
RtAudio audio_; // audio device
// TODO: id like a yml config file or something for these

View File

@@ -32,7 +32,7 @@ public:
void noteOn();
void noteOff();
// return current level
// calculates and returns envelope level. must only be called once per sample
float process();
// determine if a note is playing or not

View File

@@ -99,6 +99,12 @@ void Synth::process(float* out, uint32_t nFrames, uint32_t sampleRate) {
out[2*i] = sampleOut; // left
out[2*i+1] = sampleOut; // right
// write to scope buffer
if (scope_) {
scope_->push(sampleOut); // visualization tap
// set trigger info here too
}
// sampling business
phase_ += phaseInc;
if (phase_ > 2.0f * M_PI) phase_ -= 2.0f * M_PI;

View File

@@ -4,6 +4,7 @@
#include "../ParameterStore.h"
#include "../NoteQueue.h"
#include "Envelope.h"
#include "ScopeBuffer.h"
#include <vector>
#include <atomic>
@@ -28,8 +29,9 @@ public:
// handles note events
void handleNoteEvent(const NoteEvent& event);
// sample rate setter
// setters
void setSampleRate(uint32_t sampleRate) { sampleRate_ = sampleRate; }
void setScopeBuffer(ScopeBuffer* scope) { scope_ = scope; }
private:
@@ -60,7 +62,9 @@ private:
std::vector<uint8_t> heldNotes_;
// envelopes !!
// TODO: set these parameters via sliders
Envelope gainEnvelope_;
// for the scope
ScopeBuffer* scope_ = nullptr;
};