/[svn]/qsampler/trunk/src/qsamplerChannel.h
ViewVC logotype

Annotation of /qsampler/trunk/src/qsamplerChannel.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1510 - (hide annotations) (download) (as text)
Thu Nov 22 14:17:24 2007 UTC (16 years, 5 months ago) by capela
File MIME type: text/x-c++hdr
File size: 7422 byte(s)
- Qt4 migration: code cleanup, personal standards beautification :)

1 capela 264 // qsamplerChannel.h
2     //
3     /****************************************************************************
4 capela 1022 Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved.
5 capela 1464 Copyright (C) 2007, Christian Schoenebeck
6 capela 264
7     This program is free software; you can redistribute it and/or
8     modify it under the terms of the GNU General Public License
9     as published by the Free Software Foundation; either version 2
10     of the License, or (at your option) any later version.
11    
12     This program is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     GNU General Public License for more details.
16    
17 capela 920 You should have received a copy of the GNU General Public License along
18     with this program; if not, write to the Free Software Foundation, Inc.,
19     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 capela 264
21     *****************************************************************************/
22    
23     #ifndef __qsamplerChannel_h
24     #define __qsamplerChannel_h
25    
26 schoenebeck 1461 #include <QTableWidgetItem>
27     #include <QItemDelegate>
28 capela 264
29     #include <lscp/client.h>
30     #include <lscp/device.h>
31    
32     #include "qsamplerOptions.h"
33    
34 capela 758 class qsamplerDevice;
35 capela 264
36    
37 capela 758 // Typedef'd QMap.
38     typedef QMap<int, int> qsamplerChannelRoutingMap;
39    
40    
41 capela 264 //-------------------------------------------------------------------------
42     // qsamplerChannel - Sampler channel structure.
43     //
44    
45     class qsamplerChannel
46     {
47     public:
48    
49 capela 467 // Constructor.
50 capela 961 qsamplerChannel(int iChannelID = -1);
51 capela 467 // Default destructor.
52     ~qsamplerChannel();
53 capela 264
54 capela 467 // Add/remove sampler channel methods.
55     bool addChannel();
56     bool removeChannel();
57 capela 295
58 capela 467 // Sampler channel ID accessors.
59 capela 484 int channelID() const;
60 capela 467 void setChannelID(int iChannelID);
61 capela 295
62 capela 467 // Readable channel name.
63 capela 484 QString channelName() const;
64 capela 467
65     // Engine name property.
66 capela 484 const QString& engineName() const;
67 capela 467 bool loadEngine(const QString& sEngineName);
68    
69     // Instrument file and index.
70 capela 484 const QString& instrumentFile() const;
71     int instrumentNr() const;
72     const QString& instrumentName() const;
73     int instrumentStatus() const;
74 capela 490
75 capela 484 // Instrument file loader.
76 capela 467 bool loadInstrument(const QString& sInstrumentFile, int iInstrumentNr);
77 capela 388 // Special instrument file/name/number settler.
78 capela 467 bool setInstrument(const QString& sInstrumentFile, int iInstrumentNr);
79 capela 344
80 capela 467 // MIDI input driver (DEPRECATED).
81 capela 484 const QString& midiDriver() const;
82 capela 467 bool setMidiDriver(const QString& sMidiDriver);
83 capela 264
84 capela 467 // MIDI input device.
85 capela 484 int midiDevice() const;
86 capela 467 bool setMidiDevice(int iMidiDevice);
87 capela 264
88 capela 467 // MIDI input port.
89 capela 484 int midiPort() const;
90 capela 467 bool setMidiPort(int iMidiPort);
91 capela 371
92 capela 467 // MIDI input channel.
93 capela 484 int midiChannel() const;
94 capela 467 bool setMidiChannel(int iMidiChannel);
95 capela 264
96 capela 980 // MIDI instrument map.
97     int midiMap() const;
98     bool setMidiMap(int iMidiMap);
99    
100 capela 467 // Audio output driver (DEPRECATED).
101 capela 484 const QString& audioDriver() const;
102 capela 467 bool setAudioDriver(const QString& sAudioDriver);
103 capela 303
104 capela 467 // Audio output device.
105 capela 484 int audioDevice() const;
106 capela 467 bool setAudioDevice(int iAudioDevice);
107 capela 400
108 capela 467 // Sampler channel volume.
109 capela 484 float volume() const;
110 capela 467 bool setVolume(float fVolume);
111 capela 264
112 capela 751 // Sampler channel mute state.
113     bool channelMute() const;
114     bool setChannelMute(bool bMute);
115    
116     // Sampler channel solo state.
117     bool channelSolo() const;
118     bool setChannelSolo(bool bSolo);
119    
120 capela 758 // Audio routing accessors.
121     int audioChannel(int iAudioOut) const;
122     bool setAudioChannel(int iAudioOut, int iAudioIn);
123     // The audio routing map itself.
124     const qsamplerChannelRoutingMap& audioRouting() const;
125    
126 capela 467 // Istrument name remapper.
127     void updateInstrumentName();
128 capela 303
129 capela 467 // Channel info structure map executive.
130     bool updateChannelInfo();
131    
132     // Channel setup dialog form.
133     bool channelSetup(QWidget *pParent);
134    
135     // Reset channel method.
136     bool channelReset();
137    
138 schoenebeck 1366 // Spawn instrument editor method.
139     bool editChannel();
140    
141 capela 467 // Message logging methods (brainlessly mapped to main form's).
142 capela 484 void appendMessages (const QString & s) const;
143     void appendMessagesColor (const QString & s, const QString & c) const;
144     void appendMessagesText (const QString & s) const;
145     void appendMessagesError (const QString & s) const;
146     void appendMessagesClient (const QString & s) const;
147 capela 467
148     // Context menu event handler.
149     void contextMenuEvent(QContextMenuEvent *pEvent);
150    
151 capela 388 // Common (invalid) name-helpers.
152 capela 467 static QString noEngineName();
153     static QString noInstrumentName();
154 schoenebeck 519 static QString loadingInstrument();
155 capela 388
156     // Check whether a given file is an instrument file.
157     static bool isInstrumentFile (const QString& sInstrumentFile);
158    
159 capela 467 // Retrieve the available instrument name(s) of an instrument file (.gig).
160     static QString getInstrumentName (const QString& sInstrumentFile,
161 capela 344 int iInstrumentNr, bool bInstrumentNames);
162 capela 467 static QStringList getInstrumentList (const QString& sInstrumentFile,
163 capela 344 bool bInstrumentNames);
164 capela 299
165 capela 264 private:
166    
167 capela 467 // Unique channel identifier.
168     int m_iChannelID;
169 capela 264
170 capela 467 // Sampler channel info map.
171     QString m_sEngineName;
172     QString m_sInstrumentName;
173     QString m_sInstrumentFile;
174     int m_iInstrumentNr;
175     int m_iInstrumentStatus;
176 capela 490 QString m_sMidiDriver;
177 capela 467 int m_iMidiDevice;
178     int m_iMidiPort;
179     int m_iMidiChannel;
180 capela 980 int m_iMidiMap;
181 capela 490 QString m_sAudioDriver;
182 capela 467 int m_iAudioDevice;
183     float m_fVolume;
184 capela 751 bool m_bMute;
185     bool m_bSolo;
186 capela 758
187     // The audio routing mapping.
188     qsamplerChannelRoutingMap m_audioRouting;
189 capela 264 };
190    
191 capela 758
192     //-------------------------------------------------------------------------
193 schoenebeck 1489 // ChannelRoutingModel - data model for audio routing (used for QTableView)
194 capela 758 //
195    
196 schoenebeck 1461 struct ChannelRoutingItem {
197 capela 1510 QStringList options;
198     int selection;
199 schoenebeck 1461 };
200 capela 758
201 schoenebeck 1461 // so we can use it i.e. through QVariant
202     Q_DECLARE_METATYPE(ChannelRoutingItem)
203    
204 capela 1510 class ChannelRoutingModel : public QAbstractTableModel
205     {
206     Q_OBJECT
207     public:
208 schoenebeck 1461
209 capela 1510 ChannelRoutingModel(QObject* pParent = NULL);
210 schoenebeck 1461
211 capela 1510 // overridden methods from subclass(es)
212     int rowCount(const QModelIndex& parent = QModelIndex()) const;
213     int columnCount(const QModelIndex& parent = QModelIndex()) const;
214     Qt::ItemFlags flags(const QModelIndex& index) const;
215     bool setData(const QModelIndex& index, const QVariant& value,
216     int role = Qt::EditRole);
217     QVariant data(const QModelIndex &index, int role) const;
218     QVariant headerData(int section, Qt::Orientation orientation,
219     int role = Qt::DisplayRole) const;
220 schoenebeck 1489
221 capela 1510 // own methods
222     qsamplerChannelRoutingMap routingMap() const { return m_routing; }
223 schoenebeck 1489
224 capela 1510 void clear() { m_routing.clear(); }
225 schoenebeck 1461
226 capela 1510 public slots:
227    
228     void refresh(qsamplerDevice *pDevice,
229     const qsamplerChannelRoutingMap& routing);
230    
231     private:
232    
233     qsamplerDevice *m_pDevice;
234     qsamplerChannelRoutingMap m_routing;
235 schoenebeck 1461 };
236    
237 schoenebeck 1489
238     //-------------------------------------------------------------------------
239     // ChannelRoutingDelegate - table cell renderer for audio routing
240     //
241    
242 capela 1510 class ChannelRoutingDelegate : public QItemDelegate
243     {
244     Q_OBJECT
245    
246     public:
247    
248     ChannelRoutingDelegate(QObject* pParent = NULL);
249    
250     QWidget* createEditor(QWidget *pParent,
251     const QStyleOptionViewItem& option, const QModelIndex& index) const;
252     void setEditorData(QWidget *pEditor, const QModelIndex& index) const;
253     void setModelData(QWidget *pEditor, QAbstractItemModel* model,
254     const QModelIndex& index) const;
255     void updateEditorGeometry(QWidget *pEditor,
256     const QStyleOptionViewItem& option, const QModelIndex& index) const;
257 schoenebeck 1461 };
258    
259 capela 264 #endif // __qsamplerChannel_h
260    
261     // end of qsamplerChannel.h

  ViewVC Help
Powered by ViewVC