1 |
// qsamplerChannel.cpp |
// qsamplerChannel.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2006, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
|
|
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 |
19 |
|
|
20 |
*****************************************************************************/ |
*****************************************************************************/ |
21 |
|
|
22 |
|
#include "qsamplerUtilities.h" |
23 |
#include "qsamplerAbout.h" |
#include "qsamplerAbout.h" |
24 |
#include "qsamplerChannel.h" |
#include "qsamplerChannel.h" |
25 |
|
|
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; |
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(pMainForm->client(), sInstrumentFile.latin1(), iInstrumentNr, m_iChannelID) != LSCP_OK) { |
if ( |
207 |
|
::lscp_load_instrument_non_modal( |
208 |
|
pMainForm->client(), |
209 |
|
qsamplerUtilities::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 |
} |
} |
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 |
{ |
{ |
587 |
|
|
588 |
#ifdef CONFIG_INSTRUMENT_NAME |
#ifdef CONFIG_INSTRUMENT_NAME |
589 |
// We got all actual instrument datum... |
// We got all actual instrument datum... |
590 |
m_sInstrumentFile = pChannelInfo->instrument_file; |
m_sInstrumentFile = |
591 |
|
qsamplerUtilities::lscpEscapedPathToPosix(pChannelInfo->instrument_file); |
592 |
m_iInstrumentNr = pChannelInfo->instrument_nr; |
m_iInstrumentNr = pChannelInfo->instrument_nr; |
593 |
m_sInstrumentName = pChannelInfo->instrument_name; |
m_sInstrumentName = |
594 |
|
qsamplerUtilities::lscpEscapedTextToRaw(pChannelInfo->instrument_name); |
595 |
#else |
#else |
596 |
// First, check if intrument name has changed, |
// First, check if intrument name has changed, |
597 |
// taking care that instrument name lookup might be expensive, |
// taking care that instrument name lookup might be expensive, |
609 |
m_iMidiDevice = pChannelInfo->midi_device; |
m_iMidiDevice = pChannelInfo->midi_device; |
610 |
m_iMidiPort = pChannelInfo->midi_port; |
m_iMidiPort = pChannelInfo->midi_port; |
611 |
m_iMidiChannel = pChannelInfo->midi_channel; |
m_iMidiChannel = pChannelInfo->midi_channel; |
612 |
|
#ifdef CONFIG_MIDI_INSTRUMENT |
613 |
|
m_iMidiMap = pChannelInfo->midi_map; |
614 |
|
#endif |
615 |
m_iAudioDevice = pChannelInfo->audio_device; |
m_iAudioDevice = pChannelInfo->audio_device; |
616 |
m_fVolume = pChannelInfo->volume; |
m_fVolume = pChannelInfo->volume; |
617 |
#ifdef CONFIG_MUTE_SOLO |
#ifdef CONFIG_MUTE_SOLO |
648 |
|
|
649 |
// Set the audio routing map. |
// Set the audio routing map. |
650 |
m_audioRouting.clear(); |
m_audioRouting.clear(); |
651 |
char **ppszRouting = pChannelInfo->audio_routing; |
#ifdef CONFIG_AUDIO_ROUTING |
652 |
for (int i = 0; ppszRouting && ppszRouting[i]; i++) { |
int *piAudioRouting = pChannelInfo->audio_routing; |
653 |
m_audioRouting[i] = ::atoi(ppszRouting[i]); |
for (int i = 0; piAudioRouting && piAudioRouting[i] >= 0; i++) |
654 |
} |
m_audioRouting[i] = piAudioRouting[i]; |
655 |
|
#else |
656 |
|
char **ppszAudioRouting = pChannelInfo->audio_routing; |
657 |
|
for (int i = 0; ppszAudioRouting && ppszAudioRouting[i]; i++) |
658 |
|
m_audioRouting[i] = ::atoi(ppszAudioRouting[i]); |
659 |
|
#endif |
660 |
|
|
661 |
return true; |
return true; |
662 |
} |
} |
682 |
} |
} |
683 |
|
|
684 |
|
|
685 |
|
// Spawn instrument editor method. |
686 |
|
bool qsamplerChannel::editChannel (void) |
687 |
|
{ |
688 |
|
#ifdef CONFIG_EDIT_INSTRUMENT |
689 |
|
|
690 |
|
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
691 |
|
if (pMainForm == NULL) |
692 |
|
return false; |
693 |
|
if (pMainForm->client() == NULL || m_iChannelID < 0) |
694 |
|
return false; |
695 |
|
|
696 |
|
if (::lscp_edit_instrument(pMainForm->client(), m_iChannelID) != LSCP_OK) { |
697 |
|
appendMessagesClient("lscp_edit_instrument"); |
698 |
|
appendMessagesError(QObject::tr( |
699 |
|
"Could not launch an appropriate instrument editor " |
700 |
|
"for the given instrument!\n" |
701 |
|
"Make sure you have an appropriate " |
702 |
|
"instrument editor like 'gigedit' installed\n" |
703 |
|
"and that it placed its mandatory DLL file " |
704 |
|
"into the sampler's plugin directory.") |
705 |
|
); |
706 |
|
return false; |
707 |
|
} |
708 |
|
|
709 |
|
appendMessages(QObject::tr("edit instrument.")); |
710 |
|
|
711 |
|
return true; |
712 |
|
|
713 |
|
#else |
714 |
|
|
715 |
|
appendMessagesError(QObject::tr( |
716 |
|
"Sorry, QSampler was compiled for a version of liblscp " |
717 |
|
"which lacks this feature.\n" |
718 |
|
"You may want to update liblscp and recompile QSampler afterwards.") |
719 |
|
); |
720 |
|
|
721 |
|
return false; |
722 |
|
|
723 |
|
#endif |
724 |
|
} |
725 |
|
|
726 |
|
|
727 |
// Channel setup dialog form. |
// Channel setup dialog form. |
728 |
bool qsamplerChannel::channelSetup ( QWidget *pParent ) |
bool qsamplerChannel::channelSetup ( QWidget *pParent ) |
729 |
{ |
{ |