2 * MidiPort.h - abstraction of MIDI ports which are part of LMMS's MIDI-
5 * Copyright (c) 2005-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
7 * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
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.
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.
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.
29 #include <QtCore/QString>
30 #include <QtCore/QList>
31 #include <QtCore/QPair>
34 #include "AutomatableModel.h"
38 class MidiEventProcessor
;
43 // class for abstraction of MIDI-port
44 class MidiPort
: public Model
, public SerializingObject
47 mapPropertyFromModel(int,inputChannel
,setInputChannel
,
49 mapPropertyFromModel(int,outputChannel
,setOutputChannel
,
50 m_outputChannelModel
);
51 mapPropertyFromModel(int,inputController
,setInputController
,
52 m_inputControllerModel
);
53 mapPropertyFromModel(int,outputController
,setOutputController
,
54 m_outputControllerModel
);
55 mapPropertyFromModel(int,fixedInputVelocity
,setFixedInputVelocity
,
56 m_fixedInputVelocityModel
);
57 mapPropertyFromModel(int,fixedOutputVelocity
,setFixedOutputVelocity
,
58 m_fixedOutputVelocityModel
);
59 mapPropertyFromModel(int,fixedOutputNote
,setFixedOutputNote
,
60 m_fixedOutputNoteModel
);
61 mapPropertyFromModel(int,outputProgram
,setOutputProgram
,
62 m_outputProgramModel
);
63 mapPropertyFromModel(bool,isReadable
,setReadable
,m_readableModel
);
64 mapPropertyFromModel(bool,isWritable
,setWritable
,m_writableModel
);
66 typedef QMap
<QString
, bool> Map
;
70 Disabled
, // don't route any MIDI-events (default)
71 Input
, // from MIDI-client to MIDI-event-processor
72 Output
, // from MIDI-event-processor to MIDI-client
73 Duplex
// both directions
76 MidiPort( const QString
& _name
,
78 MidiEventProcessor
* _mep
,
79 Model
* _parent
= NULL
,
80 Modes _mode
= Disabled
);
83 void setName( const QString
& _name
);
85 inline Modes
mode() const
90 void setMode( Modes _mode
);
92 inline bool inputEnabled() const
94 return mode() == Input
|| mode() == Duplex
;
97 inline bool outputEnabled() const
99 return mode() == Output
|| mode() == Duplex
;
102 inline int realOutputChannel() const
104 return outputChannel() - 1;
107 void processInEvent( const midiEvent
& _me
, const midiTime
& _time
);
108 void processOutEvent( const midiEvent
& _me
, const midiTime
& _time
);
111 virtual void saveSettings( QDomDocument
& _doc
, QDomElement
& _parent
);
112 virtual void loadSettings( const QDomElement
& _this
);
114 virtual QString
nodeName() const
119 void subscribeReadablePort( const QString
& _port
,
120 bool _subscribe
= true );
121 void subscribeWritablePort( const QString
& _port
,
122 bool _subscribe
= true );
124 const Map
& readablePorts() const
126 return m_readablePorts
;
129 const Map
& writablePorts() const
131 return m_writablePorts
;
134 void unsubscribeAllReadablePorts();
135 void unsubscribeAllWriteablePorts();
136 inline void unsubscribeAllPorts()
138 unsubscribeAllReadablePorts();
139 unsubscribeAllWriteablePorts();
142 MidiPortMenu
* m_readablePortsMenu
;
143 MidiPortMenu
* m_writablePortsMenu
;
147 void updateMidiPortMode();
151 void updateReadablePorts();
152 void updateWritablePorts();
153 void updateOutputProgram();
157 MidiClient
* m_midiClient
;
158 MidiEventProcessor
* m_midiEventProcessor
;
162 IntModel m_inputChannelModel
;
163 IntModel m_outputChannelModel
;
164 IntModel m_inputControllerModel
;
165 IntModel m_outputControllerModel
;
166 IntModel m_fixedInputVelocityModel
;
167 IntModel m_fixedOutputVelocityModel
;
168 IntModel m_fixedOutputNoteModel
;
169 IntModel m_outputProgramModel
;
170 BoolModel m_readableModel
;
171 BoolModel m_writableModel
;
177 friend class ControllerConnectionDialog
;
178 friend class InstrumentMidiIOView
;
182 void readablePortsChanged();
183 void writablePortsChanged();
189 typedef QList
<MidiPort
*> MidiPortList
;