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 797f168f64307163e1b4df0984af4063e2bdce6e
parent 2bd8546267bd4a52c09224dc8dc9fbb8b8a86c44
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Thu,  1 Aug 2024 02:26:01 +0200

make sysex delay adjustable and provide samplerate via constructor

Diffstat:
Msource/hardwareLib/sciMidi.cpp | 10++++++++--
Msource/hardwareLib/sciMidi.h | 8+++++++-
Msource/mqLib/mqhardware.cpp | 2+-
Msource/nord/n2x/n2xLib/n2xmc.cpp | 4+++-
Msource/xtLib/xtHardware.cpp | 2+-
5 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/source/hardwareLib/sciMidi.cpp b/source/hardwareLib/sciMidi.cpp @@ -12,7 +12,7 @@ namespace hwLib static constexpr float g_sysexSendDelaySeconds = 0.1f; static constexpr uint32_t g_sysexSendDelaySize = 500; - SciMidi::SciMidi(mc68k::Qsm& _qsm) : m_qsm(_qsm) + SciMidi::SciMidi(mc68k::Qsm& _qsm, const float _samplerate) : m_qsm(_qsm), m_samplerate(_samplerate), m_sysexDelaySeconds(g_sysexSendDelaySeconds), m_sysexDelaySize(g_sysexSendDelaySize) { } @@ -43,7 +43,7 @@ namespace hwLib for (const auto b : msg) m_qsm.writeSciRX(b); - m_remainingSysexDelay = static_cast<uint32_t>(static_cast<float>(msg.size()) * 44100.0f * g_sysexSendDelaySeconds / static_cast<float>(g_sysexSendDelaySize)); + m_remainingSysexDelay = static_cast<uint32_t>(static_cast<float>(msg.size()) * m_samplerate * m_sysexDelaySeconds / static_cast<float>(m_sysexDelaySize)); m_pendingSysexBuffers.pop_front(); } @@ -117,4 +117,10 @@ namespace hwLib _result.push_back(d); } } + + void SciMidi::setSysexDelay(const float _seconds, const uint32_t _size) + { + m_sysexDelaySeconds = _seconds; + m_sysexDelaySize = _size; + } } diff --git a/source/hardwareLib/sciMidi.h b/source/hardwareLib/sciMidi.h @@ -20,7 +20,7 @@ namespace hwLib class SciMidi { public: - explicit SciMidi(mc68k::Qsm& _qsm); + explicit SciMidi(mc68k::Qsm& _qsm, float _samplerate); void process(uint32_t _numSamples); @@ -40,9 +40,13 @@ namespace hwLib void read(std::vector<uint8_t>& _result); + void setSysexDelay(const float _seconds, const uint32_t _size); + private: mc68k::Qsm& m_qsm; + const float m_samplerate; + bool m_readingSysex = false; bool m_writingSysex = false; uint32_t m_remainingSysexDelay = 0; @@ -50,5 +54,7 @@ namespace hwLib std::deque< std::vector<uint8_t> > m_pendingSysexBuffers; std::vector<uint8_t> m_pendingSysexMessage; std::mutex m_mutex; + float m_sysexDelaySeconds; + uint32_t m_sysexDelaySize; }; } diff --git a/source/mqLib/mqhardware.cpp b/source/mqLib/mqhardware.cpp @@ -16,7 +16,7 @@ namespace mqLib #else , m_dsps{MqDsp(*this, m_uc.getHdi08A().getHdi08(), 0)} #endif - , m_midi(m_uc.getQSM()) + , m_midi(m_uc.getQSM(), 44100) { if(!m_rom.isValid()) throw synthLib::DeviceException(synthLib::DeviceError::FirmwareMissing); diff --git a/source/nord/n2x/n2xLib/n2xmc.cpp b/source/nord/n2x/n2xLib/n2xmc.cpp @@ -25,7 +25,7 @@ namespace n2x : m_flash(_hardware) , m_hdi08(m_hdi08A, m_hdi08B) , m_panel(_hardware) - , m_midi(getQSM()) + , m_midi(getQSM(), g_samplerate) { if(!_rom.isValid()) return; @@ -33,6 +33,8 @@ namespace n2x m_rom = _rom.data(); m_ram.fill(0); + m_midi.setSysexDelay(0.0f, 1); + // dumpAssembly("n2x_68k.asm", g_romAddress, g_romSize); reset(); diff --git a/source/xtLib/xtHardware.cpp b/source/xtLib/xtHardware.cpp @@ -14,7 +14,7 @@ namespace xt , m_rom(RomLoader::findROM()) , m_uc(m_rom) , m_dsps{DSP(*this, m_uc.getHdi08A().getHdi08(), 0)} - , m_midi(m_uc.getQSM()) + , m_midi(m_uc.getQSM(), 40000) { if(!m_rom.isValid()) throw synthLib::DeviceException(synthLib::DeviceError::FirmwareMissing);