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