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

clientConnection.h (2076B)


      1 #pragma once
      2 
      3 #include <mutex>
      4 
      5 #include "bridgeLib/tcpConnection.h"
      6 #include "networkLib/networkThread.h"
      7 #include "networkLib/tcpStream.h"
      8 #include "synthLib/device.h"
      9 
     10 namespace bridgeServer
     11 {
     12 	class Server;
     13 
     14 	class ClientConnection : public bridgeLib::TcpConnection
     15 	{
     16 	public:
     17 		ClientConnection(Server& _server, std::unique_ptr<networkLib::TcpStream>&& _stream, std::string _name);
     18 		~ClientConnection() override;
     19 
     20 		void handleMidi(const synthLib::SMidiEvent& _e) override;
     21 		void handleData(const bridgeLib::PluginDesc& _desc) override;
     22 		void handleData(const bridgeLib::DeviceCreateParams& _params) override;
     23 		void handleData(const bridgeLib::SetSamplerate& _params) override;
     24 		void handleData(const bridgeLib::SetDspClockPercent& _params) override;
     25 		void handleData(const bridgeLib::SetUnknownCustomData& _params) override;
     26 
     27 		void handleAudio(baseLib::BinaryStream& _in) override;
     28 		void sendDeviceState(synthLib::StateType _type);
     29 		void handleRequestDeviceState(bridgeLib::RequestDeviceState& _requestDeviceState) override;
     30 		void handleDeviceState(bridgeLib::DeviceState& _in) override;
     31 		void handleDeviceState(baseLib::BinaryStream& _in) override;
     32 		void handleException(const networkLib::NetException& _e) override;
     33 
     34 		const auto& getPluginDesc() const { return m_pluginDesc; }
     35 
     36 	private:
     37 		void sendDeviceInfo();
     38 		void createDevice();
     39 		void destroyDevice();
     40 
     41 		void errorClose(bridgeLib::ErrorCode _code, const std::string& _err);
     42 
     43 		Server& m_server;
     44 		std::string m_name;
     45 
     46 		bridgeLib::PluginDesc m_pluginDesc;
     47 		synthLib::DeviceCreateParams m_deviceCreateParams;
     48 
     49 		synthLib::Device* m_device = nullptr;
     50 
     51 		synthLib::TAudioInputs m_audioInputs;
     52 		synthLib::TAudioOutputs m_audioOutputs;
     53 
     54 		std::array<std::vector<float>, std::tuple_size_v<synthLib::TAudioInputs>> m_audioInputBuffers;
     55 		std::array<std::vector<float>, std::tuple_size_v<synthLib::TAudioOutputs>> m_audioOutputBuffers;
     56 		std::vector<synthLib::SMidiEvent> m_midiIn;
     57 		std::vector<synthLib::SMidiEvent> m_midiOut;
     58 
     59 		bool m_romRequested = false;
     60 
     61 		std::mutex m_mutexDeviceState;
     62 	};
     63 }