1 |
// qsamplerChannel.h |
// qsamplerChannel.h |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2019, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
Copyright (C) 2007, Christian Schoenebeck |
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 |
24 |
#define __qsamplerChannel_h |
#define __qsamplerChannel_h |
25 |
|
|
26 |
#include <QTableWidgetItem> |
#include <QTableWidgetItem> |
|
#include <QAbstractTableModel> |
|
|
#include <QMetaType> |
|
27 |
#include <QItemDelegate> |
#include <QItemDelegate> |
|
#include <QFontMetrics> |
|
|
#include <QModelIndex> |
|
|
#include <QSize> |
|
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 qsamplerDevice; |
namespace QSampler { |
35 |
|
|
36 |
|
class Device; |
37 |
|
|
38 |
// Typedef'd QMap. |
// Typedef'd QMap. |
39 |
typedef QMap<int, int> qsamplerChannelRoutingMap; |
typedef QMap<int, int> ChannelRoutingMap; |
40 |
|
|
41 |
|
|
42 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
43 |
// qsamplerChannel - Sampler channel structure. |
// QSampler::Channel - Sampler channel structure. |
44 |
// |
// |
45 |
|
|
46 |
class qsamplerChannel |
class Channel |
47 |
{ |
{ |
48 |
public: |
public: |
49 |
|
|
50 |
// Constructor. |
// Constructor. |
51 |
qsamplerChannel(int iChannelID = -1); |
Channel(int iChannelID = -1); |
52 |
// Default destructor. |
// Default destructor. |
53 |
~qsamplerChannel(); |
~Channel(); |
54 |
|
|
55 |
// Add/remove sampler channel methods. |
// Add/remove sampler channel methods. |
56 |
bool addChannel(); |
bool addChannel(); |
122 |
int audioChannel(int iAudioOut) const; |
int audioChannel(int iAudioOut) const; |
123 |
bool setAudioChannel(int iAudioOut, int iAudioIn); |
bool setAudioChannel(int iAudioOut, int iAudioIn); |
124 |
// The audio routing map itself. |
// The audio routing map itself. |
125 |
const qsamplerChannelRoutingMap& audioRouting() const; |
const ChannelRoutingMap& audioRouting() const; |
126 |
|
|
127 |
// Istrument name remapper. |
// Istrument name remapper. |
128 |
void updateInstrumentName(); |
void updateInstrumentName(); |
155 |
static QString loadingInstrument(); |
static QString loadingInstrument(); |
156 |
|
|
157 |
// Check whether a given file is an instrument file. |
// Check whether a given file is an instrument file. |
158 |
static bool isInstrumentFile (const QString& sInstrumentFile); |
static bool isDlsInstrumentFile (const QString& sInstrumentFile); |
159 |
|
static bool isSf2InstrumentFile (const QString& sInstrumentFile); |
160 |
|
|
161 |
// Retrieve the available instrument name(s) of an instrument file (.gig). |
// Retrieve the available instrument name(s) of an instrument file (.gig). |
162 |
static QString getInstrumentName (const QString& sInstrumentFile, |
static QString getInstrumentName (const QString& sInstrumentFile, |
187 |
bool m_bSolo; |
bool m_bSolo; |
188 |
|
|
189 |
// The audio routing mapping. |
// The audio routing mapping. |
190 |
qsamplerChannelRoutingMap m_audioRouting; |
ChannelRoutingMap m_audioRouting; |
191 |
}; |
}; |
192 |
|
|
193 |
|
|
194 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
195 |
// ChannelRoutingModel - data model for audio routing (used for QTableView) |
// QSampler::ChannelRoutingModel - data model for audio routing |
196 |
|
// (used for QTableView) |
197 |
// |
// |
198 |
|
|
199 |
struct ChannelRoutingItem { |
struct ChannelRoutingItem { |
200 |
QStringList options; |
QStringList options; |
201 |
int selection; |
int selection; |
202 |
}; |
}; |
203 |
|
|
204 |
// so we can use it i.e. through QVariant |
class ChannelRoutingModel : public QAbstractTableModel |
205 |
Q_DECLARE_METATYPE(ChannelRoutingItem) |
{ |
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 |
|
ChannelRoutingMap routingMap() const { return m_routing; } |
223 |
|
|
224 |
|
void clear() { m_routing.clear(); } |
225 |
|
|
226 |
|
public slots: |
227 |
|
|
228 |
|
void refresh(Device *pDevice, |
229 |
|
const ChannelRoutingMap& routing); |
230 |
|
|
231 |
|
private: |
232 |
|
|
233 |
class ChannelRoutingModel : public QAbstractTableModel { |
Device *m_pDevice; |
234 |
Q_OBJECT |
ChannelRoutingMap m_routing; |
|
public: |
|
|
ChannelRoutingModel(QObject* parent = 0); |
|
|
|
|
|
// overridden methods from subclass(es) |
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const; |
|
|
int columnCount(const QModelIndex &parent = QModelIndex()) const; |
|
|
Qt::ItemFlags flags(const QModelIndex& index) const; |
|
|
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole); |
|
|
QVariant data(const QModelIndex &index, int role) const; |
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; |
|
|
|
|
|
// own methods |
|
|
qsamplerChannelRoutingMap routingMap() const { |
|
|
return routing; |
|
|
} |
|
|
|
|
|
void clear() { routing.clear(); } |
|
|
|
|
|
public slots: |
|
|
void refresh(qsamplerDevice *pDevice, const qsamplerChannelRoutingMap& routing); |
|
|
|
|
|
private: |
|
|
qsamplerDevice* pDevice; |
|
|
qsamplerChannelRoutingMap routing; |
|
235 |
}; |
}; |
236 |
|
|
237 |
|
|
238 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
239 |
// ChannelRoutingDelegate - table cell renderer for audio routing |
// QSampler::ChannelRoutingDelegate - table cell renderer for audio routing |
240 |
// |
// |
241 |
|
|
242 |
class ChannelRoutingDelegate : public QItemDelegate { |
class ChannelRoutingDelegate : public QItemDelegate |
243 |
Q_OBJECT |
{ |
244 |
public: |
Q_OBJECT |
245 |
ChannelRoutingDelegate(QObject* parent = 0); |
|
246 |
QWidget* createEditor(QWidget* parent, |
public: |
247 |
const QStyleOptionViewItem& option, |
|
248 |
const QModelIndex& index) const; |
ChannelRoutingDelegate(QObject* pParent = NULL); |
249 |
void setEditorData(QWidget* editor, const QModelIndex& index) const; |
|
250 |
void setModelData(QWidget* editor, QAbstractItemModel* model, |
QWidget* createEditor(QWidget *pParent, |
251 |
const QModelIndex& index) const; |
const QStyleOptionViewItem& option, const QModelIndex& index) const; |
252 |
void updateEditorGeometry(QWidget* editor, |
void setEditorData(QWidget *pEditor, const QModelIndex& index) const; |
253 |
const QStyleOptionViewItem& option, |
void setModelData(QWidget *pEditor, QAbstractItemModel* model, |
254 |
const QModelIndex& index) const; |
const QModelIndex& index) const; |
255 |
|
void updateEditorGeometry(QWidget *pEditor, |
256 |
|
const QStyleOptionViewItem& option, const QModelIndex& index) const; |
257 |
}; |
}; |
258 |
|
|
259 |
|
} // namespace QSampler |
260 |
|
|
261 |
|
// So we can use it i.e. through QVariant |
262 |
|
Q_DECLARE_METATYPE(QSampler::ChannelRoutingItem) |
263 |
|
|
264 |
#endif // __qsamplerChannel_h |
#endif // __qsamplerChannel_h |
265 |
|
|
266 |
|
|
267 |
// end of qsamplerChannel.h |
// end of qsamplerChannel.h |