1 |
// qsamplerChannel.h |
// qsamplerChannel.h |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2006, 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 |
23 |
#ifndef __qsamplerChannel_h |
#ifndef __qsamplerChannel_h |
24 |
#define __qsamplerChannel_h |
#define __qsamplerChannel_h |
25 |
|
|
26 |
#include <qtable.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> |
32 |
#include "qsamplerOptions.h" |
#include "qsamplerOptions.h" |
33 |
|
|
34 |
class qsamplerDevice; |
class qsamplerDevice; |
|
class qsamplerMainForm; |
|
35 |
|
|
36 |
|
|
37 |
// Typedef'd QMap. |
// Typedef'd QMap. |
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); |
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; |
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; |
190 |
|
|
191 |
|
|
192 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
193 |
// qsamplerChannelRoutingTable - Channel routing table widget. |
// ChannelRoutingModel - data model for audio routing (used for QTableView) |
194 |
// |
// |
195 |
|
|
196 |
class qsamplerChannelRoutingTable : public QTable |
struct ChannelRoutingItem { |
197 |
{ |
QStringList options; |
198 |
Q_OBJECT |
int selection; |
199 |
|
}; |
|
public: |
|
|
|
|
|
// Constructor. |
|
|
qsamplerChannelRoutingTable(QWidget *pParent = 0, const char *pszName = 0); |
|
|
// Default destructor. |
|
|
~qsamplerChannelRoutingTable(); |
|
200 |
|
|
201 |
// Common parameter table renderer. |
// so we can use it i.e. through QVariant |
202 |
void refresh(qsamplerDevice *pDevice, |
Q_DECLARE_METATYPE(ChannelRoutingItem) |
|
const qsamplerChannelRoutingMap& routing); |
|
203 |
|
|
204 |
// Commit any pending editing. |
class ChannelRoutingModel : public QAbstractTableModel { |
205 |
void flush(); |
Q_OBJECT |
206 |
|
public: |
207 |
|
ChannelRoutingModel(QObject* parent = 0); |
208 |
|
|
209 |
|
// overridden methods from subclass(es) |
210 |
|
int rowCount(const QModelIndex &parent = QModelIndex()) const; |
211 |
|
int columnCount(const QModelIndex &parent = QModelIndex()) const; |
212 |
|
Qt::ItemFlags flags(const QModelIndex& index) const; |
213 |
|
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole); |
214 |
|
QVariant data(const QModelIndex &index, int role) const; |
215 |
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; |
216 |
|
|
217 |
|
// own methods |
218 |
|
qsamplerChannelRoutingMap routingMap() const { |
219 |
|
return routing; |
220 |
|
} |
221 |
|
|
222 |
|
void clear() { routing.clear(); } |
223 |
|
|
224 |
|
public slots: |
225 |
|
void refresh(qsamplerDevice *pDevice, const qsamplerChannelRoutingMap& routing); |
226 |
|
|
227 |
|
private: |
228 |
|
qsamplerDevice* pDevice; |
229 |
|
qsamplerChannelRoutingMap routing; |
230 |
}; |
}; |
231 |
|
|
232 |
|
|
233 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
234 |
// qsamplerChannelRoutingComboBox - Custom combo box for routing table. |
// ChannelRoutingDelegate - table cell renderer for audio routing |
235 |
// |
// |
236 |
|
|
237 |
class qsamplerChannelRoutingComboBox : public QTableItem |
class ChannelRoutingDelegate : public QItemDelegate { |
238 |
{ |
Q_OBJECT |
239 |
public: |
public: |
240 |
|
ChannelRoutingDelegate(QObject* parent = 0); |
241 |
// Constructor. |
QWidget* createEditor(QWidget* parent, |
242 |
qsamplerChannelRoutingComboBox(QTable *pTable, |
const QStyleOptionViewItem& option, |
243 |
const QStringList& list, const QPixmap& pixmap); |
const QModelIndex& index) const; |
244 |
|
void setEditorData(QWidget* editor, const QModelIndex& index) const; |
245 |
// Public accessors. |
void setModelData(QWidget* editor, QAbstractItemModel* model, |
246 |
void setCurrentItem(int iCurrentItem); |
const QModelIndex& index) const; |
247 |
int currentItem() const; |
void updateEditorGeometry(QWidget* editor, |
248 |
|
const QStyleOptionViewItem& option, |
249 |
protected: |
const QModelIndex& index) const; |
|
|
|
|
// Virtual implemetations. |
|
|
QWidget *createEditor() const; |
|
|
void setContentFromEditor(QWidget *pWidget); |
|
|
|
|
|
private: |
|
|
|
|
|
// Initial value holders |
|
|
QStringList m_list; |
|
|
int m_iCurrentItem; |
|
250 |
}; |
}; |
251 |
|
|
|
|
|
252 |
#endif // __qsamplerChannel_h |
#endif // __qsamplerChannel_h |
253 |
|
|
|
|
|
254 |
// end of qsamplerChannel.h |
// end of qsamplerChannel.h |