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

remoteDevice.h (2453B)


      1 #pragma once
      2 
      3 #include <condition_variable>
      4 #include <functional>
      5 #include <memory>
      6 
      7 #include "bridgeLib/commands.h"
      8 
      9 #include "synthLib/device.h"
     10 
     11 namespace bridgeLib
     12 {
     13 	struct PluginDesc;
     14 }
     15 
     16 namespace bridgeClient
     17 {
     18 	class DeviceConnection;
     19 
     20 	class RemoteDevice : public synthLib::Device
     21 	{
     22 	public:
     23 		RemoteDevice(const synthLib::DeviceCreateParams& _params, bridgeLib::PluginDesc&& _desc, const std::string& _host = {}, uint32_t _port = 0);
     24 		~RemoteDevice() override;
     25 		RemoteDevice(RemoteDevice&&) = delete;
     26 		RemoteDevice(const RemoteDevice&) = delete;
     27 		RemoteDevice& operator = (RemoteDevice&&) = delete;
     28 		RemoteDevice& operator = (const RemoteDevice&) = delete;
     29 
     30 		float getSamplerate() const override;
     31 		bool isValid() const override;
     32 		bool getState(std::vector<uint8_t>& _state, synthLib::StateType _type) override;
     33 		bool setState(const std::vector<uint8_t>& _state, synthLib::StateType _type) override;
     34 		uint32_t getChannelCountIn() override;
     35 		uint32_t getChannelCountOut() override;
     36 		bool setDspClockPercent(uint32_t _percent) override;
     37 		uint32_t getDspClockPercent() const override;
     38 		uint64_t getDspClockHz() const override;
     39 		uint32_t getInternalLatencyInputToOutput() const override;
     40 		uint32_t getInternalLatencyMidiToOutput() const override;
     41 		void getPreferredSamplerates(std::vector<float>& _dst) const override;
     42 		void getSupportedSamplerates(std::vector<float>& _dst) const override;
     43 
     44 		const auto& getPluginDesc() const { return m_pluginDesc; }
     45 		auto& getPluginDesc() { return m_pluginDesc; }
     46 
     47 		bool setSamplerate(float _samplerate) override;
     48 
     49 		bool setStateFromUnknownCustomData(const std::vector<uint8_t>& _state) override;
     50 
     51 		void onBootFinished(const bridgeLib::DeviceDesc& _desc);
     52 		void onDisconnect();
     53 
     54 	protected:
     55 		void readMidiOut(std::vector<synthLib::SMidiEvent>& _midiOut) override;
     56 		void processAudio(const synthLib::TAudioInputs& _inputs, const synthLib::TAudioOutputs& _outputs, size_t _samples) override;
     57 		bool sendMidi(const synthLib::SMidiEvent& _ev, std::vector<synthLib::SMidiEvent>& _response) override;
     58 
     59 		bool safeCall(const std::function<bool()>& _func, const std::function<void()>& _onFail = [] {});
     60 
     61 		void createConnection(const std::string& _host, uint32_t _port);
     62 
     63 		bridgeLib::PluginDesc m_pluginDesc;
     64 		bridgeLib::DeviceDesc m_deviceDesc;
     65 		std::unique_ptr<DeviceConnection> m_connection;
     66 
     67 		std::mutex m_cvWaitMutex;
     68 		std::condition_variable m_cvWait;
     69 		bool m_valid = false;
     70 	};
     71 }