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 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
51 |
{ |
{ |
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 |
|
|
59 |
// Main application options accessor. |
// Add/remove sampler channel methods. |
60 |
qsamplerOptions *options(); |
bool addChannel(); |
61 |
|
bool removeChannel(); |
62 |
// LSCP client descriptor accessor. |
|
63 |
lscp_client_t * client(); |
// Sampler channel ID accessors. |
64 |
|
int channelID() const; |
65 |
// Add/remove sampler channel methods. |
void setChannelID(int iChannelID); |
66 |
bool addChannel(); |
|
67 |
bool removeChannel(); |
// Readable channel name. |
68 |
|
QString channelName() const; |
69 |
// Sampler channel ID accessors. |
|
70 |
int channelID(); |
// Engine name property. |
71 |
void setChannelID(int iChannelID); |
const QString& engineName() const; |
72 |
|
bool loadEngine(const QString& sEngineName); |
73 |
// Readable channel name. |
|
74 |
QString channelName(); |
// Instrument file and index. |
75 |
|
const QString& instrumentFile() const; |
76 |
// Engine name property. |
int instrumentNr() const; |
77 |
QString& engineName(); |
const QString& instrumentName() const; |
78 |
bool loadEngine(const QString& sEngineName); |
int instrumentStatus() const; |
79 |
|
|
80 |
// Instrument file and index. |
// Instrument file loader. |
81 |
QString& instrumentFile(); |
bool loadInstrument(const QString& sInstrumentFile, int iInstrumentNr); |
82 |
int instrumentNr(); |
// Special instrument file/name/number settler. |
83 |
int instrumentStatus(); |
bool setInstrument(const QString& sInstrumentFile, int iInstrumentNr); |
84 |
bool loadInstrument(const QString& sInstrumentFile, int iInstrumentNr); |
|
85 |
|
// MIDI input driver (DEPRECATED). |
86 |
// MIDI input driver (DEPRECATED). |
const QString& midiDriver() const; |
87 |
QString& midiDriver(); |
bool setMidiDriver(const QString& sMidiDriver); |
88 |
bool setMidiDriver(const QString& sMidiDriver); |
|
89 |
|
// MIDI input device. |
90 |
// MIDI input device. |
int midiDevice() const; |
91 |
int midiDevice(); |
bool setMidiDevice(int iMidiDevice); |
92 |
bool setMidiDevice(int iMidiDevice); |
|
93 |
|
// MIDI input port. |
94 |
// MIDI input port. |
int midiPort() const; |
95 |
int midiPort(); |
bool setMidiPort(int iMidiPort); |
96 |
bool setMidiPort(int iMidiPort); |
|
97 |
|
// MIDI input channel. |
98 |
// MIDI input channel. |
int midiChannel() const; |
99 |
int midiChannel(); |
bool setMidiChannel(int iMidiChannel); |
100 |
bool setMidiChannel(int iMidiChannel); |
|
101 |
|
// MIDI instrument map. |
102 |
// Audio output driver (DEPRECATED). |
int midiMap() const; |
103 |
QString& audioDriver(); |
bool setMidiMap(int iMidiMap); |
104 |
bool setAudioDriver(const QString& sAudioDriver); |
|
105 |
|
// Audio output driver (DEPRECATED). |
106 |
// Audio output device. |
const QString& audioDriver() const; |
107 |
int audioDevice(); |
bool setAudioDriver(const QString& sAudioDriver); |
108 |
bool setAudioDevice(int iAudioDevice); |
|
109 |
|
// Audio output device. |
110 |
// Sampler channel volume. |
int audioDevice() const; |
111 |
float volume(); |
bool setAudioDevice(int iAudioDevice); |
112 |
bool setVolume(float fVolume); |
|
113 |
|
// Sampler channel volume. |
114 |
// Channel info structure map executive. |
float volume() const; |
115 |
bool updateChannelInfo(); |
bool setVolume(float fVolume); |
116 |
|
|
117 |
// Reset channel method. |
// Sampler channel mute state. |
118 |
bool resetChannel(); |
bool channelMute() const; |
119 |
|
bool setChannelMute(bool bMute); |
120 |
// Channel setup dialog form. |
|
121 |
bool channelSetup(QWidget *pParent); |
// Sampler channel solo state. |
122 |
|
bool channelSolo() const; |
123 |
// Message logging methods (brainlessly mapped to main form's). |
bool setChannelSolo(bool bSolo); |
124 |
void appendMessages (const QString & s); |
|
125 |
void appendMessagesColor (const QString & s, const QString & c); |
// Audio routing accessors. |
126 |
void appendMessagesText (const QString & s); |
int audioChannel(int iAudioOut) const; |
127 |
void appendMessagesError (const QString & s); |
bool setAudioChannel(int iAudioOut, int iAudioIn); |
128 |
void appendMessagesClient (const QString & s); |
// The audio routing map itself. |
129 |
|
const qsamplerChannelRoutingMap& audioRouting() const; |
130 |
// Context menu event handler. |
|
131 |
void contextMenuEvent(QContextMenuEvent *pEvent); |
// Istrument name remapper. |
132 |
|
void updateInstrumentName(); |
133 |
// Retrieve the available instrument name(s) of an instrument file (.gig). |
|
134 |
static QString getInstrumentName (const QString& sInstrumentFile, int iInstrumentNr); |
// Channel info structure map executive. |
135 |
static QStringList getInstrumentList (const QString& sInstrumentFile); |
bool updateChannelInfo(); |
136 |
|
|
137 |
// Instrument name(s) retrieval mode. |
// Channel setup dialog form. |
138 |
static bool instrumentNames(); |
bool channelSetup(QWidget *pParent); |
139 |
static void setInstrumentNames (bool bInstrumentNames); |
|
140 |
|
// Reset channel method. |
141 |
|
bool channelReset(); |
142 |
|
|
143 |
|
// Spawn instrument editor method. |
144 |
|
bool editChannel(); |
145 |
|
|
146 |
|
// Message logging methods (brainlessly mapped to main form's). |
147 |
|
void appendMessages (const QString & s) const; |
148 |
|
void appendMessagesColor (const QString & s, const QString & c) const; |
149 |
|
void appendMessagesText (const QString & s) const; |
150 |
|
void appendMessagesError (const QString & s) const; |
151 |
|
void appendMessagesClient (const QString & s) const; |
152 |
|
|
153 |
|
// Context menu event handler. |
154 |
|
void contextMenuEvent(QContextMenuEvent *pEvent); |
155 |
|
|
156 |
|
// Common (invalid) name-helpers. |
157 |
|
static QString noEngineName(); |
158 |
|
static QString noInstrumentName(); |
159 |
|
static QString loadingInstrument(); |
160 |
|
|
161 |
|
// Check whether a given file is an instrument file. |
162 |
|
static bool isInstrumentFile (const QString& sInstrumentFile); |
163 |
|
|
164 |
|
// Retrieve the available instrument name(s) of an instrument file (.gig). |
165 |
|
static QString getInstrumentName (const QString& sInstrumentFile, |
166 |
|
int iInstrumentNr, bool bInstrumentNames); |
167 |
|
static QStringList getInstrumentList (const QString& sInstrumentFile, |
168 |
|
bool bInstrumentNames); |
169 |
|
|
170 |
private: |
private: |
171 |
|
|
172 |
// Main application form reference. |
// Unique channel identifier. |
173 |
qsamplerMainForm *m_pMainForm; |
int m_iChannelID; |
174 |
|
|
175 |
|
// Sampler channel info map. |
176 |
|
QString m_sEngineName; |
177 |
|
QString m_sInstrumentName; |
178 |
|
QString m_sInstrumentFile; |
179 |
|
int m_iInstrumentNr; |
180 |
|
int m_iInstrumentStatus; |
181 |
|
QString m_sMidiDriver; |
182 |
|
int m_iMidiDevice; |
183 |
|
int m_iMidiPort; |
184 |
|
int m_iMidiChannel; |
185 |
|
int m_iMidiMap; |
186 |
|
QString m_sAudioDriver; |
187 |
|
int m_iAudioDevice; |
188 |
|
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 |
|
// qsamplerChannelRoutingTable - Channel routing table widget. |
199 |
|
// |
200 |
|
|
201 |
// Unique channel identifier. |
#if 0 |
202 |
int m_iChannelID; |
class qsamplerChannelRoutingTable : public QTable |
203 |
|
{ |
204 |
|
Q_OBJECT |
205 |
|
|
206 |
|
public: |
207 |
|
|
208 |
|
// Constructor. |
209 |
|
qsamplerChannelRoutingTable(QWidget *pParent = 0, const char *pszName = 0); |
210 |
|
// Default destructor. |
211 |
|
~qsamplerChannelRoutingTable(); |
212 |
|
|
213 |
|
// Common parameter table renderer. |
214 |
|
void refresh(qsamplerDevice *pDevice, |
215 |
|
const qsamplerChannelRoutingMap& routing); |
216 |
|
|
217 |
|
// Commit any pending editing. |
218 |
|
void flush(); |
219 |
|
}; |
220 |
|
#endif |
221 |
|
|
222 |
|
struct ChannelRoutingItem { |
223 |
|
QStringList options; |
224 |
|
int selection; |
225 |
|
}; |
226 |
|
|
227 |
|
// so we can use it i.e. through QVariant |
228 |
|
Q_DECLARE_METATYPE(ChannelRoutingItem) |
229 |
|
|
230 |
|
class ChannelRoutingModel : public QAbstractTableModel { |
231 |
|
Q_OBJECT |
232 |
|
public: |
233 |
|
ChannelRoutingModel(QObject* parent = 0); |
234 |
|
|
235 |
|
// overridden methods from subclass(es) |
236 |
|
int rowCount(const QModelIndex &parent) const; |
237 |
|
int columnCount(const QModelIndex &parent) const; |
238 |
|
QVariant data(const QModelIndex &index, int role) const; |
239 |
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; |
240 |
|
|
241 |
|
public slots: |
242 |
|
void refresh(qsamplerDevice *pDevice, const qsamplerChannelRoutingMap& routing); |
243 |
|
|
244 |
|
private: |
245 |
|
qsamplerDevice* pDevice; |
246 |
|
qsamplerChannelRoutingMap routing; |
247 |
|
}; |
248 |
|
|
249 |
|
class ChannelRoutingDelegate : public QItemDelegate { |
250 |
|
Q_OBJECT |
251 |
|
public: |
252 |
|
ChannelRoutingDelegate(QObject* parent = 0); |
253 |
|
|
254 |
|
QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, |
255 |
|
const QModelIndex& index) const; |
256 |
|
|
257 |
|
void setEditorData(QWidget* editor, const QModelIndex& index) const; |
258 |
|
void setModelData(QWidget* editor, QAbstractItemModel* model, |
259 |
|
const QModelIndex& index) const; |
260 |
|
|
261 |
|
void updateEditorGeometry(QWidget* editor, |
262 |
|
const QStyleOptionViewItem& option, const QModelIndex& index) const; |
263 |
|
}; |
264 |
|
|
265 |
|
|
266 |
|
//------------------------------------------------------------------------- |
267 |
|
// qsamplerChannelRoutingComboBox - Custom combo box for routing table. |
268 |
|
// |
269 |
|
|
270 |
|
/* |
271 |
|
class qsamplerChannelRoutingComboBox : public QTableWidgetItem |
272 |
|
{ |
273 |
|
public: |
274 |
|
|
275 |
|
// Constructor. |
276 |
|
qsamplerChannelRoutingComboBox(QTableWidget *pTable, |
277 |
|
const QStringList& list, const QPixmap& pixmap); |
278 |
|
|
279 |
|
// Public accessors. |
280 |
|
void setCurrentItem(int iCurrentItem); |
281 |
|
int currentItem() const; |
282 |
|
|
283 |
|
protected: |
284 |
|
|
285 |
|
// Virtual implemetations. |
286 |
|
QWidget *createEditor() const; |
287 |
|
void setContentFromEditor(QWidget *pWidget); |
288 |
|
|
289 |
|
private: |
290 |
|
|
291 |
// Sampler channel info map. |
// Initial value holders |
292 |
QString m_sEngineName; |
QStringList m_list; |
293 |
QString m_sInstrumentFile; |
int m_iCurrentItem; |
|
int m_iInstrumentNr; |
|
|
int m_iInstrumentStatus; |
|
|
QString m_sMidiDriver; // DEPRECATED. |
|
|
int m_iMidiDevice; |
|
|
int m_iMidiPort; |
|
|
int m_iMidiChannel; |
|
|
QString m_sAudioDriver; // DEPRECATED. |
|
|
int m_iAudioDevice; |
|
|
float m_fVolume; |
|
|
|
|
|
// Retrieve mode for available instrument name(s) |
|
|
// from an instrument file (.gig). |
|
|
static bool g_bInstrumentNames; |
|
294 |
}; |
}; |
295 |
|
*/ |
296 |
|
|
297 |
#endif // __qsamplerChannel_h |
#endif // __qsamplerChannel_h |
298 |
|
|