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

dspSingle.h (2411B)


      1 #pragma once
      2 
      3 #include "romfile.h"
      4 
      5 #include "dsp56kEmu/dspthread.h"
      6 #include "dsp56kEmu/memory.h"
      7 #include "dsp56kEmu/peripherals.h"
      8 
      9 #include "synthLib/audioTypes.h"
     10 
     11 namespace dsp56k
     12 {
     13 	class Jit;
     14 }
     15 
     16 namespace virusLib
     17 {
     18 	struct FrontpanelState;
     19 
     20 	class DspSingle
     21 	{
     22 	public:
     23 		DspSingle(uint32_t _memorySize, bool _use56367Peripherals = false, const char* _name = nullptr, bool _use56303Peripherals = false);
     24 		virtual ~DspSingle();
     25 
     26 		dsp56k::HDI08& getHDI08() { return m_hdi08; }
     27 		dsp56k::Audio& getAudio() { return m_audio; }
     28 		dsp56k::EsxiClock& getEsxiClock() { return m_esxiClock; }
     29 		dsp56k::Peripherals56362& getPeriphX() { return m_periphX362; }
     30 		dsp56k::Peripherals56367& getPeriphY() { return m_periphY367; }
     31 		dsp56k::PeripheralsNop& getPeriphNop() { return m_periphNop; }
     32 		dsp56k::DSP& getDSP() const { return *m_dsp; }
     33 		dsp56k::Jit& getJIT() const { return *m_jit; }
     34 		dsp56k::Memory& getMemory() const {return *m_memory; }
     35 
     36 		void startDSPThread(bool _createDebugger);
     37 
     38 		virtual void processAudio(const synthLib::TAudioInputs& _inputs, const synthLib::TAudioOutputs& _outputs, size_t _samples, uint32_t _latency);
     39 		virtual void processAudio(const synthLib::TAudioInputsInt& _inputs, const synthLib::TAudioOutputsInt& _outputs, size_t _samples, uint32_t _latency);
     40 
     41 		void disableESSI1();
     42 		void drainESSI1();
     43 
     44 		std::thread boot(const ROMFile::BootRom& _bootRom, const std::vector<dsp56k::TWord>& _commandStream);
     45 
     46 		template<typename T> static void ensureSize(std::vector<T>& _buf, size_t _size)
     47 		{
     48 			if(_buf.size() >= _size)
     49 				return;
     50 
     51 			_buf.resize(_size, static_cast<T>(0));
     52 		}
     53 
     54 	protected:
     55 		std::vector<uint32_t> m_dummyBufferInI;
     56 		std::vector<uint32_t> m_dummyBufferOutI;
     57 		std::vector<float> m_dummyBufferInF;
     58 		std::vector<float> m_dummyBufferOutF;
     59 
     60 	private:
     61 		const std::string m_name;
     62 		std::vector<uint8_t> m_buffer;
     63 
     64 		dsp56k::DefaultMemoryValidator m_memoryValidator;
     65 		dsp56k::Peripherals56367 m_periphY367;
     66 		dsp56k::Peripherals56362 m_periphX362;
     67 		dsp56k::Peripherals56303 m_periphX303;
     68 		dsp56k::PeripheralsNop m_periphNop;
     69 
     70 		dsp56k::HDI08& m_hdi08;
     71 		dsp56k::Audio& m_audio;
     72 		dsp56k::EsxiClock& m_esxiClock;
     73 
     74 		dsp56k::Memory* m_memory = nullptr;
     75 		dsp56k::DSP* m_dsp = nullptr;
     76 		dsp56k::Jit* m_jit = nullptr;
     77 
     78 		std::unique_ptr<dsp56k::DSPThread> m_dspThread;
     79 
     80 		std::vector<dsp56k::TWord> m_commandStream;
     81 		uint32_t m_commandStreamReadIndex = 0;
     82 	};
     83 }