full adsr
This commit is contained in:
@@ -15,20 +15,33 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
|
||||
// Initialize UI
|
||||
updateCounterLabel();
|
||||
|
||||
// Connect buttons to slots
|
||||
connect(ui_->buttonIncrement, &QPushButton::clicked, this, &MainWindow::onIncrementClicked);
|
||||
connect(ui_->buttonReset, &QPushButton::clicked, this, &MainWindow::onResetClicked);
|
||||
|
||||
// synth business
|
||||
audio_->start();
|
||||
|
||||
// slider business
|
||||
connect(ui_->sliderGainA, &SmartSlider::valueChanged, this, [this](float v) {
|
||||
audio_->parameters()->set(ParamId::Osc1VolumeEnvA, v); // bind valueChanged signal to the ParameterStore
|
||||
});
|
||||
connect(ui_->sliderGainD, &SmartSlider::valueChanged, this, [this](float v) {
|
||||
audio_->parameters()->set(ParamId::Osc1VolumeEnvD, v); // bind valueChanged signal to the ParameterStore
|
||||
});
|
||||
connect(ui_->sliderGainS, &SmartSlider::valueChanged, this, [this](float v) {
|
||||
audio_->parameters()->set(ParamId::Osc1VolumeEnvS, v); // bind valueChanged signal to the ParameterStore
|
||||
});
|
||||
connect(ui_->sliderGainR, &SmartSlider::valueChanged, this, [this](float v) {
|
||||
audio_->parameters()->set(ParamId::Osc1VolumeEnvR, v); // bind valueChanged signal to the ParameterStore
|
||||
});
|
||||
// initialize to defaults
|
||||
ui_->sliderGainA->setRange(PARAM_DEFS[static_cast<size_t>(ParamId::Osc1VolumeEnvA)].min, PARAM_DEFS[static_cast<size_t>(ParamId::Osc1VolumeEnvA)].max);
|
||||
ui_->sliderGainA->setValue(PARAM_DEFS[static_cast<size_t>(ParamId::Osc1VolumeEnvA)].def);
|
||||
ui_->sliderGainD->setRange(PARAM_DEFS[static_cast<size_t>(ParamId::Osc1VolumeEnvD)].min, PARAM_DEFS[static_cast<size_t>(ParamId::Osc1VolumeEnvD)].max);
|
||||
ui_->sliderGainD->setValue(PARAM_DEFS[static_cast<size_t>(ParamId::Osc1VolumeEnvD)].def);
|
||||
ui_->sliderGainS->setRange(PARAM_DEFS[static_cast<size_t>(ParamId::Osc1VolumeEnvS)].min, PARAM_DEFS[static_cast<size_t>(ParamId::Osc1VolumeEnvS)].max);
|
||||
ui_->sliderGainS->setValue(PARAM_DEFS[static_cast<size_t>(ParamId::Osc1VolumeEnvS)].def);
|
||||
ui_->sliderGainR->setRange(PARAM_DEFS[static_cast<size_t>(ParamId::Osc1VolumeEnvR)].min, PARAM_DEFS[static_cast<size_t>(ParamId::Osc1VolumeEnvR)].max);
|
||||
ui_->sliderGainR->setValue(PARAM_DEFS[static_cast<size_t>(ParamId::Osc1VolumeEnvR)].def);
|
||||
// TODO: package a smartSlider into an envelope controller widget
|
||||
@@ -47,16 +60,15 @@ void MainWindow::keyReleaseEvent(QKeyEvent* event) {
|
||||
keyboard_.handleKeyRelease(event);
|
||||
}
|
||||
|
||||
void MainWindow::onIncrementClicked() {
|
||||
counter_++;
|
||||
updateCounterLabel();
|
||||
}
|
||||
|
||||
void MainWindow::onResetClicked() {
|
||||
counter_ = 0;
|
||||
updateCounterLabel();
|
||||
}
|
||||
|
||||
void MainWindow::updateCounterLabel() {
|
||||
ui_->labelCounter->setText(QString::number(counter_));
|
||||
// initialize to defaults
|
||||
ui_->sliderGainA->setRange(PARAM_DEFS[static_cast<size_t>(ParamId::Osc1VolumeEnvA)].min, PARAM_DEFS[static_cast<size_t>(ParamId::Osc1VolumeEnvA)].max);
|
||||
ui_->sliderGainA->setValue(PARAM_DEFS[static_cast<size_t>(ParamId::Osc1VolumeEnvA)].def);
|
||||
ui_->sliderGainD->setRange(PARAM_DEFS[static_cast<size_t>(ParamId::Osc1VolumeEnvD)].min, PARAM_DEFS[static_cast<size_t>(ParamId::Osc1VolumeEnvD)].max);
|
||||
ui_->sliderGainD->setValue(PARAM_DEFS[static_cast<size_t>(ParamId::Osc1VolumeEnvD)].def);
|
||||
ui_->sliderGainS->setRange(PARAM_DEFS[static_cast<size_t>(ParamId::Osc1VolumeEnvS)].min, PARAM_DEFS[static_cast<size_t>(ParamId::Osc1VolumeEnvS)].max);
|
||||
ui_->sliderGainS->setValue(PARAM_DEFS[static_cast<size_t>(ParamId::Osc1VolumeEnvS)].def);
|
||||
ui_->sliderGainR->setRange(PARAM_DEFS[static_cast<size_t>(ParamId::Osc1VolumeEnvR)].min, PARAM_DEFS[static_cast<size_t>(ParamId::Osc1VolumeEnvR)].max);
|
||||
ui_->sliderGainR->setValue(PARAM_DEFS[static_cast<size_t>(ParamId::Osc1VolumeEnvR)].def);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Ui { class MainWindow; }
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class MainWindow : public QMainWindow {
|
||||
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
@@ -23,16 +23,10 @@ protected:
|
||||
void keyReleaseEvent(QKeyEvent* event) override;
|
||||
|
||||
private slots:
|
||||
void onIncrementClicked();
|
||||
void onResetClicked();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui_;
|
||||
int counter_ = 0;
|
||||
|
||||
int value = 0;
|
||||
|
||||
void updateCounterLabel();
|
||||
|
||||
AudioEngine* audio_ = nullptr;
|
||||
KeyboardController keyboard_;
|
||||
|
||||
@@ -13,30 +13,15 @@
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<widget class="QPushButton" name="buttonIncrement">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>70</y>
|
||||
<width>101</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>15</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Increment</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="buttonReset">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>100</y>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>101</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
@@ -50,36 +35,57 @@
|
||||
<string>Reset</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelCounter">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>20</y>
|
||||
<width>151</width>
|
||||
<height>41</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>30</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Counter</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="SmartSlider" name="sliderGainR" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>340</x>
|
||||
<y>120</y>
|
||||
<x>580</x>
|
||||
<y>180</y>
|
||||
<width>171</width>
|
||||
<height>321</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="SmartSlider" name="sliderGainA" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>180</y>
|
||||
<width>171</width>
|
||||
<height>321</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="SmartSlider" name="sliderGainD" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>220</x>
|
||||
<y>180</y>
|
||||
<width>171</width>
|
||||
<height>321</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="SmartSlider" name="sliderGainS" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>400</x>
|
||||
<y>180</y>
|
||||
<width>171</width>
|
||||
<height>321</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
Reference in New Issue
Block a user