commit 5d0b5f31a6c1023e4cf2c29061df989de88a23ec
parent 5eed81eaa783a1e4a7cfe5ff15bfe1c0307cffa8
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date: Sun, 28 Jul 2024 22:19:41 +0200
midi function naming / allow to send SMidiEvent directly
Diffstat:
4 files changed, 39 insertions(+), 25 deletions(-)
diff --git a/source/hardwareLib/sciMidi.cpp b/source/hardwareLib/sciMidi.cpp
@@ -4,6 +4,8 @@
#include "mc68k/qsm.h"
+#include "synthLib/midiBufferParser.h"
+
namespace hwLib
{
// pause 0.1 seconds for a sysex size of 500, delay is calculated for other sysex sizes accordingly
@@ -47,7 +49,7 @@ namespace hwLib
}
}
- void SciMidi::writeMidi(const uint8_t _byte)
+ void SciMidi::write(const uint8_t _byte)
{
std::unique_lock lock(m_mutex);
@@ -76,7 +78,24 @@ namespace hwLib
}
}
- void SciMidi::readTransmitBuffer(std::vector<uint8_t>& _result)
+ void SciMidi::write(const synthLib::SMidiEvent& _e)
+ {
+ if(!_e.sysex.empty())
+ {
+ write(_e.sysex);
+ }
+ else
+ {
+ write(_e.a);
+ const auto len = synthLib::MidiBufferParser::lengthFromStatusByte(_e.a);
+ if (len > 1)
+ write(_e.b);
+ if (len > 2)
+ write(_e.c);
+ }
+ }
+
+ void SciMidi::read(std::vector<uint8_t>& _result)
{
std::deque<uint16_t> midiData;
m_qsm.readSciTX(midiData);
diff --git a/source/hardwareLib/sciMidi.h b/source/hardwareLib/sciMidi.h
@@ -5,6 +5,11 @@
#include <cstdint>
#include <mutex>
+namespace synthLib
+{
+ struct SMidiEvent;
+}
+
namespace mc68k
{
class Qsm;
@@ -19,18 +24,21 @@ namespace hwLib
void process(uint32_t _numSamples);
- void writeMidi(uint8_t _byte);
- void writeMidi(const std::initializer_list<uint8_t>& _bytes)
+ void write(uint8_t _byte);
+ void write(const std::initializer_list<uint8_t>& _bytes)
{
for (const uint8_t byte : _bytes)
- writeMidi(byte);
+ write(byte);
}
- void writeMidi(const std::vector<uint8_t>& _bytes)
+ void write(const std::vector<uint8_t>& _bytes)
{
for (const uint8_t byte : _bytes)
- writeMidi(byte);
+ write(byte);
}
- void readTransmitBuffer(std::vector<uint8_t>& _result);
+ void write(const synthLib::SMidiEvent& _e);
+
+
+ void read(std::vector<uint8_t>& _result);
private:
mc68k::Qsm& m_qsm;
diff --git a/source/mqLib/mqhardware.cpp b/source/mqLib/mqhardware.cpp
@@ -207,8 +207,8 @@ namespace mqLib
void Hardware::setGlobalDefaultParameters()
{
- m_midi.writeMidi({0xf0,0x3e,0x10,0x7f,0x24,0x00,0x07,0x02,0xf7}); // Control Send = SysEx
- m_midi.writeMidi({0xf0,0x3e,0x10,0x7f,0x24,0x00,0x08,0x01,0xf7}); // Control Receive = on
+ m_midi.write({0xf0,0x3e,0x10,0x7f,0x24,0x00,0x07,0x02,0xf7}); // Control Send = SysEx
+ m_midi.write({0xf0,0x3e,0x10,0x7f,0x24,0x00,0x08,0x01,0xf7}); // Control Receive = on
m_bootCompleted = true;
}
diff --git a/source/wLib/wHardware.cpp b/source/wLib/wHardware.cpp
@@ -71,7 +71,7 @@ namespace wLib
void Hardware::receiveMidi(std::vector<uint8_t>& _data)
{
- getMidi().readTransmitBuffer(_data);
+ getMidi().read(_data);
}
void Hardware::onEsaiCallback(dsp56k::Audio& _audio)
@@ -158,20 +158,7 @@ namespace wLib
if(e.offset > m_midiOffsetCounter)
break;
- if(!e.sysex.empty())
- {
- getMidi().writeMidi(e.sysex);
- }
- else
- {
- getMidi().writeMidi(e.a);
- const auto len = synthLib::MidiBufferParser::lengthFromStatusByte(e.a);
- if (len > 1)
- getMidi().writeMidi(e.b);
- if (len > 2)
- getMidi().writeMidi(e.c);
- }
-
+ getMidi().write(e);
m_midiIn.pop_front();
}
}