1 |
// qsamplerChannel.h |
// qsamplerChannel.h |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2003-2005, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
|
Copyright (C) 2007, Christian Schoenebeck |
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
8 |
modify it under the terms of the GNU General Public License |
modify it under the terms of the GNU General Public License |
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
GNU General Public License for more details. |
GNU General Public License for more details. |
16 |
|
|
17 |
You should have received a copy of the GNU General Public License |
You should have received a copy of the GNU General Public License along |
18 |
along with this program; if not, write to the Free Software |
with this program; if not, write to the Free Software Foundation, Inc., |
19 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
20 |
|
|
21 |
*****************************************************************************/ |
*****************************************************************************/ |
22 |
|
|
23 |
#ifndef __qsamplerChannel_h |
#ifndef __qsamplerChannel_h |
24 |
#define __qsamplerChannel_h |
#define __qsamplerChannel_h |
25 |
|
|
26 |
#include <qobject.h> |
#include <QTableWidgetItem> |
27 |
|
#include <QItemDelegate> |
28 |
|
|
29 |
#include <lscp/client.h> |
#include <lscp/client.h> |
30 |
#include <lscp/device.h> |
#include <lscp/device.h> |
31 |
|
|
32 |
#include "qsamplerOptions.h" |
#include "qsamplerOptions.h" |
33 |
|
|
34 |
class qsamplerMainForm; |
class qsamplerDevice; |
35 |
|
|
36 |
|
|
37 |
|
// Typedef'd QMap. |
38 |
|
typedef QMap<int, int> qsamplerChannelRoutingMap; |
39 |
|
|
40 |
|
|
41 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
47 |
public: |
public: |
48 |
|
|
49 |
// Constructor. |
// Constructor. |
50 |
qsamplerChannel(qsamplerMainForm *pMainForm, int iChannelID = -1); |
qsamplerChannel(int iChannelID = -1); |
51 |
// Default destructor. |
// Default destructor. |
52 |
~qsamplerChannel(); |
~qsamplerChannel(); |
53 |
|
|
|
// Main application form accessor. |
|
|
qsamplerMainForm *mainForm() const; |
|
|
|
|
|
// Main application options accessor. |
|
|
qsamplerOptions *options() const; |
|
|
|
|
|
// LSCP client descriptor accessor. |
|
|
lscp_client_t * client() const; |
|
|
|
|
54 |
// Add/remove sampler channel methods. |
// Add/remove sampler channel methods. |
55 |
bool addChannel(); |
bool addChannel(); |
56 |
bool removeChannel(); |
bool removeChannel(); |
93 |
int midiChannel() const; |
int midiChannel() const; |
94 |
bool setMidiChannel(int iMidiChannel); |
bool setMidiChannel(int iMidiChannel); |
95 |
|
|
96 |
|
// MIDI instrument map. |
97 |
|
int midiMap() const; |
98 |
|
bool setMidiMap(int iMidiMap); |
99 |
|
|
100 |
// Audio output driver (DEPRECATED). |
// Audio output driver (DEPRECATED). |
101 |
const QString& audioDriver() const; |
const QString& audioDriver() const; |
102 |
bool setAudioDriver(const QString& sAudioDriver); |
bool setAudioDriver(const QString& sAudioDriver); |
109 |
float volume() const; |
float volume() const; |
110 |
bool setVolume(float fVolume); |
bool setVolume(float fVolume); |
111 |
|
|
112 |
|
// 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 |
|
// 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 |
// Istrument name remapper. |
// Istrument name remapper. |
127 |
void updateInstrumentName(); |
void updateInstrumentName(); |
128 |
|
|
135 |
// Reset channel method. |
// Reset channel method. |
136 |
bool channelReset(); |
bool channelReset(); |
137 |
|
|
138 |
|
// Spawn instrument editor method. |
139 |
|
bool editChannel(); |
140 |
|
|
141 |
// Message logging methods (brainlessly mapped to main form's). |
// Message logging methods (brainlessly mapped to main form's). |
142 |
void appendMessages (const QString & s) const; |
void appendMessages (const QString & s) const; |
143 |
void appendMessagesColor (const QString & s, const QString & c) const; |
void appendMessagesColor (const QString & s, const QString & c) const; |
151 |
// Common (invalid) name-helpers. |
// Common (invalid) name-helpers. |
152 |
static QString noEngineName(); |
static QString noEngineName(); |
153 |
static QString noInstrumentName(); |
static QString noInstrumentName(); |
154 |
|
static QString loadingInstrument(); |
155 |
|
|
156 |
// Check whether a given file is an instrument file. |
// Check whether a given file is an instrument file. |
157 |
static bool isInstrumentFile (const QString& sInstrumentFile); |
static bool isInstrumentFile (const QString& sInstrumentFile); |
164 |
|
|
165 |
private: |
private: |
166 |
|
|
|
// Main application form reference. |
|
|
qsamplerMainForm *m_pMainForm; |
|
|
|
|
167 |
// Unique channel identifier. |
// Unique channel identifier. |
168 |
int m_iChannelID; |
int m_iChannelID; |
169 |
|
|
177 |
int m_iMidiDevice; |
int m_iMidiDevice; |
178 |
int m_iMidiPort; |
int m_iMidiPort; |
179 |
int m_iMidiChannel; |
int m_iMidiChannel; |
180 |
|
int m_iMidiMap; |
181 |
QString m_sAudioDriver; |
QString m_sAudioDriver; |
182 |
int m_iAudioDevice; |
int m_iAudioDevice; |
183 |
float m_fVolume; |
float m_fVolume; |
184 |
|
bool m_bMute; |
185 |
|
bool m_bSolo; |
186 |
|
|
187 |
|
// The audio routing mapping. |
188 |
|
qsamplerChannelRoutingMap m_audioRouting; |
189 |
}; |
}; |
190 |
|
|
|
#endif // __qsamplerChannel_h |
|
191 |
|
|
192 |
|
//------------------------------------------------------------------------- |
193 |
|
// ChannelRoutingModel - data model for audio routing (used for QTableView) |
194 |
|
// |
195 |
|
|
196 |
|
struct ChannelRoutingItem { |
197 |
|
QStringList options; |
198 |
|
int selection; |
199 |
|
}; |
200 |
|
|
201 |
|
// so we can use it i.e. through QVariant |
202 |
|
Q_DECLARE_METATYPE(ChannelRoutingItem) |
203 |
|
|
204 |
|
class ChannelRoutingModel : public QAbstractTableModel |
205 |
|
{ |
206 |
|
Q_OBJECT |
207 |
|
public: |
208 |
|
|
209 |
|
ChannelRoutingModel(QObject* pParent = NULL); |
210 |
|
|
211 |
|
// 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 |
|
|
221 |
|
// own methods |
222 |
|
qsamplerChannelRoutingMap routingMap() const { return m_routing; } |
223 |
|
|
224 |
|
void clear() { m_routing.clear(); } |
225 |
|
|
226 |
|
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 |
|
}; |
236 |
|
|
237 |
|
|
238 |
|
//------------------------------------------------------------------------- |
239 |
|
// ChannelRoutingDelegate - table cell renderer for audio routing |
240 |
|
// |
241 |
|
|
242 |
|
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 |
|
}; |
258 |
|
|
259 |
|
#endif // __qsamplerChannel_h |
260 |
|
|
261 |
// end of qsamplerChannel.h |
// end of qsamplerChannel.h |