93 lines
2.8 KiB
C++
93 lines
2.8 KiB
C++
#pragma once
|
|
|
|
#include <AH/Containers/Updatable.hpp>
|
|
#include <AH/Hardware/FilteredAnalog.hpp>
|
|
#include <AH/Timing/MillisMicrosTimer.hpp>
|
|
#include <MIDI_Interfaces/MIDI_Interface.hpp>
|
|
#include <Settings/SettingsWrapper.hpp>
|
|
|
|
BEGIN_CS_NAMESPACE
|
|
|
|
using AH::FilteredAnalog;
|
|
using AH::NormalUpdatable;
|
|
using AH::Timer;
|
|
using AH::Updatable;
|
|
|
|
class Control_Surface_ : public MIDI_Sender<Control_Surface_>,
|
|
public TrueMIDI_SinkSource {
|
|
|
|
friend class MIDI_Sender<Control_Surface_>;
|
|
|
|
public:
|
|
Control_Surface_(Control_Surface_ const &) = delete;
|
|
Control_Surface_ &operator=(Control_Surface_ const &) = delete;
|
|
static Control_Surface_ &getInstance();
|
|
|
|
private:
|
|
Control_Surface_() = default;
|
|
|
|
public:
|
|
void begin();
|
|
void loop();
|
|
|
|
bool connectDefaultMIDI_Interface();
|
|
void disconnectMIDI_Interfaces();
|
|
|
|
void updateMidiInput();
|
|
void updateInputs();
|
|
|
|
private:
|
|
void sendChannelMessageImpl(ChannelMessage);
|
|
void sendSysCommonImpl(SysCommonMessage);
|
|
void sendSysExImpl(SysExMessage);
|
|
void sendRealTimeImpl(RealTimeMessage);
|
|
void sendNowImpl() {}
|
|
|
|
private:
|
|
#if !DISABLE_PIPES
|
|
void sinkMIDIfromPipe(ChannelMessage msg) override;
|
|
void sinkMIDIfromPipe(SysExMessage msg) override;
|
|
void sinkMIDIfromPipe(SysCommonMessage msg) override;
|
|
void sinkMIDIfromPipe(RealTimeMessage msg) override;
|
|
#else
|
|
void sinkMIDIfromPipe(ChannelMessage msg);
|
|
void sinkMIDIfromPipe(SysExMessage msg);
|
|
void sinkMIDIfromPipe(SysCommonMessage msg);
|
|
void sinkMIDIfromPipe(RealTimeMessage msg);
|
|
#endif
|
|
|
|
public:
|
|
using ChannelMessageCallback = bool (*)(ChannelMessage);
|
|
using SysExMessageCallback = bool (*)(SysExMessage);
|
|
using SysCommonMessageCallback = bool (*)(SysCommonMessage);
|
|
using RealTimeMessageCallback = bool (*)(RealTimeMessage);
|
|
|
|
void
|
|
setMIDIInputCallbacks(ChannelMessageCallback channelMessageCallback,
|
|
SysExMessageCallback sysExMessageCallback,
|
|
SysCommonMessageCallback sysCommonMessageCallback,
|
|
RealTimeMessageCallback realTimeMessageCallback) {
|
|
this->channelMessageCallback = channelMessageCallback;
|
|
this->sysExMessageCallback = sysExMessageCallback;
|
|
this->sysCommonMessageCallback = sysCommonMessageCallback;
|
|
this->realTimeMessageCallback = realTimeMessageCallback;
|
|
}
|
|
|
|
private:
|
|
ChannelMessageCallback channelMessageCallback = nullptr;
|
|
SysExMessageCallback sysExMessageCallback = nullptr;
|
|
SysCommonMessageCallback sysCommonMessageCallback = nullptr;
|
|
RealTimeMessageCallback realTimeMessageCallback = nullptr;
|
|
#if !DISABLE_PIPES
|
|
MIDI_Pipe inpipe, outpipe;
|
|
#endif
|
|
};
|
|
|
|
#if CS_TRUE_CONTROL_SURFACE_INSTANCE
|
|
extern Control_Surface_ &Control_Surface;
|
|
#else
|
|
#define Control_Surface (Control_Surface_::getInstance())
|
|
#endif
|
|
|
|
END_CS_NAMESPACE
|