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,outputProgram
,setOutputProgram
,
60 m_outputProgramModel
);
61 mapPropertyFromModel(bool,isReadable
,setReadable
,m_readableModel
);
62 mapPropertyFromModel(bool,isWritable
,setWritable
,m_writableModel
);
64 typedef QMap
<QString
, bool> Map
;
68 Disabled
, // don't route any MIDI-events (default)
69 Input
, // from MIDI-client to MIDI-event-processor
70 Output
, // from MIDI-event-processor to MIDI-client
71 Duplex
// both directions
74 MidiPort( const QString
& _name
,
76 MidiEventProcessor
* _mep
,
77 Model
* _parent
= NULL
,
78 Modes _mode
= Disabled
);
81 void setName( const QString
& _name
);
83 inline Modes
mode() const
88 void setMode( Modes _mode
);
90 inline bool inputEnabled() const
92 return mode() == Input
|| mode() == Duplex
;
95 inline bool outputEnabled() const
97 return mode() == Output
|| mode() == Duplex
;
100 inline int realOutputChannel() const
102 return outputChannel() - 1;
105 void processInEvent( const midiEvent
& _me
, const midiTime
& _time
);
106 void processOutEvent( const midiEvent
& _me
, const midiTime
& _time
);
109 virtual void saveSettings( QDomDocument
& _doc
, QDomElement
& _parent
);
110 virtual void loadSettings( const QDomElement
& _this
);
112 virtual QString
nodeName() const
117 void subscribeReadablePort( const QString
& _port
,
118 bool _subscribe
= true );
119 void subscribeWritablePort( const QString
& _port
,
120 bool _subscribe
= true );
122 const Map
& readablePorts() const
124 return m_readablePorts
;
127 const Map
& writablePorts() const
129 return m_writablePorts
;
132 MidiPortMenu
* m_readablePortsMenu
;
133 MidiPortMenu
* m_writablePortsMenu
;
137 void updateMidiPortMode();
141 void updateReadablePorts();
142 void updateWritablePorts();
143 void updateOutputProgram();
147 MidiClient
* m_midiClient
;
148 MidiEventProcessor
* m_midiEventProcessor
;
152 IntModel m_inputChannelModel
;
153 IntModel m_outputChannelModel
;
154 IntModel m_inputControllerModel
;
155 IntModel m_outputControllerModel
;
156 IntModel m_fixedInputVelocityModel
;
157 IntModel m_fixedOutputVelocityModel
;
158 IntModel m_outputProgramModel
;
159 BoolModel m_readableModel
;
160 BoolModel m_writableModel
;
166 friend class ControllerConnectionDialog
;
167 friend class InstrumentMidiIOView
;
171 void readablePortsChanged();
172 void writablePortsChanged();
178 typedef QList
<MidiPort
*> MidiPortList
;