cleanup envelope parameter mappings
This commit is contained in:
@@ -57,6 +57,8 @@ qt_add_executable(metabolus
|
||||
src/synth/Envelope.h
|
||||
src/synth/Synth.cpp
|
||||
src/synth/Synth.h
|
||||
src/synth/SynthBuffer.cpp
|
||||
src/synth/SynthBuffer.h
|
||||
resources/resources.qrc
|
||||
src/ui/widgets/SmartSlider/SmartSlider.cpp
|
||||
src/ui/widgets/SmartSlider/SmartSlider.h
|
||||
@@ -64,6 +66,9 @@ qt_add_executable(metabolus
|
||||
src/ui/widgets/EnvelopeGenerator/EnvelopeGenerator.cpp
|
||||
src/ui/widgets/EnvelopeGenerator/EnvelopeGenerator.h
|
||||
src/ui/widgets/EnvelopeGenerator/EnvelopeGenerator.ui
|
||||
src/ui/widgets/Scope/Scope.cpp
|
||||
src/ui/widgets/Scope/Scope.h
|
||||
src/ui/widgets/Scope/Scope.ui
|
||||
)
|
||||
|
||||
set_target_properties(metabolus PROPERTIES AUTOUIC ON)
|
||||
|
||||
@@ -11,6 +11,8 @@ AudioEngine::AudioEngine() : synth_(params_) {
|
||||
// TODO: get audio configurations
|
||||
synth_.setSampleRate(sampleRate_);
|
||||
|
||||
synth_.setScopeBuffer(&scope_);
|
||||
|
||||
}
|
||||
|
||||
AudioEngine::~AudioEngine() {
|
||||
|
||||
@@ -23,6 +23,7 @@ public:
|
||||
// getters
|
||||
ParameterStore* parameters() { return ¶ms_; }
|
||||
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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
};
|
||||
|
||||
@@ -11,16 +11,16 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
audio_(new AudioEngine()),
|
||||
keyboard_(audio_->noteQueue()) {
|
||||
|
||||
// Initialize UI
|
||||
// initialize ui
|
||||
ui_->setupUi(this);
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
|
||||
// connect scope
|
||||
ui_->scopeWidget->setScopeBuffer(&audioEngine_->scopeBuffer());
|
||||
|
||||
// Connect buttons to slots
|
||||
connect(ui_->buttonReset, &QPushButton::clicked, this, &MainWindow::onResetClicked);
|
||||
|
||||
// synth business
|
||||
audio_->start();
|
||||
|
||||
// connect envelopeGenerator
|
||||
ui_->envelopeOsc1Volume->init(EnvelopeId::Osc1Volume);
|
||||
connect(ui_->envelopeOsc1Volume, &EnvelopeGenerator::envelopeChanged,
|
||||
@@ -28,6 +28,10 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
audio_->parameters()->set(EnvelopeId::Osc1Volume, a, d, s, r);
|
||||
});
|
||||
// this should be easy enough to put into a for each envelopeGenerator loop
|
||||
|
||||
// synth business
|
||||
audio_->start();
|
||||
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
<height>800</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -51,6 +51,19 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Scope" name="scope" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>200</x>
|
||||
<y>540</y>
|
||||
<width>400</width>
|
||||
<height>200</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
@@ -60,6 +73,12 @@
|
||||
<header>EnvelopeGenerator/EnvelopeGenerator.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Scope</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>Scope/Scope.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
@@ -16,6 +16,7 @@ public:
|
||||
explicit EnvelopeGenerator(QWidget* parent = nullptr);
|
||||
~EnvelopeGenerator();
|
||||
|
||||
// connects signals, sets parameters to the defaults defined in paramStore
|
||||
void init(EnvelopeId id);
|
||||
|
||||
// setters
|
||||
|
||||
Reference in New Issue
Block a user