RemoteVstPlugin: fixed too short arrays for preset names
[lmms.git] / include / MidiPort.h
blobeb0ebcec615acfce34f0f72356b541993c5ca18f
1 /*
2 * MidiPort.h - abstraction of MIDI ports which are part of LMMS's MIDI-
3 * sequencing system
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.
26 #ifndef _MIDI_PORT_H
27 #define _MIDI_PORT_H
29 #include <QtCore/QString>
30 #include <QtCore/QList>
31 #include <QtCore/QPair>
33 #include "midi.h"
34 #include "AutomatableModel.h"
37 class MidiClient;
38 class MidiEventProcessor;
39 class MidiPortMenu;
40 class midiTime;
43 // class for abstraction of MIDI-port
44 class MidiPort : public Model, public SerializingObject
46 Q_OBJECT
47 mapPropertyFromModel(int,inputChannel,setInputChannel,
48 m_inputChannelModel);
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);
65 public:
66 typedef QMap<QString, bool> Map;
68 enum Modes
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
74 } ;
76 MidiPort( const QString & _name,
77 MidiClient * _mc,
78 MidiEventProcessor * _mep,
79 Model * _parent = NULL,
80 Modes _mode = Disabled );
81 virtual ~MidiPort();
83 void setName( const QString & _name );
85 inline Modes mode() const
87 return m_mode;
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
116 return "midiport";
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;
146 public slots:
147 void updateMidiPortMode();
150 private slots:
151 void updateReadablePorts();
152 void updateWritablePorts();
153 void updateOutputProgram();
156 private:
157 MidiClient * m_midiClient;
158 MidiEventProcessor * m_midiEventProcessor;
160 Modes m_mode;
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;
173 Map m_readablePorts;
174 Map m_writablePorts;
177 friend class ControllerConnectionDialog;
178 friend class InstrumentMidiIOView;
181 signals:
182 void readablePortsChanged();
183 void writablePortsChanged();
184 void modeChanged();
189 typedef QList<MidiPort *> MidiPortList;
192 #endif