gearmulator

Emulation of classic VA synths of the late 90s/2000s that are based on Motorola 56300 family DSPs
Log | Files | Refs | Submodules | README | LICENSE

commit 2a4319e2cf93b1df98d775a9c96572e779e7439e
parent a98939a3c91a3890526eda148303664f9c1aa845
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Mon, 29 Jul 2024 17:08:57 +0200

midi support WIP

Diffstat:
Msource/nord/n2x/n2xLib/n2xdevice.cpp | 6+++++-
Msource/nord/n2x/n2xLib/n2xdevice.h | 2++
Msource/nord/n2x/n2xLib/n2xhardware.cpp | 13++++++++++++-
Msource/nord/n2x/n2xLib/n2xhardware.h | 6++++++
4 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/source/nord/n2x/n2xLib/n2xdevice.cpp b/source/nord/n2x/n2xLib/n2xdevice.cpp @@ -61,6 +61,10 @@ namespace n2x void Device::readMidiOut(std::vector<synthLib::SMidiEvent>& _midiOut) { + m_hardware->getMidi().read(m_midiOutBuffer); + m_midiParser.write(m_midiOutBuffer); + m_midiOutBuffer.clear(); + m_midiParser.getEvents(_midiOut); } void Device::processAudio(const synthLib::TAudioInputs& _inputs, const synthLib::TAudioOutputs& _outputs, size_t _samples) @@ -70,6 +74,6 @@ namespace n2x bool Device::sendMidi(const synthLib::SMidiEvent& _ev, std::vector<synthLib::SMidiEvent>& _response) { - return false; + return m_hardware->sendMidi(_ev); } } diff --git a/source/nord/n2x/n2xLib/n2xdevice.h b/source/nord/n2x/n2xLib/n2xdevice.h @@ -30,5 +30,7 @@ namespace n2x private: std::unique_ptr<Hardware> m_hardware = nullptr; + std::vector<uint8_t> m_midiOutBuffer; + synthLib::MidiBufferParser m_midiParser; }; } diff --git a/source/nord/n2x/n2xLib/n2xhardware.cpp b/source/nord/n2x/n2xLib/n2xhardware.cpp @@ -115,6 +115,13 @@ namespace n2x } } + bool Hardware::sendMidi(const synthLib::SMidiEvent& _ev) + { +// m_midiIn.push_back(_ev); + getMidi().write(_ev); + return true; + } + void Hardware::ensureBufferSize(const uint32_t _frames) { if(m_dummyInput.size() >= _frames) @@ -147,13 +154,17 @@ namespace n2x m_semDspAtoB.wait(); } + void Hardware::processMidiInput() + { + } + void Hardware::onEsaiCallbackB() { m_semDspAtoB.notify(); ++m_esaiFrameIndex; -// processMidiInput(); + processMidiInput(); if((m_esaiFrameIndex & (g_syncEsaiFrameRate-1)) == 0) m_esaiFrameAddedCv.notify_one(); diff --git a/source/nord/n2x/n2xLib/n2xhardware.h b/source/nord/n2x/n2xLib/n2xhardware.h @@ -5,6 +5,7 @@ #include "n2xrom.h" #include "synthLib/audioTypes.h" +#include "synthLib/midiTypes.h" namespace n2x { @@ -28,16 +29,20 @@ namespace n2x auto& getDSPA() { return m_dspA; } auto& getDSPB() { return m_dspB; } + auto& getMidi() { return m_uc.getMidi(); } + void haltDSPs(); void resumeDSPs(); bool getButtonState(ButtonType _type) const; void setButtonState(ButtonType _type, bool _pressed); void processAudio(const synthLib::TAudioOutputs& _outputs, uint32_t _frames, uint32_t _latency); + bool sendMidi(const synthLib::SMidiEvent& _ev); private: void ensureBufferSize(uint32_t _frames); void onEsaiCallbackA(); + void processMidiInput(); void onEsaiCallbackB(); void syncUCtoDSP(); void ucThreadFunc(); @@ -69,6 +74,7 @@ namespace n2x dsp56k::SpscSemaphore m_semDspAtoB; dsp56k::RingBuffer<dsp56k::Audio::RxFrame, 4, true> m_dspAtoBbuf; std::unique_ptr<std::thread> m_ucThread; + dsp56k::RingBuffer<synthLib::SMidiEvent, 256, true, true> m_midiIn; // DSP slowdown uint32_t m_maxEsaiCallbacks = 0;