LMMS
Loading...
Searching...
No Matches
MidiApple.h
Go to the documentation of this file.
1/*
2 * MidiApple.h - Apple raw MIDI client
3 *
4 * Copyright (c) 2005-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
5 * Copyright (c) 2015 Maurizio Lo Bosco (rageboge on github)
6 *
7 * This file is part of LMMS - https://lmms.io
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public
20 * License along with this program (see COPYING); if not, write to the
21 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301 USA.
23 *
24 */
25
26#ifndef LMMS_MIDI_APPLE_H
27#define LMMS_MIDI_APPLE_H
28
29#include "lmmsconfig.h"
30
31#ifdef LMMS_BUILD_APPLE
32
33#include "MidiClient.h"
34#include "MidiPort.h"
35#include <CoreMIDI/CoreMIDI.h>
36
37
38class QLineEdit;
39
40
41namespace lmms
42{
43
44
45class MidiApple : public QObject, public MidiClient
46{
47 Q_OBJECT
48public:
49 MidiApple();
50 virtual ~MidiApple();
51
52 inline static QString probeDevice()
53 {
54 return QString(); // no midi device name
55 }
56
57 inline static QString name()
58 {
59 return QT_TRANSLATE_NOOP( "MidiSetupWidget", "Apple MIDI" );
60 }
61 inline static QString configSection()
62 {
63 return QString(); // no configuration settings
64 }
65
66 virtual void processOutEvent( const MidiEvent & _me,
67 const TimePos & _time,
68 const MidiPort * _port );
69
70 virtual void applyPortMode( MidiPort * _port );
71 virtual void removePort( MidiPort * _port );
72
73
74 // list devices as ports
75 virtual QStringList readablePorts() const
76 {
77 return m_inputDevices.keys();
78 }
79
80 virtual QStringList writablePorts() const
81 {
82 return m_outputDevices.keys();
83 }
84
85 // return name of port which specified MIDI event came from
86 virtual QString sourcePortName( const MidiEvent & ) const;
87
88 // (un)subscribe given MidiPort to/from destination-port
89 virtual void subscribeReadablePort( MidiPort * _port,
90 const QString & _dest,
91 bool _subscribe = true );
92
93 virtual void subscribeWritablePort( MidiPort * _port,
94 const QString & _dest,
95 bool _subscribe = true );
96
97 virtual void connectRPChanged( QObject * _receiver,
98 const char * _member )
99 {
100 connect( this, SIGNAL( readablePortsChanged() ),
101 _receiver, _member );
102 }
103
104
105 virtual void connectWPChanged( QObject * _receiver,
106 const char * _member )
107 {
108 connect( this, SIGNAL( writablePortsChanged() ),
109 _receiver, _member );
110 }
111
112
113 virtual bool isRaw() const
114 {
115 return false;
116 }
117
118
119private:// slots:
120 void updateDeviceList();
121
122
123private:
124 void openDevices();
125 void closeDevices();
126 void openMidiReference( MIDIEndpointRef reference, QString refName,bool isIn );
127 MIDIClientRef getMidiClientRef();
128 void midiInClose( MIDIEndpointRef reference );
129 static void NotifyCallback( const MIDINotification *message, void *refCon );
130 static void ReadCallback( const MIDIPacketList *pktlist, void *readProcRefCon, void *srcConnRefCon );
131 void HandleReadCallback( const MIDIPacketList *pktlist, void *srcConnRefCon );
132 void notifyMidiPortList( MidiPortList portList, MidiEvent midiEvent);
133 char * getFullName( MIDIEndpointRef &endpoint_ref );
134 void sendMidiOut( MIDIEndpointRef & endPointRef, const MidiEvent& event );
135 MIDIPacketList createMidiPacketList( const MidiEvent& event );
136
137 MIDIClientRef mClient = 0;
138 QMap<QString, MIDIEndpointRef> m_inputDevices;
139 QMap<QString, MIDIEndpointRef> m_outputDevices;
140 QMap<MIDIEndpointRef, MIDIPortRef> m_sourcePortRef;
141
142 // subscriptions
143 using SubMap = QMap<QString, MidiPortList>;
144 SubMap m_inputSubs;
145 SubMap m_outputSubs;
146
147signals:
148 void readablePortsChanged();
149 void writablePortsChanged();
150
151} ;
152
153
154} // namespace lmms
155
156#endif // LMMS_BUILD_APPLE
157
158#endif // LMMS_MIDI_APPLE_H
static void message(int level, const char *fmt,...)
Definition adplugdb.cpp:120
Definition MidiClient.h:46
static const char * name
Definition pugl.h:1582
Definition AudioAlsa.cpp:35
#define SIGNAL
Definition tap_pinknoise.c:34