1 |
capela |
264 |
// qsamplerChannel.h |
2 |
|
|
// |
3 |
|
|
/**************************************************************************** |
4 |
capela |
2563 |
Copyright (C) 2004-2014, 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 |
1558 |
namespace QSampler { |
35 |
capela |
264 |
|
36 |
capela |
1558 |
class Device; |
37 |
capela |
264 |
|
38 |
capela |
758 |
// Typedef'd QMap. |
39 |
capela |
1558 |
typedef QMap<int, int> ChannelRoutingMap; |
40 |
capela |
758 |
|
41 |
|
|
|
42 |
capela |
264 |
//------------------------------------------------------------------------- |
43 |
capela |
1558 |
// QSampler::Channel - Sampler channel structure. |
44 |
capela |
264 |
// |
45 |
|
|
|
46 |
capela |
1558 |
class Channel |
47 |
capela |
264 |
{ |
48 |
|
|
public: |
49 |
|
|
|
50 |
capela |
467 |
// Constructor. |
51 |
capela |
1558 |
Channel(int iChannelID = -1); |
52 |
capela |
467 |
// Default destructor. |
53 |
capela |
1558 |
~Channel(); |
54 |
capela |
264 |
|
55 |
capela |
467 |
// Add/remove sampler channel methods. |
56 |
|
|
bool addChannel(); |
57 |
|
|
bool removeChannel(); |
58 |
capela |
295 |
|
59 |
capela |
467 |
// Sampler channel ID accessors. |
60 |
capela |
484 |
int channelID() const; |
61 |
capela |
467 |
void setChannelID(int iChannelID); |
62 |
capela |
295 |
|
63 |
capela |
467 |
// Readable channel name. |
64 |
capela |
484 |
QString channelName() const; |
65 |
capela |
467 |
|
66 |
|
|
// Engine name property. |
67 |
capela |
484 |
const QString& engineName() const; |
68 |
capela |
467 |
bool loadEngine(const QString& sEngineName); |
69 |
|
|
|
70 |
|
|
// Instrument file and index. |
71 |
capela |
484 |
const QString& instrumentFile() const; |
72 |
|
|
int instrumentNr() const; |
73 |
|
|
const QString& instrumentName() const; |
74 |
|
|
int instrumentStatus() const; |
75 |
capela |
490 |
|
76 |
capela |
484 |
// Instrument file loader. |
77 |
capela |
467 |
bool loadInstrument(const QString& sInstrumentFile, int iInstrumentNr); |
78 |
capela |
388 |
// Special instrument file/name/number settler. |
79 |
capela |
467 |
bool setInstrument(const QString& sInstrumentFile, int iInstrumentNr); |
80 |
capela |
344 |
|
81 |
capela |
467 |
// MIDI input driver (DEPRECATED). |
82 |
capela |
484 |
const QString& midiDriver() const; |
83 |
capela |
467 |
bool setMidiDriver(const QString& sMidiDriver); |
84 |
capela |
264 |
|
85 |
capela |
467 |
// MIDI input device. |
86 |
capela |
484 |
int midiDevice() const; |
87 |
capela |
467 |
bool setMidiDevice(int iMidiDevice); |
88 |
capela |
264 |
|
89 |
capela |
467 |
// MIDI input port. |
90 |
capela |
484 |
int midiPort() const; |
91 |
capela |
467 |
bool setMidiPort(int iMidiPort); |
92 |
capela |
371 |
|
93 |
capela |
467 |
// MIDI input channel. |
94 |
capela |
484 |
int midiChannel() const; |
95 |
capela |
467 |
bool setMidiChannel(int iMidiChannel); |
96 |
capela |
264 |
|
97 |
capela |
980 |
// MIDI instrument map. |
98 |
|
|
int midiMap() const; |
99 |
|
|
bool setMidiMap(int iMidiMap); |
100 |
|
|
|
101 |
capela |
467 |
// Audio output driver (DEPRECATED). |
102 |
capela |
484 |
const QString& audioDriver() const; |
103 |
capela |
467 |
bool setAudioDriver(const QString& sAudioDriver); |
104 |
capela |
303 |
|
105 |
capela |
467 |
// Audio output device. |
106 |
capela |
484 |
int audioDevice() const; |
107 |
capela |
467 |
bool setAudioDevice(int iAudioDevice); |
108 |
capela |
400 |
|
109 |
capela |
467 |
// Sampler channel volume. |
110 |
capela |
484 |
float volume() const; |
111 |
capela |
467 |
bool setVolume(float fVolume); |
112 |
capela |
264 |
|
113 |
capela |
751 |
// Sampler channel mute state. |
114 |
|
|
bool channelMute() const; |
115 |
|
|
bool setChannelMute(bool bMute); |
116 |
|
|
|
117 |
|
|
// Sampler channel solo state. |
118 |
|
|
bool channelSolo() const; |
119 |
|
|
bool setChannelSolo(bool bSolo); |
120 |
|
|
|
121 |
capela |
758 |
// Audio routing accessors. |
122 |
|
|
int audioChannel(int iAudioOut) const; |
123 |
|
|
bool setAudioChannel(int iAudioOut, int iAudioIn); |
124 |
|
|
// The audio routing map itself. |
125 |
capela |
1558 |
const ChannelRoutingMap& audioRouting() const; |
126 |
capela |
758 |
|
127 |
capela |
467 |
// Istrument name remapper. |
128 |
|
|
void updateInstrumentName(); |
129 |
capela |
303 |
|
130 |
capela |
467 |
// Channel info structure map executive. |
131 |
|
|
bool updateChannelInfo(); |
132 |
|
|
|
133 |
|
|
// Channel setup dialog form. |
134 |
|
|
bool channelSetup(QWidget *pParent); |
135 |
|
|
|
136 |
|
|
// Reset channel method. |
137 |
|
|
bool channelReset(); |
138 |
|
|
|
139 |
schoenebeck |
1366 |
// Spawn instrument editor method. |
140 |
|
|
bool editChannel(); |
141 |
|
|
|
142 |
capela |
467 |
// Message logging methods (brainlessly mapped to main form's). |
143 |
capela |
484 |
void appendMessages (const QString & s) const; |
144 |
|
|
void appendMessagesColor (const QString & s, const QString & c) const; |
145 |
|
|
void appendMessagesText (const QString & s) const; |
146 |
|
|
void appendMessagesError (const QString & s) const; |
147 |
|
|
void appendMessagesClient (const QString & s) const; |
148 |
capela |
467 |
|
149 |
|
|
// Context menu event handler. |
150 |
|
|
void contextMenuEvent(QContextMenuEvent *pEvent); |
151 |
|
|
|
152 |
capela |
388 |
// Common (invalid) name-helpers. |
153 |
capela |
467 |
static QString noEngineName(); |
154 |
|
|
static QString noInstrumentName(); |
155 |
schoenebeck |
519 |
static QString loadingInstrument(); |
156 |
capela |
388 |
|
157 |
|
|
// Check whether a given file is an instrument file. |
158 |
capela |
2108 |
static bool isDlsInstrumentFile (const QString& sInstrumentFile); |
159 |
capela |
2563 |
static bool isSf2InstrumentFile (const QString& sInstrumentFile); |
160 |
capela |
388 |
|
161 |
capela |
467 |
// Retrieve the available instrument name(s) of an instrument file (.gig). |
162 |
|
|
static QString getInstrumentName (const QString& sInstrumentFile, |
163 |
capela |
344 |
int iInstrumentNr, bool bInstrumentNames); |
164 |
capela |
467 |
static QStringList getInstrumentList (const QString& sInstrumentFile, |
165 |
capela |
344 |
bool bInstrumentNames); |
166 |
capela |
299 |
|
167 |
capela |
264 |
private: |
168 |
|
|
|
169 |
capela |
467 |
// Unique channel identifier. |
170 |
|
|
int m_iChannelID; |
171 |
capela |
264 |
|
172 |
capela |
467 |
// Sampler channel info map. |
173 |
|
|
QString m_sEngineName; |
174 |
|
|
QString m_sInstrumentName; |
175 |
|
|
QString m_sInstrumentFile; |
176 |
|
|
int m_iInstrumentNr; |
177 |
|
|
int m_iInstrumentStatus; |
178 |
capela |
490 |
QString m_sMidiDriver; |
179 |
capela |
467 |
int m_iMidiDevice; |
180 |
|
|
int m_iMidiPort; |
181 |
|
|
int m_iMidiChannel; |
182 |
capela |
980 |
int m_iMidiMap; |
183 |
capela |
490 |
QString m_sAudioDriver; |
184 |
capela |
467 |
int m_iAudioDevice; |
185 |
|
|
float m_fVolume; |
186 |
capela |
751 |
bool m_bMute; |
187 |
|
|
bool m_bSolo; |
188 |
capela |
758 |
|
189 |
|
|
// The audio routing mapping. |
190 |
capela |
1558 |
ChannelRoutingMap m_audioRouting; |
191 |
capela |
264 |
}; |
192 |
|
|
|
193 |
capela |
758 |
|
194 |
|
|
//------------------------------------------------------------------------- |
195 |
capela |
1558 |
// QSampler::ChannelRoutingModel - data model for audio routing |
196 |
|
|
// (used for QTableView) |
197 |
capela |
758 |
// |
198 |
|
|
|
199 |
schoenebeck |
1461 |
struct ChannelRoutingItem { |
200 |
capela |
1510 |
QStringList options; |
201 |
|
|
int selection; |
202 |
schoenebeck |
1461 |
}; |
203 |
capela |
758 |
|
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 |
capela |
1558 |
ChannelRoutingMap 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 |
capela |
1558 |
void refresh(Device *pDevice, |
229 |
|
|
const ChannelRoutingMap& routing); |
230 |
capela |
1510 |
|
231 |
|
|
private: |
232 |
|
|
|
233 |
capela |
1558 |
Device *m_pDevice; |
234 |
|
|
ChannelRoutingMap m_routing; |
235 |
schoenebeck |
1461 |
}; |
236 |
|
|
|
237 |
schoenebeck |
1489 |
|
238 |
|
|
//------------------------------------------------------------------------- |
239 |
capela |
1558 |
// QSampler::ChannelRoutingDelegate - table cell renderer for audio routing |
240 |
schoenebeck |
1489 |
// |
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 |
1558 |
} // namespace QSampler |
260 |
|
|
|
261 |
|
|
// So we can use it i.e. through QVariant |
262 |
|
|
Q_DECLARE_METATYPE(QSampler::ChannelRoutingItem) |
263 |
|
|
|
264 |
capela |
264 |
#endif // __qsamplerChannel_h |
265 |
|
|
|
266 |
capela |
1558 |
|
267 |
capela |
264 |
// end of qsamplerChannel.h |