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 <QAbstractTableModel> |
28 |
|
#include <QMetaType> |
29 |
|
#include <QItemDelegate> |
30 |
|
#include <QFontMetrics> |
31 |
|
#include <QModelIndex> |
32 |
|
#include <QSize> |
33 |
|
|
34 |
#include <lscp/client.h> |
#include <lscp/client.h> |
35 |
#include <lscp/device.h> |
#include <lscp/device.h> |
36 |
|
|
37 |
#include "qsamplerOptions.h" |
#include "qsamplerOptions.h" |
38 |
|
|
39 |
class qsamplerMainForm; |
class qsamplerDevice; |
40 |
|
|
41 |
|
|
42 |
|
// Typedef'd QMap. |
43 |
|
typedef QMap<int, int> qsamplerChannelRoutingMap; |
44 |
|
|
45 |
|
|
46 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
52 |
public: |
public: |
53 |
|
|
54 |
// Constructor. |
// Constructor. |
55 |
qsamplerChannel(qsamplerMainForm *pMainForm, int iChannelID = -1); |
qsamplerChannel(int iChannelID = -1); |
56 |
// Default destructor. |
// Default destructor. |
57 |
~qsamplerChannel(); |
~qsamplerChannel(); |
58 |
|
|
|
// Main application form accessor. |
|
|
qsamplerMainForm *mainForm() const; |
|
|
|
|
|
// Main application options accessor. |
|
|
qsamplerOptions *options() const; |
|
|
|
|
|
// LSCP client descriptor accessor. |
|
|
lscp_client_t * client() const; |
|
|
|
|
59 |
// Add/remove sampler channel methods. |
// Add/remove sampler channel methods. |
60 |
bool addChannel(); |
bool addChannel(); |
61 |
bool removeChannel(); |
bool removeChannel(); |
76 |
int instrumentNr() const; |
int instrumentNr() const; |
77 |
const QString& instrumentName() const; |
const QString& instrumentName() const; |
78 |
int instrumentStatus() const; |
int instrumentStatus() const; |
79 |
|
|
80 |
// Instrument file loader. |
// Instrument file loader. |
81 |
bool loadInstrument(const QString& sInstrumentFile, int iInstrumentNr); |
bool loadInstrument(const QString& sInstrumentFile, int iInstrumentNr); |
82 |
// Special instrument file/name/number settler. |
// Special instrument file/name/number settler. |
98 |
int midiChannel() const; |
int midiChannel() const; |
99 |
bool setMidiChannel(int iMidiChannel); |
bool setMidiChannel(int iMidiChannel); |
100 |
|
|
101 |
|
// MIDI instrument map. |
102 |
|
int midiMap() const; |
103 |
|
bool setMidiMap(int iMidiMap); |
104 |
|
|
105 |
// Audio output driver (DEPRECATED). |
// Audio output driver (DEPRECATED). |
106 |
const QString& audioDriver() const; |
const QString& audioDriver() const; |
107 |
bool setAudioDriver(const QString& sAudioDriver); |
bool setAudioDriver(const QString& sAudioDriver); |
114 |
float volume() const; |
float volume() const; |
115 |
bool setVolume(float fVolume); |
bool setVolume(float fVolume); |
116 |
|
|
117 |
|
// 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 |
|
// 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 |
// Istrument name remapper. |
// Istrument name remapper. |
132 |
void updateInstrumentName(); |
void updateInstrumentName(); |
133 |
|
|
140 |
// Reset channel method. |
// Reset channel method. |
141 |
bool channelReset(); |
bool channelReset(); |
142 |
|
|
143 |
|
// Spawn instrument editor method. |
144 |
|
bool editChannel(); |
145 |
|
|
146 |
// Message logging methods (brainlessly mapped to main form's). |
// Message logging methods (brainlessly mapped to main form's). |
147 |
void appendMessages (const QString & s) const; |
void appendMessages (const QString & s) const; |
148 |
void appendMessagesColor (const QString & s, const QString & c) const; |
void appendMessagesColor (const QString & s, const QString & c) const; |
156 |
// Common (invalid) name-helpers. |
// Common (invalid) name-helpers. |
157 |
static QString noEngineName(); |
static QString noEngineName(); |
158 |
static QString noInstrumentName(); |
static QString noInstrumentName(); |
159 |
|
static QString loadingInstrument(); |
160 |
|
|
161 |
// Check whether a given file is an instrument file. |
// Check whether a given file is an instrument file. |
162 |
static bool isInstrumentFile (const QString& sInstrumentFile); |
static bool isInstrumentFile (const QString& sInstrumentFile); |
169 |
|
|
170 |
private: |
private: |
171 |
|
|
|
// Main application form reference. |
|
|
qsamplerMainForm *m_pMainForm; |
|
|
|
|
172 |
// Unique channel identifier. |
// Unique channel identifier. |
173 |
int m_iChannelID; |
int m_iChannelID; |
174 |
|
|
178 |
QString m_sInstrumentFile; |
QString m_sInstrumentFile; |
179 |
int m_iInstrumentNr; |
int m_iInstrumentNr; |
180 |
int m_iInstrumentStatus; |
int m_iInstrumentStatus; |
181 |
QString m_sMidiDriver; // DEPRECATED. |
QString m_sMidiDriver; |
182 |
int m_iMidiDevice; |
int m_iMidiDevice; |
183 |
int m_iMidiPort; |
int m_iMidiPort; |
184 |
int m_iMidiChannel; |
int m_iMidiChannel; |
185 |
QString m_sAudioDriver; // DEPRECATED. |
int m_iMidiMap; |
186 |
|
QString m_sAudioDriver; |
187 |
int m_iAudioDevice; |
int m_iAudioDevice; |
188 |
float m_fVolume; |
float m_fVolume; |
189 |
|
bool m_bMute; |
190 |
|
bool m_bSolo; |
191 |
|
|
192 |
|
// The audio routing mapping. |
193 |
|
qsamplerChannelRoutingMap m_audioRouting; |
194 |
|
}; |
195 |
|
|
196 |
|
|
197 |
|
//------------------------------------------------------------------------- |
198 |
|
// ChannelRoutingModel - data model for audio routing (used for QTableView) |
199 |
|
// |
200 |
|
|
201 |
|
struct ChannelRoutingItem { |
202 |
|
QStringList options; |
203 |
|
int selection; |
204 |
|
}; |
205 |
|
|
206 |
|
// 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 |
|
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 |
|
QVariant data(const QModelIndex &index, int role) const; |
220 |
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; |
221 |
|
|
222 |
|
// own methods |
223 |
|
qsamplerChannelRoutingMap routingMap() const { |
224 |
|
return routing; |
225 |
|
} |
226 |
|
|
227 |
|
void clear() { routing.clear(); } |
228 |
|
|
229 |
|
public slots: |
230 |
|
void refresh(qsamplerDevice *pDevice, const qsamplerChannelRoutingMap& routing); |
231 |
|
|
232 |
|
private: |
233 |
|
qsamplerDevice* pDevice; |
234 |
|
qsamplerChannelRoutingMap routing; |
235 |
}; |
}; |
236 |
|
|
|
#endif // __qsamplerChannel_h |
|
237 |
|
|
238 |
|
//------------------------------------------------------------------------- |
239 |
|
// ChannelRoutingDelegate - table cell renderer for audio routing |
240 |
|
// |
241 |
|
|
242 |
|
class ChannelRoutingDelegate : public QItemDelegate { |
243 |
|
Q_OBJECT |
244 |
|
public: |
245 |
|
ChannelRoutingDelegate(QObject* parent = 0); |
246 |
|
QWidget* createEditor(QWidget* parent, |
247 |
|
const QStyleOptionViewItem& option, |
248 |
|
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 |
|
const QStyleOptionViewItem& option, |
254 |
|
const QModelIndex& index) const; |
255 |
|
}; |
256 |
|
|
257 |
|
#endif // __qsamplerChannel_h |
258 |
|
|
259 |
// end of qsamplerChannel.h |
// end of qsamplerChannel.h |