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