From b3fe941464844f8c7f8ff461561b3e0d70752e81 Mon Sep 17 00:00:00 2001 From: Bliblank Date: Sun, 18 Jan 2026 21:06:13 -0600 Subject: [PATCH] comments --- CMakeLists.txt | 8 ++--- scripts/build.bat | 29 ++++++------------- src/MidiController.cpp | 6 ++-- src/NoteQueue.cpp | 4 +-- src/NoteQueue.h | 5 ++-- src/synth/ScopeBuffer.cpp | 1 + src/synth/WavetableController.cpp | 2 +- .../EnvelopeGenerator/EnvelopeGenerator.cpp | 2 -- src/ui/widgets/Scope/Scope.cpp | 1 + 9 files changed, 22 insertions(+), 36 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 50d0f52..de6e8cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,28 +9,23 @@ find_package(Qt6 REQUIRED COMPONENTS Widgets) if (WIN32) # windows 11 x86_64 - # Header-only target (real target, no ::) + # dont judge me i had a lot of issues with this add_library(rtaudio_headers INTERFACE) target_include_directories(rtaudio_headers INTERFACE "C:/rtaudio/include" "C:/rtaudio/include/rtAudio" ) - - # Imported binary (real target, no ::) add_library(rtaudio_binary SHARED IMPORTED) set_target_properties(rtaudio_binary PROPERTIES IMPORTED_LOCATION "C:/rtaudio/bin/rtaudio.dll" IMPORTED_IMPLIB "C:/rtaudio/lib/rtaudio.lib" ) - - # Unified interface target add_library(rtaudio INTERFACE) target_link_libraries(rtaudio INTERFACE rtaudio_headers rtaudio_binary ) - # Public alias (this is where :: belongs) add_library(RtAudio::RtAudio ALIAS rtaudio) add_library(rtmidi_headers INTERFACE) @@ -59,6 +54,7 @@ endif() qt_standard_project_setup() +# TODO: prob fix this to make it less ugly qt_add_executable(metabolus src/main.cpp src/ui/MainWindow.cpp diff --git a/scripts/build.bat b/scripts/build.bat index 15999a5..8ee5bbb 100644 --- a/scripts/build.bat +++ b/scripts/build.bat @@ -1,9 +1,7 @@ @echo off setlocal -REM ================================ -REM Configuration -REM ================================ +REM config set BUILD_DIR=build set CONFIG=Release @@ -12,22 +10,18 @@ set QT_ROOT=C:\Qt\6.10.1\msvc2022_64 set RTAUDIO_ROOT=C:\rtaudio set RTMIDI_ROOT=C:\rtmidi -REM ================================ -REM Environment setup -REM ================================ +REM setup call "%ProgramFiles%\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat" set PATH=%QT_ROOT%\bin;%PATH% -REM ================================ -REM Configure -REM ================================ - if not exist %BUILD_DIR% ( mkdir %BUILD_DIR% ) +REM configure + cmake -S . -B %BUILD_DIR% ^ -G Ninja ^ -DCMAKE_BUILD_TYPE=%CONFIG% ^ @@ -36,17 +30,12 @@ cmake -S . -B %BUILD_DIR% ^ if errorlevel 1 goto error -REM ================================ -REM Build -REM ================================ - +REM build cmake --build %BUILD_DIR% if errorlevel 1 goto error -REM ================================ -REM Deploy Qt + RtAudio -REM ================================ +REM link dlls cd %BUILD_DIR% @@ -56,14 +45,14 @@ copy "%RTAUDIO_ROOT%\bin\rtaudio.dll" . copy "%RTMIDI_ROOT%\bin\rtmidi.dll" . echo. -echo Build successful. +echo Build successful goto end :error echo. -echo Build FAILED. +echo Build failed exit /b 1 :end endlocal -pause \ No newline at end of file +pause diff --git a/src/MidiController.cpp b/src/MidiController.cpp index f1422e8..e2aee4e 100644 --- a/src/MidiController.cpp +++ b/src/MidiController.cpp @@ -9,7 +9,7 @@ MidiController::MidiController(NoteQueue& queue) : noteQueue_(queue) { midiIn_ = std::make_unique(); midiIn_->ignoreTypes(false, false, false); } catch (RtMidiError& e) { - std::cerr << "RtMidi init failed: " << e.getMessage() << std::endl; + std::cout << "RtMidi init failed: " << e.getMessage() << std::endl; } // TODO: this still doesnt work on windows } @@ -22,7 +22,7 @@ MidiController::~MidiController() { bool MidiController::openDefaultPort() { if (!midiIn_) return false; if (midiIn_->getPortCount() == 0) { - std::cerr << "No MIDI input ports available\n"; + std::cout << "No MIDI input ports available" << std::endl; return false; } return openPort(0); @@ -34,7 +34,7 @@ bool MidiController::openPort(unsigned int index) { try { midiIn_->openPort(index); midiIn_->setCallback(&MidiController::midiCallback, this); - std::cout << "Opened MIDI port: " << midiIn_->getPortName(index) << "\n"; + std::cout << "Opened MIDI port: " << midiIn_->getPortName(index) << std::endl; return true; } catch (RtMidiError& e) { std::cerr << e.getMessage() << std::endl; diff --git a/src/NoteQueue.cpp b/src/NoteQueue.cpp index 85df585..1306af7 100644 --- a/src/NoteQueue.cpp +++ b/src/NoteQueue.cpp @@ -5,7 +5,7 @@ // add event to noteQueue, called by MidiController or keyboardController bool NoteQueue::push(const NoteEvent& event) { size_t head = head_.load(std::memory_order_relaxed); - size_t next = (head + 1) % SIZE; + size_t next = (head + 1) % SYNTH_NOTE_QUEUE_SIZE; if(next == tail_.load(std::memory_order_relaxed)) return false; // full @@ -22,7 +22,7 @@ bool NoteQueue::pop(NoteEvent& event) { if(tail == head_.load(std::memory_order_acquire)) return false; // empty event = buffer_[tail]; - tail_.store((tail + 1) % SIZE, std::memory_order_release); + tail_.store((tail + 1) % SYNTH_NOTE_QUEUE_SIZE, std::memory_order_release); return true; } diff --git a/src/NoteQueue.h b/src/NoteQueue.h index 8d87e6f..811dcd8 100644 --- a/src/NoteQueue.h +++ b/src/NoteQueue.h @@ -6,6 +6,8 @@ #include #include +#define SYNTH_NOTE_QUEUE_SIZE 128 + enum class NoteEventType { NoteOn, NoteOff @@ -29,9 +31,8 @@ public: bool pop(NoteEvent& event); private: - static constexpr size_t SIZE = 128; - std::array buffer_; + std::array buffer_; std::atomic head_{ 0 }; std::atomic tail_{ 0 }; diff --git a/src/synth/ScopeBuffer.cpp b/src/synth/ScopeBuffer.cpp index e418cdb..8e9263f 100644 --- a/src/synth/ScopeBuffer.cpp +++ b/src/synth/ScopeBuffer.cpp @@ -11,6 +11,7 @@ void ScopeBuffer::push(float sample) { buffer_[w % buffer_.size()] = sample; } +// TODO: needs a mutex to prevent flickering // outputs value from the scope buffer, called by the scope widget void ScopeBuffer::read(std::vector& out) const { size_t w = writeIndex_.load(std::memory_order_relaxed); diff --git a/src/synth/WavetableController.cpp b/src/synth/WavetableController.cpp index 791d81d..4fa6c7b 100644 --- a/src/synth/WavetableController.cpp +++ b/src/synth/WavetableController.cpp @@ -9,7 +9,7 @@ WavetableController::WavetableController() { init(); - std::cout << "wavetable init" << std::endl; + //std::cout << "wavetable init" << std::endl; } diff --git a/src/ui/widgets/EnvelopeGenerator/EnvelopeGenerator.cpp b/src/ui/widgets/EnvelopeGenerator/EnvelopeGenerator.cpp index 21ec020..5b961c5 100644 --- a/src/ui/widgets/EnvelopeGenerator/EnvelopeGenerator.cpp +++ b/src/ui/widgets/EnvelopeGenerator/EnvelopeGenerator.cpp @@ -4,8 +4,6 @@ #include -// TODO: package the rogue sliders into the envelopeGenerators with a "base" column (its what the "peak" slider in the esp synth was supposed to be) - EnvelopeGenerator::EnvelopeGenerator(QWidget* parent) : QWidget(parent), ui_(new Ui::EnvelopeGenerator) { ui_->setupUi(this); diff --git a/src/ui/widgets/Scope/Scope.cpp b/src/ui/widgets/Scope/Scope.cpp index 1b7e3f7..44b7765 100644 --- a/src/ui/widgets/Scope/Scope.cpp +++ b/src/ui/widgets/Scope/Scope.cpp @@ -2,6 +2,7 @@ #include "Scope.h" #include "ui_Scope.h" +// TODO: fix include directories because what is this #include "../../../synth/ScopeBuffer.h" #include