openMSX
MidiOutCoreMIDI.hh
Go to the documentation of this file.
1 #ifndef MIDIOUTCOREMIDI_HH
2 #define MIDIOUTCOREMIDI_HH
3 
4 #if defined(__APPLE__)
5 
6 #include "MidiOutDevice.hh"
7 #include <CoreMIDI/MIDIServices.h>
8 
9 #include <vector>
10 
11 namespace openmsx {
12 
13 class PluggingController;
14 
17 class MidiOutMessageBuffer : public MidiOutDevice
18 {
19 protected:
20  virtual OSStatus sendPacketList(MIDIPacketList *myPacketList) = 0;
21 
22 private:
23  void recvMessage(
24  const std::vector<uint8_t>& message, EmuTime::param time) override;
25 };
26 
29 class MidiOutCoreMIDI final : public MidiOutMessageBuffer
30 {
31 public:
32  static void registerAll(PluggingController& controller);
33 
37  explicit MidiOutCoreMIDI(MIDIEndpointRef endpoint);
38 
39  // Pluggable
40  void plugHelper(Connector& connector, EmuTime::param time) override;
41  void unplugHelper(EmuTime::param time) override;
42  [[nodiscard]] const std::string& getName() const override;
43  [[nodiscard]] std::string_view getDescription() const override;
44 
45  // MidiOutMessageBuffer
46  OSStatus sendPacketList(MIDIPacketList *myPacketList) override;
47 
48  template<typename Archive>
49  void serialize(Archive& ar, unsigned version);
50 
51 private:
52  MIDIClientRef client;
53  MIDIPortRef port;
54  MIDIEndpointRef endpoint;
55 
56  std::string name;
57 };
58 
64 class MidiOutCoreMIDIVirtual final : public MidiOutMessageBuffer
65 {
66 public:
67  explicit MidiOutCoreMIDIVirtual();
68 
69  // Pluggable
70  void plugHelper(Connector& connector, EmuTime::param time) override;
71  void unplugHelper(EmuTime::param time) override;
72  [[nodiscard]] const std::string& getName() const override;
73  [[nodiscard]] std::string_view getDescription() const override;
74 
75  // MidiOutMessageBuffer
76  OSStatus sendPacketList(MIDIPacketList *myPacketList) override;
77 
78  template<typename Archive>
79  void serialize(Archive& ar, unsigned version);
80 
81 private:
82  MIDIClientRef client;
83  MIDIEndpointRef endpoint;
84 };
85 
86 } // namespace openmsx
87 
88 #endif // defined(__APPLE__)
89 #endif // MIDIOUTCOREMIDI_HH
openmsx::Keys::getName
string getName(KeyCode keyCode)
Translate key code to key name.
Definition: Keys.cc:742
openmsx::serialize
void serialize(Archive &ar, T &t, unsigned version)
Definition: serialize_core.hh:41
MidiOutDevice.hh
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5
openmsx::Connector
Connector
Definition: Connector.cc:83