This commit is contained in:
2026-01-18 21:06:13 -06:00
parent c199a9b42f
commit b3fe941464
9 changed files with 22 additions and 36 deletions

View File

@@ -9,7 +9,7 @@ MidiController::MidiController(NoteQueue& queue) : noteQueue_(queue) {
midiIn_ = std::make_unique<RtMidiIn>();
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;

View File

@@ -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;
}

View File

@@ -6,6 +6,8 @@
#include <cstdint>
#include <chrono>
#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<NoteEvent, SIZE> buffer_;
std::array<NoteEvent, SYNTH_NOTE_QUEUE_SIZE> buffer_;
std::atomic<size_t> head_{ 0 };
std::atomic<size_t> tail_{ 0 };

View File

@@ -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<float>& out) const {
size_t w = writeIndex_.load(std::memory_order_relaxed);

View File

@@ -9,7 +9,7 @@ WavetableController::WavetableController() {
init();
std::cout << "wavetable init" << std::endl;
//std::cout << "wavetable init" << std::endl;
}

View File

@@ -4,8 +4,6 @@
#include <iostream>
// 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);

View File

@@ -2,6 +2,7 @@
#include "Scope.h"
#include "ui_Scope.h"
// TODO: fix include directories because what is this
#include "../../../synth/ScopeBuffer.h"
#include <QPainter>