22#include "OSLikeStuff/scheduler_api.h"
23#include "definitions_cxx.hpp"
24#include "io/midi/learned_midi.h"
25#include "playback/playback_handler.h"
36 void const* source_{
nullptr};
38 MIDISource() =
default;
39 ~MIDISource() =
default;
41 MIDISource(MIDICable
const* cable) : source_(cable) {};
42 MIDISource(MIDIInstrument
const* instrument) : source_(instrument) {};
43 MIDISource(PlaybackHandler
const* handler) : source_(handler) {};
44 MIDISource(MidiFollow
const* follow) : source_(follow) {};
45 MIDISource(MIDIDrum
const* drum) : source_(drum) {};
46 MIDISource(Sound
const* sound) : source_(sound) {};
48 MIDISource(MIDICable
const& cable) : source_(&cable) {};
49 MIDISource(MIDIInstrument
const& instrument) : source_(&instrument) {};
50 MIDISource(MIDIDrum
const& drum) : source_(&drum) {};
51 MIDISource(Sound
const& sound) : source_(&sound) {};
52 MIDISource(MidiFollow
const& follow) : source_(&follow) {};
53 MIDISource(PlaybackHandler
const& handler) : source_(&handler) {};
55 MIDISource(MIDISource
const& other) =
default;
56 MIDISource(MIDISource&& other) =
default;
58 MIDISource& operator=(MIDISource
const& other) =
default;
59 MIDISource& operator=(MIDISource&& other) =
default;
61 bool operator==(MIDISource
const& other)
const {
return source_ == other.source_; }
68 void sendNote(MIDISource source,
bool on, int32_t note, uint8_t velocity, uint8_t channel, int32_t filter);
69 void sendCC(MIDISource source, int32_t channel, int32_t cc, int32_t value, int32_t filter);
70 bool checkIncomingSerialMidi();
71 static void check_incoming_usb();
72 void checkIncomingUsbMidi();
74 void checkIncomingUsbSysex(uint8_t
const* message, int32_t ip, int32_t d, int32_t cable);
76 void sendMidi(MIDISource source, MIDIMessage message, int32_t filter = kMIDIOutputFilterNoMPE,
bool sendUSB =
true);
77 void sendClock(MIDISource source,
bool sendUSB =
true, int32_t howMany = 1);
78 void sendStart(MIDISource source);
79 void sendStop(MIDISource source);
80 void sendPositionPointer(MIDISource source, uint16_t positionPointer);
81 void sendContinue(MIDISource source);
84 void sendUsbMidi(MIDIMessage message, int32_t filter);
85 void sendSerialMidi(MIDIMessage message);
87 void sendPGMChange(MIDISource source, int32_t channel, int32_t pgm, int32_t filter);
88 void sendAllNotesOff(MIDISource source, int32_t channel, int32_t filter);
89 void sendBank(MIDISource source, int32_t channel, int32_t num, int32_t filter);
90 void sendSubBank(MIDISource source, int32_t channel, int32_t num, int32_t filter);
94 void sendPitchBend(MIDISource source, int32_t channel, uint16_t bend, int32_t filter);
96 void sendChannelAftertouch(MIDISource source, int32_t channel, int32_t value, int32_t filter);
98 void sendPolyphonicAftertouch(MIDISource source, int32_t channel, int32_t value, uint8_t noteCode, int32_t filter);
99 bool anythingInOutputBuffer();
100 void setupUSBHostReceiveTransfer(int32_t ip, int32_t midiDeviceNum);
101 void flushUSBMIDIOutput();
104 LearnedMIDI globalMIDICommands[kNumGlobalMIDICommands];
107 LearnedMIDI midiFollowChannelType[kNumMIDIFollowChannelTypesIncludingTracks];
108 MIDIFollowFeedbackChannelType midiFollowFeedbackChannelType;
109 uint8_t midiFollowKitRootNote;
110 bool midiFollowDisplayParam;
111 MIDIFollowFeedbackAutomationMode midiFollowFeedbackAutomation;
112 bool midiFollowFeedbackFilter;
113 MIDITakeoverMode midiTakeover;
114 bool midiSelectKitRow;
115 TaskID routine_task_id;
119 uint8_t sysex_fmt_buffer[1024];
130 void midiMessageReceived(MIDICable& cable, uint8_t statusType, uint8_t channel, uint8_t data1, uint8_t data2,
131 uint32_t* timer =
nullptr);
138 void midiSysexReceived(MIDICable& cable, uint8_t* data, int32_t len);
141 uint8_t serialMidiInput[3];
142 uint8_t numSerialMidiInput;
144 bool currentlyReceivingSysExSerial;
146 using EventStackStorage = std::array<MIDISource, 16>;
149 EventStackStorage eventStack_;
151 EventStackStorage::iterator eventStackTop_;
153 int32_t getPotentialNumConnectedUSBMIDIDevices(int32_t ip);
158extern MidiEngine midiEngine;
159extern bool anythingInUSBOutputBuffer;
163extern uint16_t g_usb_usbmode;
165void usbSendCompleteAsHost(int32_t ip);
166void usbSendCompleteAsPeripheral(int32_t ip);
A MIDI cable connection. Stores all state specific to a given cable and its contained ports and chann...
Definition midi_device.h:96
Definition midi_drum.h:22
Definition midi_instrument.h:38
Definition midi_follow.h:40
Definition playback_handler.h:54