1 |
// qsamplerChannel.cpp |
// qsamplerChannel.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2003-2005, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2006, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
|
|
6 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
7 |
modify it under the terms of the GNU General Public License |
modify it under the terms of the GNU General Public License |
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
GNU General Public License for more details. |
GNU General Public License for more details. |
15 |
|
|
16 |
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 |
17 |
along with this program; if not, write to the Free Software |
with this program; if not, write to the Free Software Foundation, Inc., |
18 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
19 |
|
|
20 |
*****************************************************************************/ |
*****************************************************************************/ |
21 |
|
|
22 |
|
#include "qsamplerAbout.h" |
23 |
#include "qsamplerChannel.h" |
#include "qsamplerChannel.h" |
24 |
|
|
25 |
#include "qsamplerMainForm.h" |
#include "qsamplerMainForm.h" |
26 |
#include "qsamplerChannelForm.h" |
#include "qsamplerChannelForm.h" |
27 |
|
|
|
#include "config.h" |
|
|
|
|
28 |
#include <qfileinfo.h> |
#include <qfileinfo.h> |
29 |
|
#include <qcombobox.h> |
30 |
|
|
31 |
#ifdef CONFIG_LIBGIG |
#ifdef CONFIG_LIBGIG |
32 |
#include "gig.h" |
#include "gig.h" |
33 |
#endif |
#endif |
34 |
|
|
35 |
#define QSAMPLER_INSTRUMENT_MAX 8 |
#define QSAMPLER_INSTRUMENT_MAX 100 |
36 |
|
|
37 |
|
|
38 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
40 |
// |
// |
41 |
|
|
42 |
// Constructor. |
// Constructor. |
43 |
qsamplerChannel::qsamplerChannel ( qsamplerMainForm *pMainForm, int iChannelID ) |
qsamplerChannel::qsamplerChannel ( int iChannelID ) |
44 |
{ |
{ |
45 |
m_pMainForm = pMainForm; |
m_iChannelID = iChannelID; |
|
m_iChannelID = iChannelID; |
|
46 |
|
|
47 |
// m_sEngineName = noEngineName(); |
// m_sEngineName = noEngineName(); |
48 |
// m_sInstrumentName = noInstrumentName(); |
// m_sInstrumentName = noInstrumentName(); |
49 |
// m_sInstrumentFile = m_sInstrumentName; |
// m_sInstrumentFile = m_sInstrumentName; |
50 |
m_iInstrumentNr = -1; |
m_iInstrumentNr = -1; |
51 |
m_iInstrumentStatus = -1; |
m_iInstrumentStatus = -1; |
52 |
m_sMidiDriver = "Alsa"; // DEPRECATED. |
m_sMidiDriver = "ALSA"; |
53 |
m_iMidiDevice = -1; |
m_iMidiDevice = -1; |
54 |
m_iMidiPort = -1; |
m_iMidiPort = -1; |
55 |
m_iMidiChannel = -1; |
m_iMidiChannel = -1; |
56 |
m_sAudioDriver = "Alsa"; // DEPRECATED. |
m_sAudioDriver = "ALSA"; |
57 |
m_iAudioDevice = -1; |
m_iAudioDevice = -1; |
58 |
m_fVolume = 0.0; |
m_fVolume = 0.0; |
59 |
|
m_bMute = false; |
60 |
|
m_bSolo = false; |
61 |
} |
} |
62 |
|
|
63 |
// Default destructor. |
// Default destructor. |
66 |
} |
} |
67 |
|
|
68 |
|
|
|
// The global options settings delegated property. |
|
|
qsamplerOptions *qsamplerChannel::options (void) |
|
|
{ |
|
|
if (m_pMainForm == NULL) |
|
|
return NULL; |
|
|
|
|
|
return m_pMainForm->options(); |
|
|
} |
|
|
|
|
|
|
|
|
// The client descriptor delegated property. |
|
|
lscp_client_t *qsamplerChannel::client (void) |
|
|
{ |
|
|
if (m_pMainForm == NULL) |
|
|
return NULL; |
|
|
|
|
|
return m_pMainForm->client(); |
|
|
} |
|
|
|
|
|
|
|
69 |
// Create a new sampler channel, if not already. |
// Create a new sampler channel, if not already. |
70 |
bool qsamplerChannel::addChannel (void) |
bool qsamplerChannel::addChannel (void) |
71 |
{ |
{ |
72 |
if (client() == NULL) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
73 |
return false; |
if (pMainForm == NULL) |
74 |
|
return false; |
75 |
// Are we a new channel? |
if (pMainForm->client() == NULL) |
76 |
if (m_iChannelID < 0) { |
return false; |
77 |
m_iChannelID = ::lscp_add_channel(client()); |
|
78 |
if (m_iChannelID < 0) { |
// Are we a new channel? |
79 |
appendMessagesClient("lscp_add_channel"); |
if (m_iChannelID < 0) { |
80 |
appendMessagesError(QObject::tr("Could not create the new channel.\n\nSorry.")); |
m_iChannelID = ::lscp_add_channel(pMainForm->client()); |
81 |
} // Otherwise it's created... |
if (m_iChannelID < 0) { |
82 |
else appendMessages(QObject::tr("Channel %1 created.").arg(m_iChannelID)); |
appendMessagesClient("lscp_add_channel"); |
83 |
} |
appendMessagesError( |
84 |
|
QObject::tr("Could not add channel.\n\nSorry.")); |
85 |
|
} // Otherwise it's created... |
86 |
|
else appendMessages(QObject::tr("added.")); |
87 |
|
} |
88 |
|
|
89 |
// Return whether we're a valid channel... |
// Return whether we're a valid channel... |
90 |
return (m_iChannelID >= 0); |
return (m_iChannelID >= 0); |
91 |
} |
} |
92 |
|
|
93 |
|
|
94 |
// Remove sampler channel. |
// Remove sampler channel. |
95 |
bool qsamplerChannel::removeChannel (void) |
bool qsamplerChannel::removeChannel (void) |
96 |
{ |
{ |
97 |
if (client() == NULL) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
98 |
return false; |
if (pMainForm == NULL) |
99 |
|
return false; |
100 |
|
if (pMainForm->client() == NULL) |
101 |
|
return false; |
102 |
|
|
103 |
|
// Are we an existing channel? |
104 |
|
if (m_iChannelID >= 0) { |
105 |
|
if (::lscp_remove_channel(pMainForm->client(), m_iChannelID) != LSCP_OK) { |
106 |
|
appendMessagesClient("lscp_remove_channel"); |
107 |
|
appendMessagesError(QObject::tr("Could not remove channel.\n\nSorry.")); |
108 |
|
} else { |
109 |
|
// Otherwise it's removed. |
110 |
|
appendMessages(QObject::tr("removed.")); |
111 |
|
m_iChannelID = -1; |
112 |
|
} |
113 |
|
} |
114 |
|
|
115 |
// Are we an existing channel? |
// Return whether we've removed the channel... |
116 |
if (m_iChannelID >= 0) { |
return (m_iChannelID < 0); |
|
if (::lscp_remove_channel(client(), m_iChannelID) != LSCP_OK) { |
|
|
appendMessagesClient("lscp_remove_channel"); |
|
|
appendMessagesError(QObject::tr("Could not remove channel.\n\nSorry.")); |
|
|
} else { |
|
|
// Otherwise it's removed. |
|
|
appendMessages(QObject::tr("Channel %1 removed.").arg(m_iChannelID)); |
|
|
m_iChannelID = -1; |
|
|
} |
|
|
} |
|
|
|
|
|
// Return whether we've removed the channel... |
|
|
return (m_iChannelID < 0); |
|
117 |
} |
} |
118 |
|
|
119 |
|
|
120 |
// Channel-ID (aka Sammpler-Channel) accessors. |
// Channel-ID (aka Sammpler-Channel) accessors. |
121 |
int qsamplerChannel::channelID (void) |
int qsamplerChannel::channelID (void) const |
122 |
{ |
{ |
123 |
return m_iChannelID; |
return m_iChannelID; |
124 |
} |
} |
125 |
|
|
126 |
void qsamplerChannel::setChannelID ( int iChannelID ) |
void qsamplerChannel::setChannelID ( int iChannelID ) |
127 |
{ |
{ |
128 |
m_iChannelID = iChannelID; |
m_iChannelID = iChannelID; |
129 |
} |
} |
130 |
|
|
131 |
|
|
132 |
// Readable channel name. |
// Readable channel name. |
133 |
QString qsamplerChannel::channelName (void) |
QString qsamplerChannel::channelName (void) const |
134 |
{ |
{ |
135 |
return (m_iChannelID < 0 ? QObject::tr("New Channel") : QObject::tr("Channel %1").arg(m_iChannelID)); |
return (m_iChannelID < 0 ? QObject::tr("New Channel") : QObject::tr("Channel %1").arg(m_iChannelID)); |
136 |
} |
} |
137 |
|
|
138 |
|
|
139 |
// Engine name accessors. |
// Engine name accessors. |
140 |
QString& qsamplerChannel::engineName (void) |
const QString& qsamplerChannel::engineName (void) const |
141 |
{ |
{ |
142 |
return m_sEngineName; |
return m_sEngineName; |
143 |
} |
} |
144 |
|
|
145 |
bool qsamplerChannel::loadEngine ( const QString& sEngineName ) |
bool qsamplerChannel::loadEngine ( const QString& sEngineName ) |
146 |
{ |
{ |
147 |
if (client() == NULL || m_iChannelID < 0) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
148 |
return false; |
if (pMainForm == NULL) |
149 |
|
return false; |
150 |
|
if (pMainForm->client() == NULL || m_iChannelID < 0) |
151 |
|
return false; |
152 |
|
if (m_iInstrumentStatus == 100 && m_sEngineName == sEngineName) |
153 |
|
return true; |
154 |
|
|
155 |
|
if (::lscp_load_engine(pMainForm->client(), sEngineName.latin1(), m_iChannelID) != LSCP_OK) { |
156 |
|
appendMessagesClient("lscp_load_engine"); |
157 |
|
return false; |
158 |
|
} |
159 |
|
|
160 |
if (::lscp_load_engine(client(), sEngineName.latin1(), m_iChannelID) != LSCP_OK) { |
appendMessages(QObject::tr("Engine: %1.").arg(sEngineName)); |
|
appendMessagesClient("lscp_load_engine"); |
|
|
return false; |
|
|
} |
|
161 |
|
|
162 |
m_sEngineName = sEngineName; |
m_sEngineName = sEngineName; |
163 |
return true; |
return true; |
164 |
} |
} |
165 |
|
|
166 |
|
|
167 |
// Instrument filename accessor. |
// Instrument filename accessor. |
168 |
QString& qsamplerChannel::instrumentFile (void) |
const QString& qsamplerChannel::instrumentFile (void) const |
169 |
{ |
{ |
170 |
return m_sInstrumentFile; |
return m_sInstrumentFile; |
171 |
} |
} |
172 |
|
|
173 |
// Instrument index accessor. |
// Instrument index accessor. |
174 |
int qsamplerChannel::instrumentNr (void) |
int qsamplerChannel::instrumentNr (void) const |
175 |
{ |
{ |
176 |
return m_iInstrumentNr; |
return m_iInstrumentNr; |
177 |
} |
} |
178 |
|
|
179 |
// Instrument name accessor. |
// Instrument name accessor. |
180 |
QString& qsamplerChannel::instrumentName (void) |
const QString& qsamplerChannel::instrumentName (void) const |
181 |
{ |
{ |
182 |
return m_sInstrumentName; |
return m_sInstrumentName; |
183 |
} |
} |
184 |
|
|
185 |
// Instrument status accessor. |
// Instrument status accessor. |
186 |
int qsamplerChannel::instrumentStatus (void) |
int qsamplerChannel::instrumentStatus (void) const |
187 |
{ |
{ |
188 |
return m_iInstrumentStatus; |
return m_iInstrumentStatus; |
189 |
} |
} |
190 |
|
|
191 |
// Instrument file loader. |
// Instrument file loader. |
192 |
bool qsamplerChannel::loadInstrument ( const QString& sInstrumentFile, int iInstrumentNr ) |
bool qsamplerChannel::loadInstrument ( const QString& sInstrumentFile, int iInstrumentNr ) |
193 |
{ |
{ |
194 |
if (client() == NULL || m_iChannelID < 0) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
195 |
return false; |
if (pMainForm == NULL) |
196 |
|
return false; |
197 |
|
if (pMainForm->client() == NULL || m_iChannelID < 0) |
198 |
|
return false; |
199 |
if (!isInstrumentFile(sInstrumentFile)) |
if (!isInstrumentFile(sInstrumentFile)) |
200 |
return false; |
return false; |
201 |
|
if (m_iInstrumentStatus == 100 && m_sInstrumentFile == sInstrumentFile && m_iInstrumentNr == iInstrumentNr) |
202 |
|
return true; |
203 |
|
|
204 |
|
if (::lscp_load_instrument_non_modal(pMainForm->client(), sInstrumentFile.latin1(), iInstrumentNr, m_iChannelID) != LSCP_OK) { |
205 |
|
appendMessagesClient("lscp_load_instrument"); |
206 |
|
return false; |
207 |
|
} |
208 |
|
|
209 |
if (::lscp_load_instrument_non_modal(client(), sInstrumentFile.latin1(), iInstrumentNr, m_iChannelID) != LSCP_OK) { |
appendMessages(QObject::tr("Instrument: \"%1\" (%2).") |
210 |
appendMessagesClient("lscp_load_instrument"); |
.arg(sInstrumentFile).arg(iInstrumentNr)); |
|
return false; |
|
|
} |
|
211 |
|
|
212 |
return setInstrument(sInstrumentFile, iInstrumentNr); |
return setInstrument(sInstrumentFile, iInstrumentNr); |
213 |
} |
} |
214 |
|
|
215 |
|
|
216 |
// Special instrument file/name/number settler. |
// Special instrument file/name/number settler. |
217 |
bool qsamplerChannel::setInstrument ( const QString& sInstrumentFile, int iInstrumentNr ) |
bool qsamplerChannel::setInstrument ( const QString& sInstrumentFile, int iInstrumentNr ) |
218 |
{ |
{ |
219 |
m_sInstrumentFile = sInstrumentFile; |
m_sInstrumentFile = sInstrumentFile; |
220 |
m_iInstrumentNr = iInstrumentNr; |
m_iInstrumentNr = iInstrumentNr; |
221 |
#ifdef CONFIG_INSTRUMENT_NAME |
#ifdef CONFIG_INSTRUMENT_NAME |
222 |
m_sInstrumentName = QString::null; // We'll get it, maybe later, on channel_info... |
m_sInstrumentName = QString::null; // We'll get it, maybe later, on channel_info... |
223 |
#else |
#else |
224 |
m_sInstrumentName = getInstrumentName(sInstrumentFile, iInstrumentNr, true); |
m_sInstrumentName = getInstrumentName(sInstrumentFile, iInstrumentNr, true); |
225 |
#endif |
#endif |
226 |
m_iInstrumentStatus = 0; |
m_iInstrumentStatus = 0; |
227 |
|
|
228 |
return true; |
return true; |
229 |
} |
} |
230 |
|
|
231 |
|
|
232 |
// MIDI driver type accessors (DEPRECATED). |
// MIDI driver type accessors (DEPRECATED). |
233 |
QString& qsamplerChannel::midiDriver (void) |
const QString& qsamplerChannel::midiDriver (void) const |
234 |
{ |
{ |
235 |
return m_sMidiDriver; |
return m_sMidiDriver; |
236 |
} |
} |
237 |
|
|
238 |
bool qsamplerChannel::setMidiDriver ( const QString& sMidiDriver ) |
bool qsamplerChannel::setMidiDriver ( const QString& sMidiDriver ) |
239 |
{ |
{ |
240 |
if (client() == NULL || m_iChannelID < 0) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
241 |
return false; |
if (pMainForm == NULL) |
242 |
|
return false; |
243 |
|
if (pMainForm->client() == NULL || m_iChannelID < 0) |
244 |
|
return false; |
245 |
|
if (m_iInstrumentStatus == 100 && m_sMidiDriver == sMidiDriver) |
246 |
|
return true; |
247 |
|
|
248 |
|
if (::lscp_set_channel_midi_type(pMainForm->client(), m_iChannelID, sMidiDriver.latin1()) != LSCP_OK) { |
249 |
|
appendMessagesClient("lscp_set_channel_midi_type"); |
250 |
|
return false; |
251 |
|
} |
252 |
|
|
253 |
if (::lscp_set_channel_midi_type(client(), m_iChannelID, sMidiDriver.latin1()) != LSCP_OK) { |
appendMessages(QObject::tr("MIDI driver: %1.").arg(sMidiDriver)); |
|
appendMessagesClient("lscp_set_channel_midi_type"); |
|
|
return false; |
|
|
} |
|
254 |
|
|
255 |
m_sMidiDriver = sMidiDriver; |
m_sMidiDriver = sMidiDriver; |
256 |
return true; |
return true; |
257 |
} |
} |
258 |
|
|
259 |
|
|
260 |
// MIDI device accessors. |
// MIDI device accessors. |
261 |
int qsamplerChannel::midiDevice (void) |
int qsamplerChannel::midiDevice (void) const |
262 |
{ |
{ |
263 |
return m_iMidiDevice; |
return m_iMidiDevice; |
264 |
} |
} |
265 |
|
|
266 |
bool qsamplerChannel::setMidiDevice ( int iMidiDevice ) |
bool qsamplerChannel::setMidiDevice ( int iMidiDevice ) |
267 |
{ |
{ |
268 |
if (client() == NULL || m_iChannelID < 0) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
269 |
return false; |
if (pMainForm == NULL) |
270 |
|
return false; |
271 |
|
if (pMainForm->client() == NULL || m_iChannelID < 0) |
272 |
|
return false; |
273 |
|
if (m_iInstrumentStatus == 100 && m_iMidiDevice == iMidiDevice) |
274 |
|
return true; |
275 |
|
|
276 |
|
if (::lscp_set_channel_midi_device(pMainForm->client(), m_iChannelID, iMidiDevice) != LSCP_OK) { |
277 |
|
appendMessagesClient("lscp_set_channel_midi_device"); |
278 |
|
return false; |
279 |
|
} |
280 |
|
|
281 |
if (::lscp_set_channel_midi_device(client(), m_iChannelID, iMidiDevice) != LSCP_OK) { |
appendMessages(QObject::tr("MIDI device: %1.").arg(iMidiDevice)); |
|
appendMessagesClient("lscp_set_channel_midi_device"); |
|
|
return false; |
|
|
} |
|
282 |
|
|
283 |
m_iMidiDevice = iMidiDevice; |
m_iMidiDevice = iMidiDevice; |
284 |
return true; |
return true; |
285 |
} |
} |
286 |
|
|
287 |
|
|
288 |
// MIDI port number accessor. |
// MIDI port number accessor. |
289 |
int qsamplerChannel::midiPort (void) |
int qsamplerChannel::midiPort (void) const |
290 |
{ |
{ |
291 |
return m_iMidiPort; |
return m_iMidiPort; |
292 |
} |
} |
293 |
|
|
294 |
bool qsamplerChannel::setMidiPort ( int iMidiPort ) |
bool qsamplerChannel::setMidiPort ( int iMidiPort ) |
295 |
{ |
{ |
296 |
if (client() == NULL || m_iChannelID < 0) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
297 |
return false; |
if (pMainForm == NULL) |
298 |
|
return false; |
299 |
|
if (pMainForm->client() == NULL || m_iChannelID < 0) |
300 |
|
return false; |
301 |
|
if (m_iInstrumentStatus == 100 && m_iMidiPort == iMidiPort) |
302 |
|
return true; |
303 |
|
|
304 |
|
if (::lscp_set_channel_midi_port(pMainForm->client(), m_iChannelID, iMidiPort) != LSCP_OK) { |
305 |
|
appendMessagesClient("lscp_set_channel_midi_port"); |
306 |
|
return false; |
307 |
|
} |
308 |
|
|
309 |
if (::lscp_set_channel_midi_port(client(), m_iChannelID, iMidiPort) != LSCP_OK) { |
appendMessages(QObject::tr("MIDI port: %1.").arg(iMidiPort)); |
|
appendMessagesClient("lscp_set_channel_midi_port"); |
|
|
return false; |
|
|
} |
|
310 |
|
|
311 |
m_iMidiPort = iMidiPort; |
m_iMidiPort = iMidiPort; |
312 |
return true; |
return true; |
313 |
} |
} |
314 |
|
|
315 |
|
|
316 |
// MIDI channel accessor. |
// MIDI channel accessor. |
317 |
int qsamplerChannel::midiChannel (void) |
int qsamplerChannel::midiChannel (void) const |
318 |
{ |
{ |
319 |
return m_iMidiChannel; |
return m_iMidiChannel; |
320 |
} |
} |
321 |
|
|
322 |
bool qsamplerChannel::setMidiChannel ( int iMidiChannel ) |
bool qsamplerChannel::setMidiChannel ( int iMidiChannel ) |
323 |
{ |
{ |
324 |
if (client() == NULL || m_iChannelID < 0) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
325 |
return false; |
if (pMainForm == NULL) |
326 |
|
return false; |
327 |
|
if (pMainForm->client() == NULL || m_iChannelID < 0) |
328 |
|
return false; |
329 |
|
if (m_iInstrumentStatus == 100 && m_iMidiChannel == iMidiChannel) |
330 |
|
return true; |
331 |
|
|
332 |
|
if (::lscp_set_channel_midi_channel(pMainForm->client(), m_iChannelID, iMidiChannel) != LSCP_OK) { |
333 |
|
appendMessagesClient("lscp_set_channel_midi_channel"); |
334 |
|
return false; |
335 |
|
} |
336 |
|
|
337 |
if (::lscp_set_channel_midi_channel(client(), m_iChannelID, iMidiChannel) != LSCP_OK) { |
appendMessages(QObject::tr("MIDI channel: %1.").arg(iMidiChannel)); |
|
appendMessagesClient("lscp_set_channel_midi_channel"); |
|
|
return false; |
|
|
} |
|
338 |
|
|
339 |
m_iMidiChannel = iMidiChannel; |
m_iMidiChannel = iMidiChannel; |
340 |
return true; |
return true; |
341 |
} |
} |
342 |
|
|
343 |
|
|
344 |
// Audio device accessor. |
// Audio device accessor. |
345 |
int qsamplerChannel::audioDevice (void) |
int qsamplerChannel::audioDevice (void) const |
346 |
{ |
{ |
347 |
return m_iAudioDevice; |
return m_iAudioDevice; |
348 |
} |
} |
349 |
|
|
350 |
bool qsamplerChannel::setAudioDevice ( int iAudioDevice ) |
bool qsamplerChannel::setAudioDevice ( int iAudioDevice ) |
351 |
{ |
{ |
352 |
if (client() == NULL || m_iChannelID < 0) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
353 |
return false; |
if (pMainForm == NULL) |
354 |
|
return false; |
355 |
|
if (pMainForm->client() == NULL || m_iChannelID < 0) |
356 |
|
return false; |
357 |
|
if (m_iInstrumentStatus == 100 && m_iAudioDevice == iAudioDevice) |
358 |
|
return true; |
359 |
|
|
360 |
|
if (::lscp_set_channel_audio_device(pMainForm->client(), m_iChannelID, iAudioDevice) != LSCP_OK) { |
361 |
|
appendMessagesClient("lscp_set_channel_audio_device"); |
362 |
|
return false; |
363 |
|
} |
364 |
|
|
365 |
if (::lscp_set_channel_audio_device(client(), m_iChannelID, iAudioDevice) != LSCP_OK) { |
appendMessages(QObject::tr("Audio device: %1.").arg(iAudioDevice)); |
|
appendMessagesClient("lscp_set_channel_audio_device"); |
|
|
return false; |
|
|
} |
|
366 |
|
|
367 |
m_iAudioDevice = iAudioDevice; |
m_iAudioDevice = iAudioDevice; |
368 |
return true; |
return true; |
369 |
} |
} |
370 |
|
|
371 |
|
|
372 |
// Audio driver type accessors (DEPRECATED). |
// Audio driver type accessors (DEPRECATED). |
373 |
QString& qsamplerChannel::audioDriver (void) |
const QString& qsamplerChannel::audioDriver (void) const |
374 |
{ |
{ |
375 |
return m_sAudioDriver; |
return m_sAudioDriver; |
376 |
} |
} |
377 |
|
|
378 |
bool qsamplerChannel::setAudioDriver ( const QString& sAudioDriver ) |
bool qsamplerChannel::setAudioDriver ( const QString& sAudioDriver ) |
379 |
{ |
{ |
380 |
if (client() == NULL || m_iChannelID < 0) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
381 |
return false; |
if (pMainForm == NULL) |
382 |
|
return false; |
383 |
|
if (pMainForm->client() == NULL || m_iChannelID < 0) |
384 |
|
return false; |
385 |
|
if (m_iInstrumentStatus == 100 && m_sAudioDriver == sAudioDriver) |
386 |
|
return true; |
387 |
|
|
388 |
|
if (::lscp_set_channel_audio_type(pMainForm->client(), m_iChannelID, sAudioDriver.latin1()) != LSCP_OK) { |
389 |
|
appendMessagesClient("lscp_set_channel_audio_type"); |
390 |
|
return false; |
391 |
|
} |
392 |
|
|
393 |
if (::lscp_set_channel_audio_type(client(), m_iChannelID, sAudioDriver.latin1()) != LSCP_OK) { |
appendMessages(QObject::tr("Audio driver: %1.").arg(sAudioDriver)); |
|
appendMessagesClient("lscp_set_channel_audio_type"); |
|
|
return false; |
|
|
} |
|
394 |
|
|
395 |
m_sAudioDriver = sAudioDriver; |
m_sAudioDriver = sAudioDriver; |
396 |
return true; |
return true; |
397 |
} |
} |
398 |
|
|
399 |
|
|
400 |
// Channel volume accessors. |
// Channel volume accessors. |
401 |
float qsamplerChannel::volume (void) |
float qsamplerChannel::volume (void) const |
402 |
{ |
{ |
403 |
return m_fVolume; |
return m_fVolume; |
404 |
} |
} |
405 |
|
|
406 |
bool qsamplerChannel::setVolume ( float fVolume ) |
bool qsamplerChannel::setVolume ( float fVolume ) |
407 |
{ |
{ |
408 |
if (client() == NULL || m_iChannelID < 0) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
409 |
return false; |
if (pMainForm == NULL) |
410 |
|
return false; |
411 |
|
if (pMainForm->client() == NULL || m_iChannelID < 0) |
412 |
|
return false; |
413 |
|
if (m_iInstrumentStatus == 100 && m_fVolume == fVolume) |
414 |
|
return true; |
415 |
|
|
416 |
|
if (::lscp_set_channel_volume(pMainForm->client(), m_iChannelID, fVolume) != LSCP_OK) { |
417 |
|
appendMessagesClient("lscp_set_channel_volume"); |
418 |
|
return false; |
419 |
|
} |
420 |
|
|
421 |
if (::lscp_set_channel_volume(client(), m_iChannelID, fVolume) != LSCP_OK) { |
appendMessages(QObject::tr("Volume: %1.").arg(fVolume)); |
|
appendMessagesClient("lscp_set_channel_volume"); |
|
|
return false; |
|
|
} |
|
422 |
|
|
423 |
m_fVolume = fVolume; |
m_fVolume = fVolume; |
424 |
return true; |
return true; |
425 |
|
} |
426 |
|
|
427 |
|
|
428 |
|
// Sampler channel mute state. |
429 |
|
bool qsamplerChannel::channelMute (void) const |
430 |
|
{ |
431 |
|
return m_bMute; |
432 |
|
} |
433 |
|
|
434 |
|
bool qsamplerChannel::setChannelMute ( bool bMute ) |
435 |
|
{ |
436 |
|
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
437 |
|
if (pMainForm == NULL) |
438 |
|
return false; |
439 |
|
if (pMainForm->client() == NULL || m_iChannelID < 0) |
440 |
|
return false; |
441 |
|
if (m_iInstrumentStatus == 100 && ((m_bMute && bMute) || (!m_bMute && !bMute))) |
442 |
|
return true; |
443 |
|
|
444 |
|
#ifdef CONFIG_MUTE_SOLO |
445 |
|
if (::lscp_set_channel_mute(pMainForm->client(), m_iChannelID, bMute) != LSCP_OK) { |
446 |
|
appendMessagesClient("lscp_set_channel_mute"); |
447 |
|
return false; |
448 |
|
} |
449 |
|
appendMessages(QObject::tr("Mute: %1.").arg((int) bMute)); |
450 |
|
m_bMute = bMute; |
451 |
|
return true; |
452 |
|
#else |
453 |
|
return false; |
454 |
|
#endif |
455 |
|
} |
456 |
|
|
457 |
|
|
458 |
|
// Sampler channel solo state. |
459 |
|
bool qsamplerChannel::channelSolo (void) const |
460 |
|
{ |
461 |
|
return m_bSolo; |
462 |
|
} |
463 |
|
|
464 |
|
bool qsamplerChannel::setChannelSolo ( bool bSolo ) |
465 |
|
{ |
466 |
|
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
467 |
|
if (pMainForm == NULL) |
468 |
|
return false; |
469 |
|
if (pMainForm->client() == NULL || m_iChannelID < 0) |
470 |
|
return false; |
471 |
|
if (m_iInstrumentStatus == 100 && ((m_bSolo && bSolo) || (!m_bSolo && !bSolo))) |
472 |
|
return true; |
473 |
|
|
474 |
|
#ifdef CONFIG_MUTE_SOLO |
475 |
|
if (::lscp_set_channel_solo(pMainForm->client(), m_iChannelID, bSolo) != LSCP_OK) { |
476 |
|
appendMessagesClient("lscp_set_channel_solo"); |
477 |
|
return false; |
478 |
|
} |
479 |
|
appendMessages(QObject::tr("Solo: %1.").arg((int) bSolo)); |
480 |
|
m_bSolo = bSolo; |
481 |
|
return true; |
482 |
|
#else |
483 |
|
return false; |
484 |
|
#endif |
485 |
|
} |
486 |
|
|
487 |
|
|
488 |
|
// Audio routing accessors. |
489 |
|
int qsamplerChannel::audioChannel ( int iAudioOut ) const |
490 |
|
{ |
491 |
|
return m_audioRouting[iAudioOut]; |
492 |
|
} |
493 |
|
|
494 |
|
bool qsamplerChannel::setAudioChannel ( int iAudioOut, int iAudioIn ) |
495 |
|
{ |
496 |
|
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
497 |
|
if (pMainForm == NULL) |
498 |
|
return false; |
499 |
|
if (pMainForm->client() == NULL || m_iChannelID < 0) |
500 |
|
return false; |
501 |
|
if (m_iInstrumentStatus == 100 && |
502 |
|
m_audioRouting[iAudioOut] == iAudioIn) |
503 |
|
return true; |
504 |
|
|
505 |
|
if (::lscp_set_channel_audio_channel(pMainForm->client(), |
506 |
|
m_iChannelID, iAudioOut, iAudioIn) != LSCP_OK) { |
507 |
|
appendMessagesClient("lscp_set_channel_audio_channel"); |
508 |
|
return false; |
509 |
|
} |
510 |
|
|
511 |
|
appendMessages(QObject::tr("Audio Channel: %1 -> %2.") |
512 |
|
.arg(iAudioOut).arg(iAudioIn)); |
513 |
|
|
514 |
|
m_audioRouting[iAudioOut] = iAudioIn; |
515 |
|
return true; |
516 |
|
} |
517 |
|
|
518 |
|
// The audio routing map itself. |
519 |
|
const qsamplerChannelRoutingMap& qsamplerChannel::audioRouting (void) const |
520 |
|
{ |
521 |
|
return m_audioRouting; |
522 |
} |
} |
523 |
|
|
524 |
|
|
535 |
// Update whole channel info state. |
// Update whole channel info state. |
536 |
bool qsamplerChannel::updateChannelInfo (void) |
bool qsamplerChannel::updateChannelInfo (void) |
537 |
{ |
{ |
538 |
if (client() == NULL || m_iChannelID < 0) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
539 |
return false; |
if (pMainForm == NULL) |
540 |
|
return false; |
541 |
// Read channel information. |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
542 |
lscp_channel_info_t *pChannelInfo = ::lscp_get_channel_info(client(), m_iChannelID); |
return false; |
543 |
if (pChannelInfo == NULL) { |
|
544 |
appendMessagesClient("lscp_get_channel_info"); |
// Read channel information. |
545 |
appendMessagesError(QObject::tr("Could not get channel information.\n\nSorry.")); |
lscp_channel_info_t *pChannelInfo = ::lscp_get_channel_info(pMainForm->client(), m_iChannelID); |
546 |
return false; |
if (pChannelInfo == NULL) { |
547 |
} |
appendMessagesClient("lscp_get_channel_info"); |
548 |
|
appendMessagesError(QObject::tr("Could not get channel information.\n\nSorry.")); |
549 |
|
return false; |
550 |
|
} |
551 |
|
|
552 |
#ifdef CONFIG_INSTRUMENT_NAME |
#ifdef CONFIG_INSTRUMENT_NAME |
553 |
// We got all actual instrument datum... |
// We got all actual instrument datum... |
565 |
updateInstrumentName(); |
updateInstrumentName(); |
566 |
} |
} |
567 |
#endif |
#endif |
568 |
// Cache in other channel information. |
// Cache in other channel information. |
569 |
m_sEngineName = pChannelInfo->engine_name; |
m_sEngineName = pChannelInfo->engine_name; |
570 |
m_iInstrumentStatus = pChannelInfo->instrument_status; |
m_iInstrumentStatus = pChannelInfo->instrument_status; |
571 |
m_iMidiDevice = pChannelInfo->midi_device; |
m_iMidiDevice = pChannelInfo->midi_device; |
572 |
m_iMidiPort = pChannelInfo->midi_port; |
m_iMidiPort = pChannelInfo->midi_port; |
573 |
m_iMidiChannel = pChannelInfo->midi_channel; |
m_iMidiChannel = pChannelInfo->midi_channel; |
574 |
m_iAudioDevice = pChannelInfo->audio_device; |
m_iAudioDevice = pChannelInfo->audio_device; |
575 |
m_fVolume = pChannelInfo->volume; |
m_fVolume = pChannelInfo->volume; |
576 |
// Some sanity checks. |
#ifdef CONFIG_MUTE_SOLO |
577 |
if (m_sEngineName == "NONE") |
m_bMute = pChannelInfo->mute; |
578 |
m_sEngineName = QString::null; |
m_bSolo = pChannelInfo->solo; |
579 |
if (m_sInstrumentFile == "NONE") { |
#endif |
580 |
m_sInstrumentFile = QString::null; |
// Some sanity checks. |
581 |
m_sInstrumentName = QString::null; |
if (m_sEngineName == "NONE" || m_sEngineName.isEmpty()) |
582 |
|
m_sEngineName = QString::null; |
583 |
|
if (m_sInstrumentFile == "NONE" || m_sInstrumentFile.isEmpty()) { |
584 |
|
m_sInstrumentFile = QString::null; |
585 |
|
m_sInstrumentName = QString::null; |
586 |
} |
} |
587 |
|
|
588 |
return true; |
// Time for device info grabbing... |
589 |
|
lscp_device_info_t *pDeviceInfo; |
590 |
|
const QString sNone = QObject::tr("(none)"); |
591 |
|
// Audio device driver type. |
592 |
|
pDeviceInfo = ::lscp_get_audio_device_info(pMainForm->client(), m_iAudioDevice); |
593 |
|
if (pDeviceInfo == NULL) { |
594 |
|
appendMessagesClient("lscp_get_audio_device_info"); |
595 |
|
m_sAudioDriver = sNone; |
596 |
|
} else { |
597 |
|
m_sAudioDriver = pDeviceInfo->driver; |
598 |
|
} |
599 |
|
// MIDI device driver type. |
600 |
|
pDeviceInfo = ::lscp_get_midi_device_info(pMainForm->client(), m_iMidiDevice); |
601 |
|
if (pDeviceInfo == NULL) { |
602 |
|
appendMessagesClient("lscp_get_midi_device_info"); |
603 |
|
m_sMidiDriver = sNone; |
604 |
|
} else { |
605 |
|
m_sMidiDriver = pDeviceInfo->driver; |
606 |
|
} |
607 |
|
|
608 |
|
// Set the audio routing map. |
609 |
|
m_audioRouting.clear(); |
610 |
|
char **ppszRouting = pChannelInfo->audio_routing; |
611 |
|
for (int i = 0; ppszRouting && ppszRouting[i]; i++) { |
612 |
|
m_audioRouting[i] = ::atoi(ppszRouting[i]); |
613 |
|
} |
614 |
|
|
615 |
|
return true; |
616 |
} |
} |
617 |
|
|
618 |
|
|
619 |
// Reset channel method. |
// Reset channel method. |
620 |
bool qsamplerChannel::resetChannel (void) |
bool qsamplerChannel::channelReset (void) |
621 |
{ |
{ |
622 |
if (client() == NULL || m_iChannelID < 0) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
623 |
return false; |
if (pMainForm == NULL) |
624 |
|
return false; |
625 |
|
if (pMainForm->client() == NULL || m_iChannelID < 0) |
626 |
|
return false; |
627 |
|
|
628 |
|
if (::lscp_reset_channel(pMainForm->client(), m_iChannelID) != LSCP_OK) { |
629 |
|
appendMessagesClient("lscp_reset_channel"); |
630 |
|
return false; |
631 |
|
} |
632 |
|
|
633 |
if (::lscp_reset_channel(client(), m_iChannelID) != LSCP_OK) { |
appendMessages(QObject::tr("reset.")); |
|
appendMessagesClient("lscp_reset_channel"); |
|
|
return false; |
|
|
} |
|
634 |
|
|
635 |
appendMessages(QObject::tr("Channel %1 reset.").arg(m_iChannelID)); |
return true; |
|
return true; |
|
636 |
} |
} |
637 |
|
|
638 |
|
|
639 |
// Channel setup dialog form. |
// Channel setup dialog form. |
640 |
bool qsamplerChannel::channelSetup ( QWidget *pParent ) |
bool qsamplerChannel::channelSetup ( QWidget *pParent ) |
641 |
{ |
{ |
642 |
bool bResult = false; |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
643 |
|
if (pMainForm == NULL) |
644 |
|
return false; |
645 |
|
|
646 |
qsamplerChannelForm *pChannelForm = new qsamplerChannelForm(pParent); |
bool bResult = false; |
647 |
if (pChannelForm) { |
|
648 |
pChannelForm->setup(this); |
appendMessages(QObject::tr("setup...")); |
|
bResult = pChannelForm->exec(); |
|
|
delete pChannelForm; |
|
|
} |
|
649 |
|
|
650 |
return bResult; |
qsamplerChannelForm *pChannelForm = new qsamplerChannelForm(pParent); |
651 |
|
if (pChannelForm) { |
652 |
|
pChannelForm->setup(this); |
653 |
|
bResult = pChannelForm->exec(); |
654 |
|
delete pChannelForm; |
655 |
|
} |
656 |
|
|
657 |
|
return bResult; |
658 |
} |
} |
659 |
|
|
660 |
|
|
661 |
// Redirected messages output methods. |
// Redirected messages output methods. |
662 |
void qsamplerChannel::appendMessages( const QString& s ) |
void qsamplerChannel::appendMessages( const QString& s ) const |
663 |
{ |
{ |
664 |
if (m_pMainForm) m_pMainForm->appendMessages(s); |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
665 |
|
if (pMainForm) |
666 |
|
pMainForm->appendMessages(channelName() + ' ' + s); |
667 |
} |
} |
668 |
|
|
669 |
void qsamplerChannel::appendMessagesColor( const QString& s, const QString& c ) |
void qsamplerChannel::appendMessagesColor( const QString& s, |
670 |
|
const QString& c ) const |
671 |
{ |
{ |
672 |
if (m_pMainForm) m_pMainForm->appendMessagesColor(s, c); |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
673 |
|
if (pMainForm) |
674 |
|
pMainForm->appendMessagesColor(channelName() + ' ' + s, c); |
675 |
} |
} |
676 |
|
|
677 |
void qsamplerChannel::appendMessagesText( const QString& s ) |
void qsamplerChannel::appendMessagesText( const QString& s ) const |
678 |
{ |
{ |
679 |
if (m_pMainForm) m_pMainForm->appendMessagesText(s); |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
680 |
|
if (pMainForm) |
681 |
|
pMainForm->appendMessagesText(channelName() + ' ' + s); |
682 |
} |
} |
683 |
|
|
684 |
void qsamplerChannel::appendMessagesError( const QString& s ) |
void qsamplerChannel::appendMessagesError( const QString& s ) const |
685 |
{ |
{ |
686 |
if (m_pMainForm) m_pMainForm->appendMessagesError(s); |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
687 |
|
if (pMainForm) |
688 |
|
pMainForm->appendMessagesError(channelName() + "\n\n" + s); |
689 |
} |
} |
690 |
|
|
691 |
void qsamplerChannel::appendMessagesClient( const QString& s ) |
void qsamplerChannel::appendMessagesClient( const QString& s ) const |
692 |
{ |
{ |
693 |
if (m_pMainForm) m_pMainForm->appendMessagesClient(s); |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
694 |
|
if (pMainForm) |
695 |
|
pMainForm->appendMessagesClient(channelName() + ' ' + s); |
696 |
} |
} |
697 |
|
|
698 |
|
|
699 |
// Context menu event handler. |
// Context menu event handler. |
700 |
void qsamplerChannel::contextMenuEvent( QContextMenuEvent *pEvent ) |
void qsamplerChannel::contextMenuEvent( QContextMenuEvent *pEvent ) |
701 |
{ |
{ |
702 |
if (m_pMainForm) m_pMainForm->contextMenuEvent(pEvent); |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
703 |
|
if (pMainForm) |
704 |
|
pMainForm->contextMenuEvent(pEvent); |
705 |
} |
} |
706 |
|
|
707 |
|
|
712 |
|
|
713 |
QFile file(sInstrumentFile); |
QFile file(sInstrumentFile); |
714 |
if (file.open(IO_ReadOnly)) { |
if (file.open(IO_ReadOnly)) { |
715 |
char achHeader[4]; |
char achHeader[16]; |
716 |
if (file.readBlock(achHeader, 4)) { |
if (file.readBlock(achHeader, 16)) { |
717 |
bResult = (achHeader[0] == 'R' |
bResult = (::memcmp(&achHeader[0], "RIFF", 4) == 0 |
718 |
&& achHeader[1] == 'I' |
&& ::memcmp(&achHeader[8], "DLS LIST", 8) == 0); |
|
&& achHeader[2] == 'F' |
|
|
&& achHeader[3] == 'F'); |
|
719 |
} |
} |
720 |
file.close(); |
file.close(); |
721 |
} |
} |
728 |
QStringList qsamplerChannel::getInstrumentList( const QString& sInstrumentFile, |
QStringList qsamplerChannel::getInstrumentList( const QString& sInstrumentFile, |
729 |
bool bInstrumentNames ) |
bool bInstrumentNames ) |
730 |
{ |
{ |
731 |
QString sInstrumentName = QFileInfo(sInstrumentFile).fileName(); |
QString sInstrumentName = QFileInfo(sInstrumentFile).fileName(); |
732 |
QStringList instlist; |
QStringList instlist; |
733 |
|
|
734 |
if (isInstrumentFile(sInstrumentFile)) { |
if (isInstrumentFile(sInstrumentFile)) { |
735 |
#ifdef CONFIG_LIBGIG |
#ifdef CONFIG_LIBGIG |
736 |
if (bInstrumentNames) { |
if (bInstrumentNames) { |
737 |
RIFF::File *pRiff = new RIFF::File(sInstrumentFile); |
RIFF::File *pRiff = new RIFF::File(sInstrumentFile.latin1()); |
738 |
gig::File *pGig = new gig::File(pRiff); |
gig::File *pGig = new gig::File(pRiff); |
739 |
gig::Instrument *pInstrument = pGig->GetFirstInstrument(); |
gig::Instrument *pInstrument = pGig->GetFirstInstrument(); |
740 |
while (pInstrument) { |
while (pInstrument) { |
741 |
instlist.append((pInstrument->pInfo)->Name.c_str()); |
instlist.append((pInstrument->pInfo)->Name.c_str()); |
742 |
pInstrument = pGig->GetNextInstrument(); |
pInstrument = pGig->GetNextInstrument(); |
743 |
} |
} |
744 |
delete pGig; |
delete pGig; |
745 |
delete pRiff; |
delete pRiff; |
746 |
} |
} |
747 |
else |
else |
748 |
#endif |
#endif |
749 |
for (int iInstrumentNr = 0; iInstrumentNr < QSAMPLER_INSTRUMENT_MAX; iInstrumentNr++) |
for (int iInstrumentNr = 0; iInstrumentNr < QSAMPLER_INSTRUMENT_MAX; iInstrumentNr++) |
750 |
instlist.append(sInstrumentName + " [" + QString::number(iInstrumentNr) + "]"); |
instlist.append(sInstrumentName + " [" + QString::number(iInstrumentNr) + "]"); |
751 |
} |
} |
752 |
else instlist.append(noInstrumentName()); |
else instlist.append(noInstrumentName()); |
753 |
|
|
754 |
return instlist; |
return instlist; |
755 |
} |
} |
756 |
|
|
757 |
|
|
759 |
QString qsamplerChannel::getInstrumentName( const QString& sInstrumentFile, |
QString qsamplerChannel::getInstrumentName( const QString& sInstrumentFile, |
760 |
int iInstrumentNr, bool bInstrumentNames ) |
int iInstrumentNr, bool bInstrumentNames ) |
761 |
{ |
{ |
762 |
QString sInstrumentName; |
QString sInstrumentName; |
763 |
|
|
764 |
if (isInstrumentFile(sInstrumentFile)) { |
if (isInstrumentFile(sInstrumentFile)) { |
765 |
sInstrumentName = QFileInfo(sInstrumentFile).fileName(); |
sInstrumentName = QFileInfo(sInstrumentFile).fileName(); |
766 |
#ifdef CONFIG_LIBGIG |
#ifdef CONFIG_LIBGIG |
767 |
if (bInstrumentNames) { |
if (bInstrumentNames) { |
768 |
RIFF::File *pRiff = new RIFF::File(sInstrumentFile); |
RIFF::File *pRiff = new RIFF::File(sInstrumentFile.latin1()); |
769 |
gig::File *pGig = new gig::File(pRiff); |
gig::File *pGig = new gig::File(pRiff); |
770 |
int iIndex = 0; |
int iIndex = 0; |
771 |
gig::Instrument *pInstrument = pGig->GetFirstInstrument(); |
gig::Instrument *pInstrument = pGig->GetFirstInstrument(); |
772 |
while (pInstrument) { |
while (pInstrument) { |
773 |
if (iIndex == iInstrumentNr) { |
if (iIndex == iInstrumentNr) { |
774 |
sInstrumentName = (pInstrument->pInfo)->Name.c_str(); |
sInstrumentName = (pInstrument->pInfo)->Name.c_str(); |
775 |
break; |
break; |
776 |
} |
} |
777 |
iIndex++; |
iIndex++; |
778 |
pInstrument = pGig->GetNextInstrument(); |
pInstrument = pGig->GetNextInstrument(); |
779 |
} |
} |
780 |
delete pGig; |
delete pGig; |
781 |
delete pRiff; |
delete pRiff; |
782 |
} |
} |
783 |
else |
else |
784 |
#endif |
#endif |
785 |
sInstrumentName += " [" + QString::number(iInstrumentNr) + "]"; |
sInstrumentName += " [" + QString::number(iInstrumentNr) + "]"; |
786 |
} |
} |
787 |
else sInstrumentName = noInstrumentName(); |
else sInstrumentName = noInstrumentName(); |
788 |
|
|
789 |
return sInstrumentName; |
return sInstrumentName; |
790 |
} |
} |
791 |
|
|
792 |
|
|
801 |
return QObject::tr("(No instrument)"); |
return QObject::tr("(No instrument)"); |
802 |
} |
} |
803 |
|
|
804 |
|
QString qsamplerChannel::loadingInstrument (void) { |
805 |
|
return QObject::tr("(Loading instrument...)"); |
806 |
|
} |
807 |
|
|
808 |
|
|
809 |
|
|
810 |
|
//------------------------------------------------------------------------- |
811 |
|
// qsamplerChannelRoutingTable - Channel routing table. |
812 |
|
// |
813 |
|
|
814 |
|
// Constructor. |
815 |
|
qsamplerChannelRoutingTable::qsamplerChannelRoutingTable ( |
816 |
|
QWidget *pParent, const char *pszName ) |
817 |
|
: QTable(pParent, pszName) |
818 |
|
{ |
819 |
|
// Set fixed number of columns. |
820 |
|
QTable::setNumCols(2); |
821 |
|
QTable::setShowGrid(false); |
822 |
|
QTable::setSorting(false); |
823 |
|
QTable::setFocusStyle(QTable::FollowStyle); |
824 |
|
QTable::setSelectionMode(QTable::NoSelection); |
825 |
|
// No vertical header. |
826 |
|
QTable::verticalHeader()->hide(); |
827 |
|
QTable::setLeftMargin(0); |
828 |
|
// Initialize the fixed table column headings. |
829 |
|
QHeader *pHeader = QTable::horizontalHeader(); |
830 |
|
pHeader->setLabel(0, tr("Sampler Channel")); |
831 |
|
pHeader->setLabel(1, tr("Device Channel")); |
832 |
|
// Set read-onlyness of each column |
833 |
|
QTable::setColumnReadOnly(0, true); |
834 |
|
// QTable::setColumnReadOnly(1, false); -- of course not. |
835 |
|
QTable::setColumnStretchable(1, true); |
836 |
|
} |
837 |
|
|
838 |
|
// Default destructor. |
839 |
|
qsamplerChannelRoutingTable::~qsamplerChannelRoutingTable (void) |
840 |
|
{ |
841 |
|
} |
842 |
|
|
843 |
|
|
844 |
|
// Routing map table renderer. |
845 |
|
void qsamplerChannelRoutingTable::refresh ( qsamplerDevice *pDevice, |
846 |
|
const qsamplerChannelRoutingMap& routing ) |
847 |
|
{ |
848 |
|
if (pDevice == NULL) |
849 |
|
return; |
850 |
|
|
851 |
|
// Always (re)start it empty. |
852 |
|
QTable::setUpdatesEnabled(false); |
853 |
|
QTable::setNumRows(0); |
854 |
|
|
855 |
|
// The common device port item list. |
856 |
|
QStringList opts; |
857 |
|
qsamplerDevicePortList& ports = pDevice->ports(); |
858 |
|
qsamplerDevicePort *pPort; |
859 |
|
for (pPort = ports.first(); pPort; pPort = ports.next()) { |
860 |
|
opts.append(pDevice->deviceTypeName() |
861 |
|
+ ' ' + pDevice->driverName() |
862 |
|
+ ' ' + pPort->portName()); |
863 |
|
} |
864 |
|
|
865 |
|
// Those items shall have a proper pixmap... |
866 |
|
QPixmap pmChannel = QPixmap::fromMimeSource("qsamplerChannel.png"); |
867 |
|
QPixmap pmDevice; |
868 |
|
switch (pDevice->deviceType()) { |
869 |
|
case qsamplerDevice::Audio: |
870 |
|
pmDevice = QPixmap::fromMimeSource("audio2.png"); |
871 |
|
break; |
872 |
|
case qsamplerDevice::Midi: |
873 |
|
pmDevice = QPixmap::fromMimeSource("midi2.png"); |
874 |
|
break; |
875 |
|
case qsamplerDevice::None: |
876 |
|
break; |
877 |
|
} |
878 |
|
|
879 |
|
// Fill the routing table... |
880 |
|
QTable::insertRows(0, routing.count()); |
881 |
|
int iRow = 0; |
882 |
|
qsamplerChannelRoutingMap::ConstIterator iter; |
883 |
|
for (iter = routing.begin(); iter != routing.end(); ++iter) { |
884 |
|
QTable::setPixmap(iRow, 0, pmChannel); |
885 |
|
QTable::setText(iRow, 0, pDevice->deviceTypeName() |
886 |
|
+ ' ' + QString::number(iter.key())); |
887 |
|
qsamplerChannelRoutingComboBox *pComboItem = |
888 |
|
new qsamplerChannelRoutingComboBox(this, opts, pmDevice); |
889 |
|
pComboItem->setCurrentItem(iter.data()); |
890 |
|
QTable::setItem(iRow, 1, pComboItem); |
891 |
|
++iRow; |
892 |
|
} |
893 |
|
|
894 |
|
// Adjust optimal column widths. |
895 |
|
QTable::adjustColumn(0); |
896 |
|
QTable::adjustColumn(1); |
897 |
|
|
898 |
|
QTable::setUpdatesEnabled(true); |
899 |
|
QTable::updateContents(); |
900 |
|
} |
901 |
|
|
902 |
|
|
903 |
|
// Commit any pending editing. |
904 |
|
void qsamplerChannelRoutingTable::flush (void) |
905 |
|
{ |
906 |
|
if (QTable::isEditing()) |
907 |
|
QTable::endEdit(QTable::currEditRow(), QTable::currEditCol(), true, true); |
908 |
|
} |
909 |
|
|
910 |
|
|
911 |
|
//------------------------------------------------------------------------- |
912 |
|
// qsamplerChannelRoutingComboBox - Custom combo box for routing table. |
913 |
|
// |
914 |
|
|
915 |
|
// Constructor. |
916 |
|
qsamplerChannelRoutingComboBox::qsamplerChannelRoutingComboBox ( |
917 |
|
QTable *pTable, const QStringList& list, const QPixmap& pixmap ) |
918 |
|
: QTableItem(pTable, QTableItem::WhenCurrent, QString::null, pixmap), |
919 |
|
m_list(list) |
920 |
|
{ |
921 |
|
m_iCurrentItem = 0; |
922 |
|
} |
923 |
|
|
924 |
|
// Public accessors. |
925 |
|
void qsamplerChannelRoutingComboBox::setCurrentItem ( int iCurrentItem ) |
926 |
|
{ |
927 |
|
m_iCurrentItem = iCurrentItem; |
928 |
|
|
929 |
|
QTableItem::setText(m_list[iCurrentItem]); |
930 |
|
} |
931 |
|
|
932 |
|
int qsamplerChannelRoutingComboBox::currentItem (void) const |
933 |
|
{ |
934 |
|
return m_iCurrentItem; |
935 |
|
} |
936 |
|
|
937 |
|
// Virtual implemetations. |
938 |
|
QWidget *qsamplerChannelRoutingComboBox::createEditor (void) const |
939 |
|
{ |
940 |
|
QComboBox *pComboBox = new QComboBox(QTableItem::table()->viewport()); |
941 |
|
QObject::connect(pComboBox, SIGNAL(activated(int)), |
942 |
|
QTableItem::table(), SLOT(doValueChanged())); |
943 |
|
for (QStringList::ConstIterator iter = m_list.begin(); |
944 |
|
iter != m_list.end(); iter++) { |
945 |
|
pComboBox->insertItem(QTableItem::pixmap(), *iter); |
946 |
|
} |
947 |
|
pComboBox->setCurrentItem(m_iCurrentItem); |
948 |
|
return pComboBox; |
949 |
|
} |
950 |
|
|
951 |
|
void qsamplerChannelRoutingComboBox::setContentFromEditor ( QWidget *pWidget ) |
952 |
|
{ |
953 |
|
if (pWidget->inherits("QComboBox")) { |
954 |
|
QComboBox *pComboBox = (QComboBox *) pWidget; |
955 |
|
m_iCurrentItem = pComboBox->currentItem(); |
956 |
|
QTableItem::setText(pComboBox->currentText()); |
957 |
|
} |
958 |
|
else QTableItem::setContentFromEditor(pWidget); |
959 |
|
} |
960 |
|
|
961 |
|
|
962 |
// end of qsamplerChannel.cpp |
// end of qsamplerChannel.cpp |