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 2697e4314b24dd9c66c7bd3550e1bdc1e72b5607
parent 933e16e6c5f35586c11f3b2bcc210f6752feda7f
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Mon, 29 Jul 2024 14:37:53 +0200

move UC thread to hardware class

Diffstat:
Msource/nord/n2x/n2xLib/n2xhardware.cpp | 27+++++++++++++++++++++++++++
Msource/nord/n2x/n2xLib/n2xhardware.h | 3+++
Msource/nord/n2x/n2xTestConsole/n2xTestConsole.cpp | 20+-------------------
3 files changed, 31 insertions(+), 19 deletions(-)

diff --git a/source/nord/n2x/n2xLib/n2xhardware.cpp b/source/nord/n2x/n2xLib/n2xhardware.cpp @@ -1,5 +1,7 @@ #include "n2xhardware.h" +#include "dsp56kEmu/threadtools.h" + namespace n2x { constexpr uint32_t g_syncEsaiFrameRate = 16; @@ -20,8 +22,15 @@ namespace n2x m_dspA.getPeriph().getEsai().setCallback([this](dsp56k::Audio*){ onEsaiCallbackA(); }, 0); m_dspB.getPeriph().getEsai().setCallback([this](dsp56k::Audio*){ onEsaiCallbackB(); }, 0); + + m_ucThread.reset(new std::thread([this] + { + ucThreadFunc(); + })); } + Hardware::~Hardware() = default; + bool Hardware::isValid() const { return m_rom.isValid(); @@ -200,6 +209,24 @@ namespace n2x m_lastEsaiFrameIndex = esaiFrameIndex; } + void Hardware::ucThreadFunc() + { + dsp56k::ThreadTools::setCurrentThreadName("MC68331"); + dsp56k::ThreadTools::setCurrentThreadPriority(dsp56k::ThreadPriority::Highest); + + while(true) + { + processUC(); + processUC(); + processUC(); + processUC(); + processUC(); + processUC(); + processUC(); + processUC(); + } + } + void Hardware::haltDSPs() { if(m_dspHalted) diff --git a/source/nord/n2x/n2xLib/n2xhardware.h b/source/nord/n2x/n2xLib/n2xhardware.h @@ -12,6 +12,7 @@ namespace n2x public: using AudioOutputs = std::array<std::vector<dsp56k::TWord>, 4>; Hardware(); + ~Hardware(); bool isValid() const; @@ -38,6 +39,7 @@ namespace n2x void onEsaiCallbackA(); void onEsaiCallbackB(); void syncUCtoDSP(); + void ucThreadFunc(); Rom m_rom; Microcontroller m_uc; @@ -64,5 +66,6 @@ namespace n2x bool m_dspHalted = false; dsp56k::SpscSemaphore m_semDspAtoB; dsp56k::RingBuffer<dsp56k::Audio::RxFrame, 4, true> m_dspAtoBbuf; + std::unique_ptr<std::thread> m_ucThread; }; } diff --git a/source/nord/n2x/n2xTestConsole/n2xTestConsole.cpp b/source/nord/n2x/n2xTestConsole/n2xTestConsole.cpp @@ -1,8 +1,8 @@ #include <iostream> -#include "dsp56kEmu/threadtools.h" #include "n2xLib/n2xhardware.h" #include "n2xLib/n2xrom.h" + #include "synthLib/wavWriter.h" static constexpr bool g_factoryDemo = true; @@ -28,24 +28,6 @@ int main() hw->getDSPA().getDSPThread().setLogToStdout(true); hw->getDSPB().getDSPThread().setLogToStdout(true); - std::thread ucThread([&]() - { - dsp56k::ThreadTools::setCurrentThreadName("MC68331"); - dsp56k::ThreadTools::setCurrentThreadPriority(dsp56k::ThreadPriority::Highest); - - while(true) - { - hw->processUC(); - hw->processUC(); - hw->processUC(); - hw->processUC(); - hw->processUC(); - hw->processUC(); - hw->processUC(); - hw->processUC(); - } - }); - constexpr uint32_t blockSize = 64; std::vector<dsp56k::TWord> stereoOutput;