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 1d83447339a0f15dfd5328c3b455982f093d70cb
parent 2f91b32a0254bf30926082ce0916fb7e6fc8c039
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Sun, 28 Jul 2024 22:56:05 +0200

more cleanup work

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

diff --git a/source/nord/n2x/n2xLib/n2xdevice.cpp b/source/nord/n2x/n2xLib/n2xdevice.cpp @@ -1,5 +1,75 @@ #include "n2xdevice.h" +#include "n2xhardware.h" +#include "n2xtypes.h" + namespace n2x { + Device::Device() + { + m_hardware.reset(new Hardware()); + } + + float Device::getSamplerate() const + { + return g_samplerate; + } + + bool Device::isValid() const + { + return m_hardware->isValid(); + } + + bool Device::getState(std::vector<uint8_t>& _state, synthLib::StateType _type) + { + // TODO + return false; + } + + bool Device::setState(const std::vector<uint8_t>& _state, synthLib::StateType _type) + { + // TODO + return false; + } + + uint32_t Device::getChannelCountIn() + { + return 0; + } + + uint32_t Device::getChannelCountOut() + { + return 4; + } + + bool Device::setDspClockPercent(const uint32_t _percent) + { + bool res = m_hardware->getDSPA().getPeriph().getEsaiClock().setSpeedPercent(_percent); + res &= m_hardware->getDSPB().getPeriph().getEsaiClock().setSpeedPercent(_percent); + return res; + } + + uint32_t Device::getDspClockPercent() const + { + return m_hardware->getDSPA().getPeriph().getEsaiClock().getSpeedPercent(); + } + + uint64_t Device::getDspClockHz() const + { + return m_hardware->getDSPA().getPeriph().getEsaiClock().getSpeedInHz(); + } + + void Device::readMidiOut(std::vector<synthLib::SMidiEvent>& _midiOut) + { + } + + void Device::processAudio(const synthLib::TAudioInputs& _inputs, const synthLib::TAudioOutputs& _outputs, size_t _samples) + { + m_hardware->processAudio(_outputs, static_cast<uint32_t>(_samples), getExtraLatencySamples()); + } + + bool Device::sendMidi(const synthLib::SMidiEvent& _ev, std::vector<synthLib::SMidiEvent>& _response) + { + return false; + } } diff --git a/source/nord/n2x/n2xLib/n2xdevice.h b/source/nord/n2x/n2xLib/n2xdevice.h @@ -1,5 +1,34 @@ #pragma once +#include <memory> + +#include "wLib/wDevice.h" + namespace n2x { + class Hardware; + + class Device : public synthLib::Device + { + public: + Device(); + + float getSamplerate() const override; + bool isValid() const override; + bool getState(std::vector<uint8_t>& _state, synthLib::StateType _type) override; + bool setState(const std::vector<uint8_t>& _state, synthLib::StateType _type) override; + uint32_t getChannelCountIn() override; + uint32_t getChannelCountOut() override; + bool setDspClockPercent(uint32_t _percent) override; + uint32_t getDspClockPercent() const override; + uint64_t getDspClockHz() const override; + + protected: + void readMidiOut(std::vector<synthLib::SMidiEvent>& _midiOut) override; + void processAudio(const synthLib::TAudioInputs& _inputs, const synthLib::TAudioOutputs& _outputs, size_t _samples) override; + bool sendMidi(const synthLib::SMidiEvent& _ev, std::vector<synthLib::SMidiEvent>& _response) override; + + private: + std::unique_ptr<Hardware> m_hardware = nullptr; + }; } diff --git a/source/nord/n2x/n2xLib/n2xhardware.cpp b/source/nord/n2x/n2xLib/n2xhardware.cpp @@ -90,6 +90,19 @@ namespace n2x outputs[3] += processCount; } } + + void Hardware::processAudio(const synthLib::TAudioOutputs& _outputs, const uint32_t _frames, const uint32_t _latency) + { + processAudio(_frames, _latency); + + for(size_t i=0; i<_frames; ++i) + { + _outputs[0][i] = dsp56k::dsp2sample<float>(m_audioOutputs[0][i]); + _outputs[1][i] = dsp56k::dsp2sample<float>(m_audioOutputs[1][i]); + _outputs[2][i] = dsp56k::dsp2sample<float>(m_audioOutputs[2][i]); + _outputs[3][i] = dsp56k::dsp2sample<float>(m_audioOutputs[3][i]); + } + } void Hardware::ensureBufferSize(const uint32_t _frames) { diff --git a/source/nord/n2x/n2xLib/n2xhardware.h b/source/nord/n2x/n2xLib/n2xhardware.h @@ -3,6 +3,7 @@ #include "n2xdsp.h" #include "n2xmc.h" #include "n2xrom.h" +#include "synthLib/audioTypes.h" namespace n2x { @@ -30,6 +31,7 @@ namespace n2x bool getButtonState(ButtonType _type) const; void setButtonState(ButtonType _type, bool _pressed); + void processAudio(const synthLib::TAudioOutputs& _outputs, uint32_t _frames, uint32_t _latency); private: void ensureBufferSize(uint32_t _frames);