LMMS
Loading...
Searching...
No Matches
MidiWinMM.h
Go to the documentation of this file.
1/*
2 * MidiWinMM.h - WinMM MIDI client
3 *
4 * Copyright (c) 2008-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
5 *
6 * This file is part of LMMS - https://lmms.io
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program (see COPYING); if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301 USA.
22 *
23 */
24
25#ifndef LMMS_MIDI_WINMM_H
26#define LMMS_MIDI_WINMM_H
27
28#include "lmmsconfig.h"
29
30#ifdef LMMS_BUILD_WIN32
31#include <windows.h>
32#include <mmsystem.h>
33
34#include "MidiClient.h"
35#include "MidiPort.h"
36
37
38class QLineEdit;
39
40
41namespace lmms
42{
43
44
45class MidiWinMM : public QObject, public MidiClient
46{
47 Q_OBJECT
48public:
49 MidiWinMM();
50 virtual ~MidiWinMM();
51
52 inline static QString probeDevice()
53 {
54 return QString(); // no midi device name
55 }
56
57
58 inline static QString name()
59 {
60 return QT_TRANSLATE_NOOP( "MidiSetupWidget", "WinMM MIDI" );
61 }
62
63 inline static QString configSection()
64 {
65 return QString(); // no configuration settings
66 }
67
68
69
70 virtual void processOutEvent( const MidiEvent & _me,
71 const TimePos & _time,
72 const MidiPort * _port );
73
74 virtual void applyPortMode( MidiPort * _port );
75 virtual void removePort( MidiPort * _port );
76
77
78 // list devices as ports
79 virtual QStringList readablePorts() const
80 {
81 return m_inputDevices.values();
82 }
83
84 virtual QStringList writablePorts() const
85 {
86 return m_outputDevices.values();
87 }
88
89 // return name of port which specified MIDI event came from
90 virtual QString sourcePortName( const MidiEvent & ) const;
91
92 // (un)subscribe given MidiPort to/from destination-port
93 virtual void subscribeReadablePort( MidiPort * _port,
94 const QString & _dest,
95 bool _subscribe = true );
96 virtual void subscribeWritablePort( MidiPort * _port,
97 const QString & _dest,
98 bool _subscribe = true );
99 virtual void connectRPChanged( QObject * _receiver,
100 const char * _member )
101 {
102 connect( this, SIGNAL( readablePortsChanged() ),
103 _receiver, _member );
104 }
105
106 virtual void connectWPChanged( QObject * _receiver,
107 const char * _member )
108 {
109 connect( this, SIGNAL( writablePortsChanged() ),
110 _receiver, _member );
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
127 static void WINAPI CALLBACK inputCallback( HMIDIIN _hm, UINT _msg,
128 DWORD_PTR _inst,
129 DWORD_PTR _param1,
130 DWORD_PTR _param2 );
131 void handleInputEvent( HMIDIIN _hm, DWORD _ev );
132
133 QMap<HMIDIIN, QString> m_inputDevices;
134 QMap<HMIDIOUT, QString> m_outputDevices;
135
136 // subscriptions
137 using SubMap = QMap<QString, MidiPortList>;
138 SubMap m_inputSubs;
139 SubMap m_outputSubs;
140
141
142signals:
143 void readablePortsChanged();
144 void writablePortsChanged();
145
146} ;
147
148
149} // namespace lmms
150
151#endif // LMMS_BUILD_WIN32
152
153#endif // LMMS_MIDI_WINMM_H
Definition MidiClient.h:46
static const char * name
Definition pugl.h:1582
Definition AudioAlsa.cpp:35
unsigned int UINT
Definition swell-types.h:166
unsigned int DWORD
Definition swell-types.h:164
uintptr_t DWORD_PTR
Definition swell-types.h:43
#define WINAPI
Definition swell-types.h:631
#define CALLBACK
Definition swell-types.h:635
#define SIGNAL
Definition tap_pinknoise.c:34