diff --git a/DrumMachine.pro b/DrumMachine.pro index 587edae..cab1ced 100755 --- a/DrumMachine.pro +++ b/DrumMachine.pro @@ -40,6 +40,8 @@ SOURCES += \ widgets/drumpadsamplewidget.cpp \ widgets/drumpadwidget.cpp \ widgets/loopstationpresetdetailwidget.cpp \ + widgets/loopstationsampleswidget.cpp \ + widgets/loopstationsamplewidget.cpp \ widgets/loopstationwidget.cpp \ widgets/mainwindow.cpp \ widgets/midibutton.cpp \ @@ -80,6 +82,8 @@ HEADERS += \ widgets/drumpadsamplewidget.h \ widgets/drumpadwidget.h \ widgets/loopstationpresetdetailwidget.h \ + widgets/loopstationsampleswidget.h \ + widgets/loopstationsamplewidget.h \ widgets/loopstationwidget.h \ widgets/mainwindow.h \ widgets/midibutton.h \ @@ -98,6 +102,8 @@ FORMS += \ widgets/drumpadsamplewidget.ui \ widgets/drumpadwidget.ui \ widgets/loopstationpresetdetailwidget.ui \ + widgets/loopstationsampleswidget.ui \ + widgets/loopstationsamplewidget.ui \ widgets/loopstationwidget.ui \ widgets/mainwindow.ui \ widgets/sequencerwidget.ui \ diff --git a/widgets/drumpadsampleswidget.h b/widgets/drumpadsampleswidget.h index 84245cb..0f59aee 100755 --- a/widgets/drumpadsampleswidget.h +++ b/widgets/drumpadsampleswidget.h @@ -1,11 +1,11 @@ #pragma once +#include + #include #include #include -#include - #include "drumpadpresets.h" namespace Ui { class DrumPadSamplesWidget; } diff --git a/widgets/drumpadwidget.ui b/widgets/drumpadwidget.ui index b318f3b..741da7f 100644 --- a/widgets/drumpadwidget.ui +++ b/widgets/drumpadwidget.ui @@ -13,99 +13,95 @@ Qt::Horizontal - - - - 9 - - - - - - - - - true - - - - - - - - 32 - 16777215 - - - - - - - - - - - - 32 - 16777215 - - - - - - - - - - - false - - - - 32 - 16777215 - - - - - - - - - - - - - false - - - true - - - - - - - - - 0 - - - - Properties - - - + + + Qt::Vertical + + + + + + + + + true + + + + + + + + 32 + 16777215 + + + + + + + + + + + + 32 + 16777215 + + + + + + + + + + + false + + + + 32 + 16777215 + + + + + + + + + + + false - - Samples - + + true + - - - + + + + + + 0 + + + + Properties + + + + + false + + + Samples + + + diff --git a/widgets/loopstationsampleswidget.cpp b/widgets/loopstationsampleswidget.cpp new file mode 100644 index 0000000..b186df0 --- /dev/null +++ b/widgets/loopstationsampleswidget.cpp @@ -0,0 +1,106 @@ +#include "loopstationsampleswidget.h" +#include "ui_loopstationsampleswidget.h" + +LoopStationSamplesWidget::LoopStationSamplesWidget(QWidget *parent) : + QWidget{parent}, + m_ui{std::make_unique()} +{ + m_ui->setupUi(this); +} + +LoopStationSamplesWidget::~LoopStationSamplesWidget() = default; + +void LoopStationSamplesWidget::loadSettings(DrumMachineSettings &settings) +{ + Q_UNUSED(settings) +} + +void LoopStationSamplesWidget::setPreset(const loopstation_presets::Preset &preset) +{ + Q_UNUSED(preset) +} + +void LoopStationSamplesWidget::midiReceived(const midi::MidiMessage &message) +{ + Q_UNUSED(message) +} + +void LoopStationSamplesWidget::writeSamples(frame_t *begin, frame_t *end) +{ + Q_UNUSED(begin) + Q_UNUSED(end) +} + +void LoopStationSamplesWidget::injectNetworkAccessManager(QNetworkAccessManager &networkAccessManager) +{ + Q_UNUSED(networkAccessManager) +} + +void LoopStationSamplesWidget::injectDecodingThread(QThread &thread) +{ + Q_UNUSED(thread) +} + +void LoopStationSamplesWidget::unsendColors() +{ + +} + +void LoopStationSamplesWidget::sendColors() +{ + +} + +std::array, 48> LoopStationSamplesWidget::getWidgets() +{ + return { + std::ref(*m_ui->sampleWidget0), + std::ref(*m_ui->sampleWidget1), + std::ref(*m_ui->sampleWidget2), + std::ref(*m_ui->sampleWidget3), + std::ref(*m_ui->sampleWidget4), + std::ref(*m_ui->sampleWidget5), + std::ref(*m_ui->sampleWidget6), + std::ref(*m_ui->sampleWidget7), + std::ref(*m_ui->sampleWidget8), + std::ref(*m_ui->sampleWidget9), + std::ref(*m_ui->sampleWidget10), + std::ref(*m_ui->sampleWidget11), + std::ref(*m_ui->sampleWidget12), + std::ref(*m_ui->sampleWidget13), + std::ref(*m_ui->sampleWidget14), + std::ref(*m_ui->sampleWidget15), + std::ref(*m_ui->sampleWidget16), + std::ref(*m_ui->sampleWidget17), + std::ref(*m_ui->sampleWidget18), + std::ref(*m_ui->sampleWidget19), + std::ref(*m_ui->sampleWidget20), + std::ref(*m_ui->sampleWidget21), + std::ref(*m_ui->sampleWidget22), + std::ref(*m_ui->sampleWidget23), + std::ref(*m_ui->sampleWidget24), + std::ref(*m_ui->sampleWidget25), + std::ref(*m_ui->sampleWidget26), + std::ref(*m_ui->sampleWidget27), + std::ref(*m_ui->sampleWidget28), + std::ref(*m_ui->sampleWidget29), + std::ref(*m_ui->sampleWidget30), + std::ref(*m_ui->sampleWidget31), + std::ref(*m_ui->sampleWidget32), + std::ref(*m_ui->sampleWidget33), + std::ref(*m_ui->sampleWidget34), + std::ref(*m_ui->sampleWidget35), + std::ref(*m_ui->sampleWidget36), + std::ref(*m_ui->sampleWidget37), + std::ref(*m_ui->sampleWidget38), + std::ref(*m_ui->sampleWidget39), + std::ref(*m_ui->sampleWidget40), + std::ref(*m_ui->sampleWidget41), + std::ref(*m_ui->sampleWidget42), + std::ref(*m_ui->sampleWidget43), + std::ref(*m_ui->sampleWidget44), + std::ref(*m_ui->sampleWidget45), + std::ref(*m_ui->sampleWidget46), + std::ref(*m_ui->sampleWidget47), + }; +} diff --git a/widgets/loopstationsampleswidget.h b/widgets/loopstationsampleswidget.h new file mode 100644 index 0000000..6828fa8 --- /dev/null +++ b/widgets/loopstationsampleswidget.h @@ -0,0 +1,47 @@ +#pragma once + +#include + +#include +#include +#include + +#include "loopstationpresets.h" + +namespace Ui { class LoopStationSamplesWidget; } +namespace midi { struct MidiMessage; } +class QNetworkAccessManager; +class LoopStationSampleWidget; +class DrumMachineSettings; +struct frame_t; + +class LoopStationSamplesWidget : public QWidget +{ + Q_OBJECT + +public: + explicit LoopStationSamplesWidget(QWidget *parent = nullptr); + ~LoopStationSamplesWidget(); + + void loadSettings(DrumMachineSettings &settings); + + void setPreset(const loopstation_presets::Preset &preset); + + void midiReceived(const midi::MidiMessage &message); + + void writeSamples(frame_t *begin, frame_t *end); + + void injectNetworkAccessManager(QNetworkAccessManager &networkAccessManager); + void injectDecodingThread(QThread &thread); + + void unsendColors(); + void sendColors(); + +signals: + void sendMidi(const midi::MidiMessage &midiMsg); + +private: + std::array, 48> getWidgets(); + + const std::unique_ptr m_ui; +}; diff --git a/widgets/loopstationsampleswidget.ui b/widgets/loopstationsampleswidget.ui new file mode 100644 index 0000000..54f2dfc --- /dev/null +++ b/widgets/loopstationsampleswidget.ui @@ -0,0 +1,235 @@ + + + LoopStationSamplesWidget + + + + 0 + 0 + 1254 + 890 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + LoopStationSampleWidget + QWidget +
widgets/loopstationsamplewidget.h
+ 1 +
+
+ + +
diff --git a/widgets/loopstationsamplewidget.cpp b/widgets/loopstationsamplewidget.cpp new file mode 100644 index 0000000..ae28cb2 --- /dev/null +++ b/widgets/loopstationsamplewidget.cpp @@ -0,0 +1,11 @@ +#include "loopstationsamplewidget.h" +#include "ui_loopstationsamplewidget.h" + +LoopStationSampleWidget::LoopStationSampleWidget(QWidget *parent) : + QFrame{parent}, + m_ui{std::make_unique()} +{ + m_ui->setupUi(this); +} + +LoopStationSampleWidget::~LoopStationSampleWidget() = default; diff --git a/widgets/loopstationsamplewidget.h b/widgets/loopstationsamplewidget.h new file mode 100644 index 0000000..b2403d6 --- /dev/null +++ b/widgets/loopstationsamplewidget.h @@ -0,0 +1,19 @@ +#pragma once + +#include + +#include + +namespace Ui { class LoopStationSampleWidget; } + +class LoopStationSampleWidget : public QFrame +{ + Q_OBJECT + +public: + explicit LoopStationSampleWidget(QWidget *parent = nullptr); + ~LoopStationSampleWidget(); + +private: + const std::unique_ptr m_ui; +}; diff --git a/widgets/loopstationsamplewidget.ui b/widgets/loopstationsamplewidget.ui new file mode 100644 index 0000000..40eeaa4 --- /dev/null +++ b/widgets/loopstationsamplewidget.ui @@ -0,0 +1,65 @@ + + + LoopStationSampleWidget + + + + 0 + 0 + 400 + 300 + + + + Form + + + QFrame::Panel + + + QFrame::Sunken + + + + + + TextLabel + + + + + + + + + + 32 + 16777215 + + + + + + + + + + + + + TextLabel + + + + + + + + MidiButton + QPushButton +
widgets/midibutton.h
+
+
+ + +
diff --git a/widgets/loopstationwidget.cpp b/widgets/loopstationwidget.cpp index 3f15396..5aac81b 100644 --- a/widgets/loopstationwidget.cpp +++ b/widgets/loopstationwidget.cpp @@ -38,19 +38,19 @@ LoopStationWidget::~LoopStationWidget() = default; void LoopStationWidget::writeSamples(frame_t *begin, frame_t *end) { - Q_UNUSED(begin) - Q_UNUSED(end) + m_ui->samplesWidget->writeSamples(begin, end); } void LoopStationWidget::injectNetworkAccessManager(QNetworkAccessManager &networkAccessManager) { m_networkAccessManager = &networkAccessManager; loadPresets(); + m_ui->samplesWidget->injectNetworkAccessManager(networkAccessManager); } void LoopStationWidget::injectDecodingThread(QThread &thread) { - Q_UNUSED(thread) + m_ui->samplesWidget->injectDecodingThread(thread); } void LoopStationWidget::loadSettings(DrumMachineSettings &settings) @@ -62,6 +62,8 @@ void LoopStationWidget::loadSettings(DrumMachineSettings &settings) connect(m_ui->pushButtonUp, &MidiButton::learnSettingChanged, m_settings, &DrumMachineSettings::setLoopstationPrevPreset); connect(m_ui->pushButtonDown, &MidiButton::learnSettingChanged, m_settings, &DrumMachineSettings::setLoopstationNextPreset); + + m_ui->samplesWidget->loadSettings(settings); } void LoopStationWidget::unsendColors() @@ -80,6 +82,8 @@ void LoopStationWidget::unsendColors() .note = m_ui->pushButtonDown->learnSetting().note, .velocity = 0 }); + + m_ui->samplesWidget->unsendColors(); } void LoopStationWidget::sendColors() @@ -98,6 +102,8 @@ void LoopStationWidget::sendColors() .note = m_ui->pushButtonDown->learnSetting().note, .velocity = 127 }); + + m_ui->samplesWidget->sendColors(); } void LoopStationWidget::midiReceived(const midi::MidiMessage &message) @@ -105,7 +111,7 @@ void LoopStationWidget::midiReceived(const midi::MidiMessage &message) m_ui->pushButtonUp->midiReceived(message); m_ui->pushButtonDown->midiReceived(message); - // TODO + m_ui->samplesWidget->midiReceived(message); } void LoopStationWidget::currentRowChanged(const QModelIndex ¤t) @@ -129,6 +135,7 @@ void LoopStationWidget::currentRowChanged(const QModelIndex ¤t) qWarning() << "no settings available"; m_ui->presetDetailWidget->setPreset(preset); + m_ui->samplesWidget->setPreset(preset); } void LoopStationWidget::loadPresets() diff --git a/widgets/loopstationwidget.ui b/widgets/loopstationwidget.ui index 929dd1a..0e1c91f 100644 --- a/widgets/loopstationwidget.ui +++ b/widgets/loopstationwidget.ui @@ -13,97 +13,86 @@ Qt::Horizontal - - - - - - - - true - - - - - - - - 32 - 16777215 - - - - - - - - - - - - 32 - 16777215 - - - - - - - - - - - false - - - - 32 - 16777215 - - - - - - - - - - - - - false - - - true - - - - - - - - Properties - + + + Qt::Vertical + + + + + + + + + true + + + + + + + + 32 + 16777215 + + + + + + + + + + + + 32 + 16777215 + + + + + + + + + + + false + + + + 32 + 16777215 + + + + + + + + + + + + + false + + + true + - - - - - - - - - 20 - 10 - 261 - 18 - - - - Hier könnte ihre LoopStation stehen. - + + + + + + + Properties + + + @@ -117,6 +106,12 @@
widgets/loopstationpresetdetailwidget.h
1
+ + LoopStationSamplesWidget + QWidget +
widgets/loopstationsampleswidget.h
+ 1 +
diff --git a/widgets/mainwindow.cpp b/widgets/mainwindow.cpp index 81a8387..28cd439 100755 --- a/widgets/mainwindow.cpp +++ b/widgets/mainwindow.cpp @@ -338,28 +338,31 @@ void MainWindow::unsendColors(int index) void MainWindow::sendColors(int index) { + if (true) { - const auto &learnSetting = m_ui->tabWidget->learnSetting(index); - emit sendMidi(midi::MidiMessage { - .channel = learnSetting.channel, - .cmd = learnSetting.cmd, - .flag = true, - .note = learnSetting.note, - .velocity = 3 - }); + { + const auto &learnSetting = m_ui->tabWidget->learnSetting(index); + emit sendMidi(midi::MidiMessage { + .channel = learnSetting.channel, + .cmd = learnSetting.cmd, + .flag = true, + .note = learnSetting.note, + .velocity = 3 + }); + } + + if (index == 0) + m_ui->drumPadWidget->sendColors(); + else if (index == 1) + m_ui->loopStationWidget->sendColors(); + else if (index == 2) + m_ui->djWidget->sendColors(); + else if (index == 3) + m_ui->synthisizerWidget->sendColors(); + + return; } - if (index == 0) - m_ui->drumPadWidget->sendColors(); - else if (index == 1) - m_ui->loopStationWidget->sendColors(); - else if (index == 2) - m_ui->djWidget->sendColors(); - else if (index == 3) - m_ui->synthisizerWidget->sendColors(); - - return; - // this was just for debugging all the available colors on novation launchpad mk1 int k{0};