1 |
// qsamplerChannel.cpp |
// qsamplerChannel.cpp |
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 |
|
|
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 "qsamplerUtilities.h" |
23 |
#include "qsamplerAbout.h" |
#include "qsamplerAbout.h" |
24 |
#include "qsamplerChannel.h" |
#include "qsamplerChannel.h" |
25 |
|
|
41 |
// |
// |
42 |
|
|
43 |
// Constructor. |
// Constructor. |
44 |
qsamplerChannel::qsamplerChannel ( qsamplerMainForm *pMainForm, int iChannelID ) |
qsamplerChannel::qsamplerChannel ( int iChannelID ) |
45 |
{ |
{ |
|
m_pMainForm = pMainForm; |
|
46 |
m_iChannelID = iChannelID; |
m_iChannelID = iChannelID; |
47 |
|
|
48 |
// m_sEngineName = noEngineName(); |
// m_sEngineName = noEngineName(); |
54 |
m_iMidiDevice = -1; |
m_iMidiDevice = -1; |
55 |
m_iMidiPort = -1; |
m_iMidiPort = -1; |
56 |
m_iMidiChannel = -1; |
m_iMidiChannel = -1; |
57 |
|
m_iMidiMap = -1; |
58 |
m_sAudioDriver = "ALSA"; |
m_sAudioDriver = "ALSA"; |
59 |
m_iAudioDevice = -1; |
m_iAudioDevice = -1; |
60 |
m_fVolume = 0.0; |
m_fVolume = 0.0; |
68 |
} |
} |
69 |
|
|
70 |
|
|
|
// Main application form accessor. |
|
|
qsamplerMainForm *qsamplerChannel::mainForm(void) const |
|
|
{ |
|
|
return m_pMainForm; |
|
|
} |
|
|
|
|
|
|
|
|
// The global options settings delegated property. |
|
|
qsamplerOptions *qsamplerChannel::options (void) const |
|
|
{ |
|
|
if (m_pMainForm == NULL) |
|
|
return NULL; |
|
|
|
|
|
return m_pMainForm->options(); |
|
|
} |
|
|
|
|
|
|
|
|
// The client descriptor delegated property. |
|
|
lscp_client_t *qsamplerChannel::client (void) const |
|
|
{ |
|
|
if (m_pMainForm == NULL) |
|
|
return NULL; |
|
|
|
|
|
return m_pMainForm->client(); |
|
|
} |
|
|
|
|
|
|
|
71 |
// Create a new sampler channel, if not already. |
// Create a new sampler channel, if not already. |
72 |
bool qsamplerChannel::addChannel (void) |
bool qsamplerChannel::addChannel (void) |
73 |
{ |
{ |
74 |
if (client() == NULL) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
75 |
|
if (pMainForm == NULL) |
76 |
|
return false; |
77 |
|
if (pMainForm->client() == NULL) |
78 |
return false; |
return false; |
79 |
|
|
80 |
// Are we a new channel? |
// Are we a new channel? |
81 |
if (m_iChannelID < 0) { |
if (m_iChannelID < 0) { |
82 |
m_iChannelID = ::lscp_add_channel(client()); |
m_iChannelID = ::lscp_add_channel(pMainForm->client()); |
83 |
if (m_iChannelID < 0) { |
if (m_iChannelID < 0) { |
84 |
appendMessagesClient("lscp_add_channel"); |
appendMessagesClient("lscp_add_channel"); |
85 |
appendMessagesError(QObject::tr("Could not add channel.\n\nSorry.")); |
appendMessagesError( |
86 |
|
QObject::tr("Could not add channel.\n\nSorry.")); |
87 |
} // Otherwise it's created... |
} // Otherwise it's created... |
88 |
else appendMessages(QObject::tr("added.")); |
else appendMessages(QObject::tr("added.")); |
89 |
} |
} |
96 |
// Remove sampler channel. |
// Remove sampler channel. |
97 |
bool qsamplerChannel::removeChannel (void) |
bool qsamplerChannel::removeChannel (void) |
98 |
{ |
{ |
99 |
if (client() == NULL) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
100 |
|
if (pMainForm == NULL) |
101 |
|
return false; |
102 |
|
if (pMainForm->client() == NULL) |
103 |
return false; |
return false; |
104 |
|
|
105 |
// Are we an existing channel? |
// Are we an existing channel? |
106 |
if (m_iChannelID >= 0) { |
if (m_iChannelID >= 0) { |
107 |
if (::lscp_remove_channel(client(), m_iChannelID) != LSCP_OK) { |
if (::lscp_remove_channel(pMainForm->client(), m_iChannelID) != LSCP_OK) { |
108 |
appendMessagesClient("lscp_remove_channel"); |
appendMessagesClient("lscp_remove_channel"); |
109 |
appendMessagesError(QObject::tr("Could not remove channel.\n\nSorry.")); |
appendMessagesError(QObject::tr("Could not remove channel.\n\nSorry.")); |
110 |
} else { |
} else { |
146 |
|
|
147 |
bool qsamplerChannel::loadEngine ( const QString& sEngineName ) |
bool qsamplerChannel::loadEngine ( const QString& sEngineName ) |
148 |
{ |
{ |
149 |
if (client() == NULL || m_iChannelID < 0) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
150 |
|
if (pMainForm == NULL) |
151 |
|
return false; |
152 |
|
if (pMainForm->client() == NULL || m_iChannelID < 0) |
153 |
return false; |
return false; |
154 |
if (m_iInstrumentStatus == 100 && m_sEngineName == sEngineName) |
if (m_iInstrumentStatus == 100 && m_sEngineName == sEngineName) |
155 |
return true; |
return true; |
156 |
|
|
157 |
if (::lscp_load_engine(client(), sEngineName.latin1(), m_iChannelID) != LSCP_OK) { |
if (::lscp_load_engine(pMainForm->client(), sEngineName.latin1(), m_iChannelID) != LSCP_OK) { |
158 |
appendMessagesClient("lscp_load_engine"); |
appendMessagesClient("lscp_load_engine"); |
159 |
return false; |
return false; |
160 |
} |
} |
161 |
|
|
162 |
appendMessages(QObject::tr("Engine: %1.").arg(sEngineName)); |
appendMessages(QObject::tr("Engine: %1.").arg(sEngineName)); |
163 |
|
|
164 |
m_sEngineName = sEngineName; |
m_sEngineName = sEngineName; |
193 |
// Instrument file loader. |
// Instrument file loader. |
194 |
bool qsamplerChannel::loadInstrument ( const QString& sInstrumentFile, int iInstrumentNr ) |
bool qsamplerChannel::loadInstrument ( const QString& sInstrumentFile, int iInstrumentNr ) |
195 |
{ |
{ |
196 |
if (client() == NULL || m_iChannelID < 0) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
197 |
|
if (pMainForm == NULL) |
198 |
|
return false; |
199 |
|
if (pMainForm->client() == NULL || m_iChannelID < 0) |
200 |
return false; |
return false; |
201 |
if (!isInstrumentFile(sInstrumentFile)) |
if (!isInstrumentFile(sInstrumentFile)) |
202 |
return false; |
return false; |
203 |
if (m_iInstrumentStatus == 100 && m_sInstrumentFile == sInstrumentFile && m_iInstrumentNr == iInstrumentNr) |
if (m_iInstrumentStatus == 100 && m_sInstrumentFile == sInstrumentFile && m_iInstrumentNr == iInstrumentNr) |
204 |
return true; |
return true; |
205 |
|
|
206 |
if (::lscp_load_instrument_non_modal(client(), sInstrumentFile.latin1(), iInstrumentNr, m_iChannelID) != LSCP_OK) { |
if ( |
207 |
|
::lscp_load_instrument_non_modal( |
208 |
|
pMainForm->client(), |
209 |
|
lscpEscapePath(sInstrumentFile).latin1(), |
210 |
|
iInstrumentNr, m_iChannelID |
211 |
|
) != LSCP_OK |
212 |
|
) { |
213 |
appendMessagesClient("lscp_load_instrument"); |
appendMessagesClient("lscp_load_instrument"); |
214 |
return false; |
return false; |
215 |
} |
} |
245 |
|
|
246 |
bool qsamplerChannel::setMidiDriver ( const QString& sMidiDriver ) |
bool qsamplerChannel::setMidiDriver ( const QString& sMidiDriver ) |
247 |
{ |
{ |
248 |
if (client() == NULL || m_iChannelID < 0) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
249 |
|
if (pMainForm == NULL) |
250 |
|
return false; |
251 |
|
if (pMainForm->client() == NULL || m_iChannelID < 0) |
252 |
return false; |
return false; |
253 |
if (m_iInstrumentStatus == 100 && m_sMidiDriver == sMidiDriver) |
if (m_iInstrumentStatus == 100 && m_sMidiDriver == sMidiDriver) |
254 |
return true; |
return true; |
255 |
|
|
256 |
if (::lscp_set_channel_midi_type(client(), m_iChannelID, sMidiDriver.latin1()) != LSCP_OK) { |
if (::lscp_set_channel_midi_type(pMainForm->client(), m_iChannelID, sMidiDriver.latin1()) != LSCP_OK) { |
257 |
appendMessagesClient("lscp_set_channel_midi_type"); |
appendMessagesClient("lscp_set_channel_midi_type"); |
258 |
return false; |
return false; |
259 |
} |
} |
273 |
|
|
274 |
bool qsamplerChannel::setMidiDevice ( int iMidiDevice ) |
bool qsamplerChannel::setMidiDevice ( int iMidiDevice ) |
275 |
{ |
{ |
276 |
if (client() == NULL || m_iChannelID < 0) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
277 |
|
if (pMainForm == NULL) |
278 |
|
return false; |
279 |
|
if (pMainForm->client() == NULL || m_iChannelID < 0) |
280 |
return false; |
return false; |
281 |
if (m_iInstrumentStatus == 100 && m_iMidiDevice == iMidiDevice) |
if (m_iInstrumentStatus == 100 && m_iMidiDevice == iMidiDevice) |
282 |
return true; |
return true; |
283 |
|
|
284 |
if (::lscp_set_channel_midi_device(client(), m_iChannelID, iMidiDevice) != LSCP_OK) { |
if (::lscp_set_channel_midi_device(pMainForm->client(), m_iChannelID, iMidiDevice) != LSCP_OK) { |
285 |
appendMessagesClient("lscp_set_channel_midi_device"); |
appendMessagesClient("lscp_set_channel_midi_device"); |
286 |
return false; |
return false; |
287 |
} |
} |
301 |
|
|
302 |
bool qsamplerChannel::setMidiPort ( int iMidiPort ) |
bool qsamplerChannel::setMidiPort ( int iMidiPort ) |
303 |
{ |
{ |
304 |
if (client() == NULL || m_iChannelID < 0) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
305 |
|
if (pMainForm == NULL) |
306 |
|
return false; |
307 |
|
if (pMainForm->client() == NULL || m_iChannelID < 0) |
308 |
return false; |
return false; |
309 |
if (m_iInstrumentStatus == 100 && m_iMidiPort == iMidiPort) |
if (m_iInstrumentStatus == 100 && m_iMidiPort == iMidiPort) |
310 |
return true; |
return true; |
311 |
|
|
312 |
if (::lscp_set_channel_midi_port(client(), m_iChannelID, iMidiPort) != LSCP_OK) { |
if (::lscp_set_channel_midi_port(pMainForm->client(), m_iChannelID, iMidiPort) != LSCP_OK) { |
313 |
appendMessagesClient("lscp_set_channel_midi_port"); |
appendMessagesClient("lscp_set_channel_midi_port"); |
314 |
return false; |
return false; |
315 |
} |
} |
329 |
|
|
330 |
bool qsamplerChannel::setMidiChannel ( int iMidiChannel ) |
bool qsamplerChannel::setMidiChannel ( int iMidiChannel ) |
331 |
{ |
{ |
332 |
if (client() == NULL || m_iChannelID < 0) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
333 |
|
if (pMainForm == NULL) |
334 |
|
return false; |
335 |
|
if (pMainForm->client() == NULL || m_iChannelID < 0) |
336 |
return false; |
return false; |
337 |
if (m_iInstrumentStatus == 100 && m_iMidiChannel == iMidiChannel) |
if (m_iInstrumentStatus == 100 && m_iMidiChannel == iMidiChannel) |
338 |
return true; |
return true; |
339 |
|
|
340 |
if (::lscp_set_channel_midi_channel(client(), m_iChannelID, iMidiChannel) != LSCP_OK) { |
if (::lscp_set_channel_midi_channel(pMainForm->client(), m_iChannelID, iMidiChannel) != LSCP_OK) { |
341 |
appendMessagesClient("lscp_set_channel_midi_channel"); |
appendMessagesClient("lscp_set_channel_midi_channel"); |
342 |
return false; |
return false; |
343 |
} |
} |
349 |
} |
} |
350 |
|
|
351 |
|
|
352 |
|
// MIDI instrument map accessor. |
353 |
|
int qsamplerChannel::midiMap (void) const |
354 |
|
{ |
355 |
|
return m_iMidiMap; |
356 |
|
} |
357 |
|
|
358 |
|
bool qsamplerChannel::setMidiMap ( int iMidiMap ) |
359 |
|
{ |
360 |
|
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
361 |
|
if (pMainForm == NULL) |
362 |
|
return false; |
363 |
|
if (pMainForm->client() == NULL || m_iChannelID < 0) |
364 |
|
return false; |
365 |
|
if (m_iInstrumentStatus == 100 && m_iMidiMap == iMidiMap) |
366 |
|
return true; |
367 |
|
#ifdef CONFIG_MIDI_INSTRUMENT |
368 |
|
if (::lscp_set_channel_midi_map(pMainForm->client(), m_iChannelID, iMidiMap) != LSCP_OK) { |
369 |
|
appendMessagesClient("lscp_set_channel_midi_map"); |
370 |
|
return false; |
371 |
|
} |
372 |
|
#endif |
373 |
|
appendMessages(QObject::tr("MIDI map: %1.").arg(iMidiMap)); |
374 |
|
|
375 |
|
m_iMidiMap = iMidiMap; |
376 |
|
return true; |
377 |
|
} |
378 |
|
|
379 |
|
|
380 |
// Audio device accessor. |
// Audio device accessor. |
381 |
int qsamplerChannel::audioDevice (void) const |
int qsamplerChannel::audioDevice (void) const |
382 |
{ |
{ |
385 |
|
|
386 |
bool qsamplerChannel::setAudioDevice ( int iAudioDevice ) |
bool qsamplerChannel::setAudioDevice ( int iAudioDevice ) |
387 |
{ |
{ |
388 |
if (client() == NULL || m_iChannelID < 0) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
389 |
|
if (pMainForm == NULL) |
390 |
|
return false; |
391 |
|
if (pMainForm->client() == NULL || m_iChannelID < 0) |
392 |
return false; |
return false; |
393 |
if (m_iInstrumentStatus == 100 && m_iAudioDevice == iAudioDevice) |
if (m_iInstrumentStatus == 100 && m_iAudioDevice == iAudioDevice) |
394 |
return true; |
return true; |
395 |
|
|
396 |
if (::lscp_set_channel_audio_device(client(), m_iChannelID, iAudioDevice) != LSCP_OK) { |
if (::lscp_set_channel_audio_device(pMainForm->client(), m_iChannelID, iAudioDevice) != LSCP_OK) { |
397 |
appendMessagesClient("lscp_set_channel_audio_device"); |
appendMessagesClient("lscp_set_channel_audio_device"); |
398 |
return false; |
return false; |
399 |
} |
} |
413 |
|
|
414 |
bool qsamplerChannel::setAudioDriver ( const QString& sAudioDriver ) |
bool qsamplerChannel::setAudioDriver ( const QString& sAudioDriver ) |
415 |
{ |
{ |
416 |
if (client() == NULL || m_iChannelID < 0) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
417 |
|
if (pMainForm == NULL) |
418 |
|
return false; |
419 |
|
if (pMainForm->client() == NULL || m_iChannelID < 0) |
420 |
return false; |
return false; |
421 |
if (m_iInstrumentStatus == 100 && m_sAudioDriver == sAudioDriver) |
if (m_iInstrumentStatus == 100 && m_sAudioDriver == sAudioDriver) |
422 |
return true; |
return true; |
423 |
|
|
424 |
if (::lscp_set_channel_audio_type(client(), m_iChannelID, sAudioDriver.latin1()) != LSCP_OK) { |
if (::lscp_set_channel_audio_type(pMainForm->client(), m_iChannelID, sAudioDriver.latin1()) != LSCP_OK) { |
425 |
appendMessagesClient("lscp_set_channel_audio_type"); |
appendMessagesClient("lscp_set_channel_audio_type"); |
426 |
return false; |
return false; |
427 |
} |
} |
441 |
|
|
442 |
bool qsamplerChannel::setVolume ( float fVolume ) |
bool qsamplerChannel::setVolume ( float fVolume ) |
443 |
{ |
{ |
444 |
if (client() == NULL || m_iChannelID < 0) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
445 |
|
if (pMainForm == NULL) |
446 |
|
return false; |
447 |
|
if (pMainForm->client() == NULL || m_iChannelID < 0) |
448 |
return false; |
return false; |
449 |
if (m_iInstrumentStatus == 100 && m_fVolume == fVolume) |
if (m_iInstrumentStatus == 100 && m_fVolume == fVolume) |
450 |
return true; |
return true; |
451 |
|
|
452 |
if (::lscp_set_channel_volume(client(), m_iChannelID, fVolume) != LSCP_OK) { |
if (::lscp_set_channel_volume(pMainForm->client(), m_iChannelID, fVolume) != LSCP_OK) { |
453 |
appendMessagesClient("lscp_set_channel_volume"); |
appendMessagesClient("lscp_set_channel_volume"); |
454 |
return false; |
return false; |
455 |
} |
} |
469 |
|
|
470 |
bool qsamplerChannel::setChannelMute ( bool bMute ) |
bool qsamplerChannel::setChannelMute ( bool bMute ) |
471 |
{ |
{ |
472 |
if (client() == NULL || m_iChannelID < 0) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
473 |
|
if (pMainForm == NULL) |
474 |
|
return false; |
475 |
|
if (pMainForm->client() == NULL || m_iChannelID < 0) |
476 |
return false; |
return false; |
477 |
if (m_iInstrumentStatus == 100 && ((m_bMute && bMute) || (!m_bMute && !bMute))) |
if (m_iInstrumentStatus == 100 && ((m_bMute && bMute) || (!m_bMute && !bMute))) |
478 |
return true; |
return true; |
479 |
|
|
480 |
#ifdef CONFIG_MUTE_SOLO |
#ifdef CONFIG_MUTE_SOLO |
481 |
if (::lscp_set_channel_mute(client(), m_iChannelID, bMute) != LSCP_OK) { |
if (::lscp_set_channel_mute(pMainForm->client(), m_iChannelID, bMute) != LSCP_OK) { |
482 |
appendMessagesClient("lscp_set_channel_mute"); |
appendMessagesClient("lscp_set_channel_mute"); |
483 |
return false; |
return false; |
484 |
} |
} |
499 |
|
|
500 |
bool qsamplerChannel::setChannelSolo ( bool bSolo ) |
bool qsamplerChannel::setChannelSolo ( bool bSolo ) |
501 |
{ |
{ |
502 |
if (client() == NULL || m_iChannelID < 0) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
503 |
|
if (pMainForm == NULL) |
504 |
|
return false; |
505 |
|
if (pMainForm->client() == NULL || m_iChannelID < 0) |
506 |
return false; |
return false; |
507 |
if (m_iInstrumentStatus == 100 && ((m_bSolo && bSolo) || (!m_bSolo && !bSolo))) |
if (m_iInstrumentStatus == 100 && ((m_bSolo && bSolo) || (!m_bSolo && !bSolo))) |
508 |
return true; |
return true; |
509 |
|
|
510 |
#ifdef CONFIG_MUTE_SOLO |
#ifdef CONFIG_MUTE_SOLO |
511 |
if (::lscp_set_channel_solo(client(), m_iChannelID, bSolo) != LSCP_OK) { |
if (::lscp_set_channel_solo(pMainForm->client(), m_iChannelID, bSolo) != LSCP_OK) { |
512 |
appendMessagesClient("lscp_set_channel_solo"); |
appendMessagesClient("lscp_set_channel_solo"); |
513 |
return false; |
return false; |
514 |
} |
} |
529 |
|
|
530 |
bool qsamplerChannel::setAudioChannel ( int iAudioOut, int iAudioIn ) |
bool qsamplerChannel::setAudioChannel ( int iAudioOut, int iAudioIn ) |
531 |
{ |
{ |
532 |
if (client() == NULL || m_iChannelID < 0) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
533 |
|
if (pMainForm == NULL) |
534 |
|
return false; |
535 |
|
if (pMainForm->client() == NULL || m_iChannelID < 0) |
536 |
return false; |
return false; |
537 |
if (m_iInstrumentStatus == 100 && |
if (m_iInstrumentStatus == 100 && |
538 |
m_audioRouting[iAudioOut] == iAudioIn) |
m_audioRouting[iAudioOut] == iAudioIn) |
539 |
return true; |
return true; |
540 |
|
|
541 |
if (::lscp_set_channel_audio_channel(client(), |
if (::lscp_set_channel_audio_channel(pMainForm->client(), |
542 |
m_iChannelID, iAudioOut, iAudioIn) != LSCP_OK) { |
m_iChannelID, iAudioOut, iAudioIn) != LSCP_OK) { |
543 |
appendMessagesClient("lscp_set_channel_audio_channel"); |
appendMessagesClient("lscp_set_channel_audio_channel"); |
544 |
return false; |
return false; |
571 |
// Update whole channel info state. |
// Update whole channel info state. |
572 |
bool qsamplerChannel::updateChannelInfo (void) |
bool qsamplerChannel::updateChannelInfo (void) |
573 |
{ |
{ |
574 |
if (client() == NULL || m_iChannelID < 0) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
575 |
|
if (pMainForm == NULL) |
576 |
|
return false; |
577 |
|
if (pMainForm->client() == NULL || m_iChannelID < 0) |
578 |
return false; |
return false; |
579 |
|
|
580 |
// Read channel information. |
// Read channel information. |
581 |
lscp_channel_info_t *pChannelInfo = ::lscp_get_channel_info(client(), m_iChannelID); |
lscp_channel_info_t *pChannelInfo = ::lscp_get_channel_info(pMainForm->client(), m_iChannelID); |
582 |
if (pChannelInfo == NULL) { |
if (pChannelInfo == NULL) { |
583 |
appendMessagesClient("lscp_get_channel_info"); |
appendMessagesClient("lscp_get_channel_info"); |
584 |
appendMessagesError(QObject::tr("Could not get channel information.\n\nSorry.")); |
appendMessagesError(QObject::tr("Could not get channel information.\n\nSorry.")); |
607 |
m_iMidiDevice = pChannelInfo->midi_device; |
m_iMidiDevice = pChannelInfo->midi_device; |
608 |
m_iMidiPort = pChannelInfo->midi_port; |
m_iMidiPort = pChannelInfo->midi_port; |
609 |
m_iMidiChannel = pChannelInfo->midi_channel; |
m_iMidiChannel = pChannelInfo->midi_channel; |
610 |
|
#ifdef CONFIG_MIDI_INSTRUMENT |
611 |
|
m_iMidiMap = pChannelInfo->midi_map; |
612 |
|
#endif |
613 |
m_iAudioDevice = pChannelInfo->audio_device; |
m_iAudioDevice = pChannelInfo->audio_device; |
614 |
m_fVolume = pChannelInfo->volume; |
m_fVolume = pChannelInfo->volume; |
615 |
#ifdef CONFIG_MUTE_SOLO |
#ifdef CONFIG_MUTE_SOLO |
628 |
lscp_device_info_t *pDeviceInfo; |
lscp_device_info_t *pDeviceInfo; |
629 |
const QString sNone = QObject::tr("(none)"); |
const QString sNone = QObject::tr("(none)"); |
630 |
// Audio device driver type. |
// Audio device driver type. |
631 |
pDeviceInfo = ::lscp_get_audio_device_info(client(), m_iAudioDevice); |
pDeviceInfo = ::lscp_get_audio_device_info(pMainForm->client(), m_iAudioDevice); |
632 |
if (pDeviceInfo == NULL) { |
if (pDeviceInfo == NULL) { |
633 |
appendMessagesClient("lscp_get_audio_device_info"); |
appendMessagesClient("lscp_get_audio_device_info"); |
634 |
m_sAudioDriver = sNone; |
m_sAudioDriver = sNone; |
636 |
m_sAudioDriver = pDeviceInfo->driver; |
m_sAudioDriver = pDeviceInfo->driver; |
637 |
} |
} |
638 |
// MIDI device driver type. |
// MIDI device driver type. |
639 |
pDeviceInfo = ::lscp_get_midi_device_info(client(), m_iMidiDevice); |
pDeviceInfo = ::lscp_get_midi_device_info(pMainForm->client(), m_iMidiDevice); |
640 |
if (pDeviceInfo == NULL) { |
if (pDeviceInfo == NULL) { |
641 |
appendMessagesClient("lscp_get_midi_device_info"); |
appendMessagesClient("lscp_get_midi_device_info"); |
642 |
m_sMidiDriver = sNone; |
m_sMidiDriver = sNone; |
646 |
|
|
647 |
// Set the audio routing map. |
// Set the audio routing map. |
648 |
m_audioRouting.clear(); |
m_audioRouting.clear(); |
649 |
char **ppszRouting = pChannelInfo->audio_routing; |
#ifdef CONFIG_AUDIO_ROUTING |
650 |
for (int i = 0; ppszRouting && ppszRouting[i]; i++) { |
int *piAudioRouting = pChannelInfo->audio_routing; |
651 |
m_audioRouting[i] = ::atoi(ppszRouting[i]); |
for (int i = 0; piAudioRouting && piAudioRouting[i] >= 0; i++) |
652 |
} |
m_audioRouting[i] = piAudioRouting[i]; |
653 |
|
#else |
654 |
|
char **ppszAudioRouting = pChannelInfo->audio_routing; |
655 |
|
for (int i = 0; ppszAudioRouting && ppszAudioRouting[i]; i++) |
656 |
|
m_audioRouting[i] = ::atoi(ppszAudioRouting[i]); |
657 |
|
#endif |
658 |
|
|
659 |
return true; |
return true; |
660 |
} |
} |
663 |
// Reset channel method. |
// Reset channel method. |
664 |
bool qsamplerChannel::channelReset (void) |
bool qsamplerChannel::channelReset (void) |
665 |
{ |
{ |
666 |
if (client() == NULL || m_iChannelID < 0) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
667 |
|
if (pMainForm == NULL) |
668 |
|
return false; |
669 |
|
if (pMainForm->client() == NULL || m_iChannelID < 0) |
670 |
return false; |
return false; |
671 |
|
|
672 |
if (::lscp_reset_channel(client(), m_iChannelID) != LSCP_OK) { |
if (::lscp_reset_channel(pMainForm->client(), m_iChannelID) != LSCP_OK) { |
673 |
appendMessagesClient("lscp_reset_channel"); |
appendMessagesClient("lscp_reset_channel"); |
674 |
return false; |
return false; |
675 |
} |
} |
680 |
} |
} |
681 |
|
|
682 |
|
|
683 |
|
// Spawn instrument editor method. |
684 |
|
bool qsamplerChannel::editChannel (void) |
685 |
|
{ |
686 |
|
#ifdef CONFIG_EDIT_INSTRUMENT |
687 |
|
|
688 |
|
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
689 |
|
if (pMainForm == NULL) |
690 |
|
return false; |
691 |
|
if (pMainForm->client() == NULL || m_iChannelID < 0) |
692 |
|
return false; |
693 |
|
|
694 |
|
if (::lscp_edit_instrument(pMainForm->client(), m_iChannelID) != LSCP_OK) { |
695 |
|
appendMessagesClient("lscp_edit_instrument"); |
696 |
|
appendMessagesError(QObject::tr( |
697 |
|
"Could not launch an appropriate instrument editor " |
698 |
|
"for the given instrument!\n" |
699 |
|
"Make sure you have an appropriate " |
700 |
|
"instrument editor like 'gigedit' installed\n" |
701 |
|
"and that it placed its mandatory DLL file " |
702 |
|
"into the sampler's plugin directory.") |
703 |
|
); |
704 |
|
return false; |
705 |
|
} |
706 |
|
|
707 |
|
appendMessages(QObject::tr("edit instrument.")); |
708 |
|
|
709 |
|
return true; |
710 |
|
|
711 |
|
#else |
712 |
|
|
713 |
|
appendMessagesError(QObject::tr( |
714 |
|
"Sorry, QSampler was compiled for a version of liblscp " |
715 |
|
"which lacks this feature.\n" |
716 |
|
"You may want to update liblscp and recompile QSampler afterwards.") |
717 |
|
); |
718 |
|
|
719 |
|
return false; |
720 |
|
|
721 |
|
#endif |
722 |
|
} |
723 |
|
|
724 |
|
|
725 |
// Channel setup dialog form. |
// Channel setup dialog form. |
726 |
bool qsamplerChannel::channelSetup ( QWidget *pParent ) |
bool qsamplerChannel::channelSetup ( QWidget *pParent ) |
727 |
{ |
{ |
728 |
|
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
729 |
|
if (pMainForm == NULL) |
730 |
|
return false; |
731 |
|
|
732 |
bool bResult = false; |
bool bResult = false; |
733 |
|
|
734 |
appendMessages(QObject::tr("setup...")); |
appendMessages(QObject::tr("setup...")); |
747 |
// Redirected messages output methods. |
// Redirected messages output methods. |
748 |
void qsamplerChannel::appendMessages( const QString& s ) const |
void qsamplerChannel::appendMessages( const QString& s ) const |
749 |
{ |
{ |
750 |
if (m_pMainForm) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
751 |
m_pMainForm->appendMessages(channelName() + ' ' + s); |
if (pMainForm) |
752 |
|
pMainForm->appendMessages(channelName() + ' ' + s); |
753 |
} |
} |
754 |
|
|
755 |
void qsamplerChannel::appendMessagesColor( const QString& s, |
void qsamplerChannel::appendMessagesColor( const QString& s, |
756 |
const QString& c ) const |
const QString& c ) const |
757 |
{ |
{ |
758 |
if (m_pMainForm) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
759 |
m_pMainForm->appendMessagesColor(channelName() + ' ' + s, c); |
if (pMainForm) |
760 |
|
pMainForm->appendMessagesColor(channelName() + ' ' + s, c); |
761 |
} |
} |
762 |
|
|
763 |
void qsamplerChannel::appendMessagesText( const QString& s ) const |
void qsamplerChannel::appendMessagesText( const QString& s ) const |
764 |
{ |
{ |
765 |
if (m_pMainForm) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
766 |
m_pMainForm->appendMessagesText(channelName() + ' ' + s); |
if (pMainForm) |
767 |
|
pMainForm->appendMessagesText(channelName() + ' ' + s); |
768 |
} |
} |
769 |
|
|
770 |
void qsamplerChannel::appendMessagesError( const QString& s ) const |
void qsamplerChannel::appendMessagesError( const QString& s ) const |
771 |
{ |
{ |
772 |
if (m_pMainForm) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
773 |
m_pMainForm->appendMessagesError(channelName() + "\n\n" + s); |
if (pMainForm) |
774 |
|
pMainForm->appendMessagesError(channelName() + "\n\n" + s); |
775 |
} |
} |
776 |
|
|
777 |
void qsamplerChannel::appendMessagesClient( const QString& s ) const |
void qsamplerChannel::appendMessagesClient( const QString& s ) const |
778 |
{ |
{ |
779 |
if (m_pMainForm) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
780 |
m_pMainForm->appendMessagesClient(channelName() + ' ' + s); |
if (pMainForm) |
781 |
|
pMainForm->appendMessagesClient(channelName() + ' ' + s); |
782 |
} |
} |
783 |
|
|
784 |
|
|
785 |
// Context menu event handler. |
// Context menu event handler. |
786 |
void qsamplerChannel::contextMenuEvent( QContextMenuEvent *pEvent ) |
void qsamplerChannel::contextMenuEvent( QContextMenuEvent *pEvent ) |
787 |
{ |
{ |
788 |
if (m_pMainForm) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
789 |
m_pMainForm->contextMenuEvent(pEvent); |
if (pMainForm) |
790 |
|
pMainForm->contextMenuEvent(pEvent); |
791 |
} |
} |
792 |
|
|
793 |
|
|