Made 0.4.12 release
[lmms/mlankhorst.git] / include / MidiWinMM.h
blob51cccae71cfab384ef5ff73c74f1b1280f3470ae
1 /*
2 * MidiWinMM.h - WinMM MIDI client
4 * Copyright (c) 2008-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
6 * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
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.
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.
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.
25 #ifndef _MIDI_WINMM_H
26 #define _MIDI_WINMM_H
28 #include "lmmsconfig.h"
30 #ifdef LMMS_BUILD_WIN32
31 #include <windows.h>
32 #include <mmsystem.h>
33 #endif
35 #include "MidiClient.h"
36 #include "MidiPort.h"
39 class QLineEdit;
42 class MidiWinMM : public QObject, public MidiClient
44 Q_OBJECT
45 public:
46 MidiWinMM();
47 virtual ~MidiWinMM();
49 static QString probeDevice();
52 inline static QString name()
54 return QT_TRANSLATE_NOOP( "setupWidget", "WinMM MIDI" );
59 virtual void processOutEvent( const midiEvent & _me,
60 const midiTime & _time,
61 const MidiPort * _port );
63 virtual void applyPortMode( MidiPort * _port );
64 virtual void removePort( MidiPort * _port );
67 #ifdef LMMS_BUILD_WIN32
68 // list devices as ports
69 virtual QStringList readablePorts() const
71 return m_inputDevices.values();
74 virtual QStringList writablePorts() const
76 return m_outputDevices.values();
78 #endif
80 // return name of port which specified MIDI event came from
81 virtual QString sourcePortName( const midiEvent & ) const;
83 // (un)subscribe given MidiPort to/from destination-port
84 virtual void subscribeReadablePort( MidiPort * _port,
85 const QString & _dest,
86 bool _subscribe = true );
87 virtual void subscribeWritablePort( MidiPort * _port,
88 const QString & _dest,
89 bool _subscribe = true );
90 virtual void connectRPChanged( QObject * _receiver,
91 const char * _member )
93 connect( this, SIGNAL( readablePortsChanged() ),
94 _receiver, _member );
97 virtual void connectWPChanged( QObject * _receiver,
98 const char * _member )
100 connect( this, SIGNAL( writablePortsChanged() ),
101 _receiver, _member );
104 virtual bool isRaw() const
106 return false;
110 class setupWidget : public MidiClient::setupWidget
112 public:
113 setupWidget( QWidget * _parent );
114 virtual ~setupWidget();
116 virtual void saveSettings()
123 private:// slots:
124 void updateDeviceList();
127 private:
128 void openDevices();
129 void closeDevices();
131 #ifdef LMMS_BUILD_WIN32
132 static void WINAPI CALLBACK inputCallback( HMIDIIN _hm, UINT _msg,
133 DWORD_PTR _inst,
134 DWORD_PTR _param1,
135 DWORD_PTR _param2 );
136 void handleInputEvent( HMIDIIN _hm, DWORD _ev );
138 QMap<HMIDIIN, QString> m_inputDevices;
139 QMap<HMIDIOUT, QString> m_outputDevices;
140 #endif
142 // subscriptions
143 typedef QMap<QString, MidiPortList> SubMap;
144 SubMap m_inputSubs;
145 SubMap m_outputSubs;
148 signals:
149 void readablePortsChanged();
150 void writablePortsChanged();
154 #endif