6 #ifndef OFXPDSPMIDI_PDSPMIDIOUT_H_INCLUDED 7 #define OFXPDSPMIDI_PDSPMIDIOUT_H_INCLUDED 13 #include "helper/PositionedMidiMessage.h" 17 #include <condition_variable> 19 #include "../DSP/pdspCore.h" 20 #include "../sequencer/SequencerSection.h" 26 namespace pdsp {
namespace midi {
32 class ScheduledMidiMessage{
34 ScheduledMidiMessage();
35 ScheduledMidiMessage(ofxMidiMessage message, std::chrono::high_resolution_clock::time_point schedule);
36 ScheduledMidiMessage(
const ScheduledMidiMessage &other);
37 ScheduledMidiMessage& operator= (
const ScheduledMidiMessage &other);
38 ~ScheduledMidiMessage();
41 std::chrono::high_resolution_clock::time_point scheduledTime;
45 static bool scheduledMidiSort(
const ScheduledMidiMessage &lhs,
const ScheduledMidiMessage &rhs );
61 void close()
override;
90 pdsp::ExtSequencer&
gate(
int midiChannel,
int defaultNote = 60);
97 pdsp::ExtSequencer&
note();
104 pdsp::ExtSequencer&
cc(
int midiChannel,
int ccNumber);
109 void process(
int bufferSize ) noexcept
override;
111 void linkToMessageBuffer(pdsp::MessageBuffer &messageBuffer)
override;
112 void unlinkMessageBuffer(pdsp::MessageBuffer &messageBuffer)
override;
117 void prepareToPlay(
int expectedBufferSize,
double sampleRate )
override;
118 void releaseResources()
override ;
122 ofxMidiOut* midiOut_p;
127 std::vector<ScheduledMidiMessage> messagesToSend;
129 std::vector<pdsp::MessageBuffer*> inputs [3];
130 std::vector<int> defaultNote;
131 std::vector<int> midiChannelsNote;
132 std::vector<int> ccNumbers;
133 std::vector<int> midiChannelsCC;
136 int selectedMidiChannel;
137 int selectedDefaultNote;
140 static const int nullType = -1;
141 static const int gateType = 0;
142 static const int noteType = 1;
143 static const int ccType = 2;
146 void startMidiDaemon();
147 void closeMidiDaemon();
148 void midiDaemonFunction() noexcept;
149 static void midiDaemonFunctionWrapper(
Output* parent);
151 std::thread midiDaemonThread;
152 std::atomic<bool> runMidiDaemon;
156 std::chrono::time_point<std::chrono::high_resolution_clock> bufferChrono;
157 double usecPerSample;
158 std::vector<ScheduledMidiMessage> circularBuffer;
160 std::atomic<int> writeindex;
172 #endif //OFXPDSPMIDI_PDSPMIDIOUT_H_INCLUDED void openPort(int index)
open the port with the given index
Definition: MidiOut.cpp:94
void close() override
close the opened port
Definition: MidiOut.cpp:112
bool isConnected()
return true if the port has been sucessfully opened
Definition: MidiOut.h:77
pdsp::ExtSequencer & note()
patch a pdsp::ScoreSection::out_message() method to the result of this method for controlling the mid...
Definition: MidiOut.cpp:132
void listPorts()
list the available ports
Definition: MidiOut.cpp:90
Thread-safe value control with smoothing.
Definition: SequencerBridge.h:11
void linkToMidiOut(ofxMidiOut &midiOut)
uses an already open ofxMidiOut instead of opening a port
Definition: MidiOut.cpp:72
pdsp::ExtSequencer & gate(int midiChannel, int defaultNote=60)
patch a pdsp::ScoreSection::out_message() method to the result of this method for sending midi note m...
Definition: MidiOut.cpp:125
void setVerbose(bool verbose)
enable or disable diagnostic messages
Definition: MidiOut.cpp:68
pdsp::ExtSequencer & cc(int midiChannel, int ccNumber)
patch a pdsp::ScoreSection::out_message() method to the result of this method for sending midi cc mes...
Definition: MidiOut.cpp:137
Definition: Preparable.h:36