--- qsampler/trunk/src/qsamplerChannelStrip.ui.h 2004/06/14 21:05:20 127 +++ qsampler/trunk/src/qsamplerChannelStrip.ui.h 2004/06/24 18:26:57 145 @@ -41,16 +41,17 @@ m_pMainForm = NULL; m_iChannelID = 0; -// m_sEngineName = "(No engine)"; -// m_sInstrumentFile = "(No instrument)"; - m_iInstrumentNr = 0; - m_sMidiDriver = "ALSA"; // DEPRECATED. - m_iMidiDevice = 0; - m_iMidiPort = 0; - m_iMidiChannel = 0; - m_sAudioDriver = "ALSA"; // DEPRECATED. - m_iAudioDevice = 0; - m_fVolume = 0.8; +// m_sEngineName = tr("(No engine)"); +// m_sInstrumentFile = tr("(No instrument)"); + m_iInstrumentNr = -1; + m_iInstrumentStatus = -1; + m_sMidiDriver = "Alsa"; // DEPRECATED. + m_iMidiDevice = -1; + m_iMidiPort = -1; + m_iMidiChannel = -1; + m_sAudioDriver = "Alsa"; // DEPRECATED. + m_iAudioDevice = -1; + m_fVolume = 0.0; m_iDirtyChange = 0; @@ -130,30 +131,39 @@ } -// Instrument filename accessors. +// Instrument filename accessor. QString& qsamplerChannelStrip::instrumentFile (void) { return m_sInstrumentFile; } -// Instrument index accessors. +// Instrument index accessor. int qsamplerChannelStrip::instrumentNr (void) { return m_iInstrumentNr; } +// Instrument status accessor. +int qsamplerChannelStrip::instrumentStatus (void) +{ + return m_iInstrumentStatus; +} + +// Instrument file loader. bool qsamplerChannelStrip::loadInstrument ( const QString& sInstrumentFile, int iInstrumentNr ) { if (client() == NULL) return false; - if (::lscp_load_instrument(client(), sInstrumentFile.latin1(), iInstrumentNr, m_iChannelID) != LSCP_OK) { + if (::lscp_load_instrument_non_modal(client(), sInstrumentFile.latin1(), iInstrumentNr, m_iChannelID) != LSCP_OK) { appendMessagesClient("lscp_load_instrument"); return false; } m_sInstrumentFile = sInstrumentFile; m_iInstrumentNr = iInstrumentNr; + m_iInstrumentStatus = 0; + return true; } @@ -190,11 +200,10 @@ if (client() == NULL) return false; -// FIXME: call this when LSCP becomes stable. -// if (::lscp_set_channel_midi_device(client(), m_iChannelID, iMidiDevice) != LSCP_OK) { -// appendMessagesClient("lscp_set_channel_midi_device"); -// return false; -// } + if (::lscp_set_channel_midi_device(client(), m_iChannelID, iMidiDevice) != LSCP_OK) { + appendMessagesClient("lscp_set_channel_midi_device"); + return false; + } m_iMidiDevice = iMidiDevice; return true; @@ -212,11 +221,10 @@ if (client() == NULL) return false; -// FIXME: call this when LSCP becomes stable. -// if (::lscp_set_channel_midi_port(client(), m_iChannelID, iMidiPort) != LSCP_OK) { -// appendMessagesClient("lscp_set_channel_midi_port"); -// return false; -// } + if (::lscp_set_channel_midi_port(client(), m_iChannelID, iMidiPort) != LSCP_OK) { + appendMessagesClient("lscp_set_channel_midi_port"); + return false; + } m_iMidiPort = iMidiPort; return true; @@ -234,11 +242,10 @@ if (client() == NULL) return false; -// FIXME: call this when LSCP becomes stable. -// if (::lscp_set_channel_midi_channel(client(), m_iChannelID, iMidiChannel) != LSCP_OK) { -// appendMessagesClient("lscp_set_channel_midi_channel"); -// return false; -// } + if (::lscp_set_channel_midi_channel(client(), m_iChannelID, iMidiChannel) != LSCP_OK) { + appendMessagesClient("lscp_set_channel_midi_channel"); + return false; + } m_iMidiChannel = iMidiChannel; return true; @@ -256,11 +263,10 @@ if (client() == NULL) return false; -// FIXME: call this when LSCP becomes stable. -// if (::lscp_set_channel_audio_device(client(), m_iChannelID, iAudioDevice) != LSCP_OK) { -// appendMessagesClient("lscp_set_channel_audio_device"); -// return false; -// } + if (::lscp_set_channel_audio_device(client(), m_iChannelID, iAudioDevice) != LSCP_OK) { + appendMessagesClient("lscp_set_channel_audio_device"); + return false; + } m_iAudioDevice = iAudioDevice; return true; @@ -318,8 +324,9 @@ void qsamplerChannelStrip::setDisplayFont ( const QFont & font ) { EngineNameTextLabel->setFont(font); - InstrumentNameTextLabel->setFont(font); MidiPortChannelTextLabel->setFont(font); + InstrumentNameTextLabel->setFont(font); + InstrumentStatusTextLabel->setFont(font); } // Channel setup dialog. @@ -353,17 +360,23 @@ lscp_channel_info_t *pChannelInfo = ::lscp_get_channel_info(client(), m_iChannelID); if (pChannelInfo == NULL) { appendMessagesClient("lscp_get_channel_info"); - // appendMessagesError(tr("Could not get channel information.\n\nSorry.")); + appendMessagesError(tr("Could not get channel information.\n\nSorry.")); } else { // Cache in channel information. - m_sEngineName = pChannelInfo->engine_name; - m_sInstrumentFile = pChannelInfo->instrument_file; - m_iInstrumentNr = pChannelInfo->instrument_nr; - m_iMidiDevice = pChannelInfo->midi_device; - m_iMidiPort = pChannelInfo->midi_port; - m_iMidiChannel = pChannelInfo->midi_channel; - m_iAudioDevice = pChannelInfo->audio_device; - m_fVolume = pChannelInfo->volume; + m_sEngineName = pChannelInfo->engine_name; + m_sInstrumentFile = pChannelInfo->instrument_file; + m_iInstrumentNr = pChannelInfo->instrument_nr; + m_iInstrumentStatus = pChannelInfo->instrument_status; + m_iMidiDevice = pChannelInfo->midi_device; + m_iMidiPort = pChannelInfo->midi_port; + m_iMidiChannel = pChannelInfo->midi_channel; + m_iAudioDevice = pChannelInfo->audio_device; + m_fVolume = pChannelInfo->volume; + // Some sanity checks. + if (m_sEngineName == "NONE") + m_sEngineName = QString::null; + if (m_sInstrumentFile == "NONE") + m_sInstrumentFile = QString::null; } // Set some proper display values. @@ -381,6 +394,15 @@ InstrumentNameTextLabel->setText(QString("%1 [%2]") .arg(QFileInfo(m_sInstrumentFile).fileName()).arg(m_iInstrumentNr)); + // Instrument status... + if (m_iInstrumentStatus < 0) { + InstrumentStatusTextLabel->setPaletteForegroundColor(Qt::red); + InstrumentStatusTextLabel->setText(tr("ERR%1").arg(m_iInstrumentStatus)); + } else { + InstrumentStatusTextLabel->setPaletteForegroundColor(m_iInstrumentStatus < 100 ? Qt::yellow : Qt::green); + InstrumentStatusTextLabel->setText(QString::number(m_iInstrumentStatus) + "%"); + } + // MIDI Port/Channel... MidiPortChannelTextLabel->setText(QString("%1 / %2") .arg(m_iMidiPort).arg(m_iMidiChannel)); @@ -425,6 +447,10 @@ if (client() == NULL) return; + // Conditionally update whole channel status info. + if (m_iInstrumentStatus >= 0 && m_iInstrumentStatus < 100) + updateChannelInfo(); + // Get current channel voice count. int iVoiceCount = ::lscp_get_channel_voice_count(client(), m_iChannelID); // Get current stream count.