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

deviceConnection.h (2016B)


      1 #pragma once
      2 
      3 #include <mutex>
      4 #include <condition_variable>
      5 
      6 #include "bridgeLib/audioBuffers.h"
      7 #include "bridgeLib/tcpConnection.h"
      8 
      9 #include "synthLib/audioTypes.h"
     10 #include "synthLib/deviceTypes.h"
     11 
     12 namespace bridgeClient
     13 {
     14 	class RemoteDevice;
     15 
     16 	class DeviceConnection : public bridgeLib::TcpConnection
     17 	{
     18 	public:
     19 		DeviceConnection(RemoteDevice& _device, std::unique_ptr<networkLib::TcpStream>&& _stream);
     20 		~DeviceConnection() override;
     21 
     22 		void handleCommand(bridgeLib::Command _command, baseLib::BinaryStream& _in) override;
     23 
     24 		void handleData(const bridgeLib::DeviceDesc& _desc) override;
     25 		void handleDeviceInfo(baseLib::BinaryStream& _in) override;
     26 
     27 		void handleException(const networkLib::NetException& _e) override;
     28 
     29 		// INIT
     30 		void sendDeviceCreateParams(bool _sendRom);
     31 
     32 		// AUDIO
     33 		bool processAudio(const synthLib::TAudioInputs& _inputs, const synthLib::TAudioOutputs& _outputs, uint32_t _size, uint32_t _latency);
     34 		void handleAudio(baseLib::BinaryStream& _in) override;
     35 
     36 		// MIDI
     37 		void handleMidi(const synthLib::SMidiEvent& _e) override;
     38 		void readMidiOut(std::vector<synthLib::SMidiEvent>& _midiOut);
     39 
     40 		// DEVICE STATE
     41 		bool getDeviceState(std::vector<uint8_t>& _state, synthLib::StateType _type);
     42 		void handleDeviceState(baseLib::BinaryStream& _in) override;
     43 		bool setDeviceState(const std::vector<uint8_t>& _state, synthLib::StateType _type);
     44 
     45 		void setSamplerate(float _samplerate);
     46 		void setStateFromUnknownCustomData(const std::vector<uint8_t>& _state);
     47 		void setDspClockPercent(uint32_t _percent);
     48 
     49 	private:
     50 		bool sendAwaitReply(const std::function<void()>& _send, const std::function<void(baseLib::BinaryStream&)>& _reply, bridgeLib::Command _replyCommand);
     51 
     52 		RemoteDevice& m_device;
     53 		bridgeLib::DeviceDesc m_deviceDesc;
     54 
     55 		std::function<void(bridgeLib::Command, baseLib::BinaryStream&)> m_handleReplyFunc;
     56 
     57 		std::mutex m_cvWaitMutex;
     58 		std::condition_variable m_cvWait;
     59 
     60 		std::vector<synthLib::SMidiEvent> m_midiOut;
     61 
     62 		bridgeLib::AudioBuffers m_audioBuffers;
     63 	};
     64 }