--- qsampler/trunk/src/qsamplerChannelForm.ui.h 2004/09/29 13:12:45 264 +++ qsampler/trunk/src/qsamplerChannelForm.ui.h 2005/01/18 13:53:04 344 @@ -2,7 +2,7 @@ // // ui.h extension file, included from the uic-generated form implementation. /**************************************************************************** - Copyright (C) 2004, rncbc aka Rui Nuno Capela. All rights reserved. + Copyright (C) 2004-2005, rncbc aka Rui Nuno Capela. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -50,7 +50,7 @@ // Channel dialog setup formal initializer. -void qsamplerChannelForm::setup ( qsamplerChannel *pChannel, bool bNew ) +void qsamplerChannelForm::setup ( qsamplerChannel *pChannel ) { m_pChannel = pChannel; @@ -60,7 +60,9 @@ if (m_pChannel == NULL) return; - setCaption(tr("Channel %1").arg(m_pChannel->channelID())); + // It can be a brand new channel, remember? + bool bNew = (m_pChannel->channelID() < 0); + setCaption(m_pChannel->channelName()); // Check if we're up and connected. if (m_pChannel->client() == NULL) @@ -120,10 +122,14 @@ if (sInstrumentFile.isEmpty()) sInstrumentFile = tr("(No instrument)"); InstrumentFileComboBox->setCurrentText(sInstrumentFile); - InstrumentNrSpinBox->setValue(pChannel->instrumentNr()); + InstrumentNrComboBox->clear(); + InstrumentNrComboBox->insertStringList( + qsamplerChannel::getInstrumentList(sInstrumentFile, + pOptions->bInstrumentNames)); + InstrumentNrComboBox->setCurrentItem(pChannel->instrumentNr()); // MIDI input driver... QString sMidiDriver = pChannel->midiDriver(); - if (sMidiDriver.isEmpty() && bNew) + if (sMidiDriver.isEmpty() || bNew) sMidiDriver = pOptions->sMidiDriver; if (!sMidiDriver.isEmpty()) { if (MidiDriverComboBox->listBox()->findItem(sMidiDriver, Qt::ExactMatch) == NULL) @@ -134,12 +140,13 @@ MidiPortSpinBox->setValue(pChannel->midiPort()); // MIDI input channel... int iMidiChannel = pChannel->midiChannel(); - if (bNew) - iMidiChannel = (pChannel->channelID() + 1) % 16; + // When new, try to suggest a sensible MIDI channel... + if (iMidiChannel < 0) + iMidiChannel = (::lscp_get_channels(m_pChannel->client()) % 16); MidiChannelComboBox->setCurrentItem(iMidiChannel); // Audio output driver... QString sAudioDriver = pChannel->audioDriver(); - if (sAudioDriver.isEmpty() && bNew) + if (sAudioDriver.isEmpty() || bNew) sAudioDriver = pOptions->sAudioDriver; if (!sAudioDriver.isEmpty()) { if (AudioDriverComboBox->listBox()->findItem(sAudioDriver, Qt::ExactMatch) == NULL) @@ -165,6 +172,9 @@ // We'll go for it! if (m_iDirtyCount > 0) { int iErrors = 0; + // Are we a new channel? + if (!m_pChannel->addChannel()) + iErrors++; // Audio output driver type... if (!m_pChannel->setAudioDriver(AudioDriverComboBox->currentText())) iErrors++; @@ -181,7 +191,7 @@ if (!m_pChannel->loadEngine(EngineNameComboBox->currentText())) iErrors++; // Instrument file and index... - if (!m_pChannel->loadInstrument(InstrumentFileComboBox->currentText(), InstrumentNrSpinBox->value())) + if (!m_pChannel->loadInstrument(InstrumentFileComboBox->currentText(), InstrumentNrComboBox->currentItem())) iErrors++; // Show error messages? if (iErrors > 0) @@ -252,10 +262,18 @@ // Refresh the actual instrument name. void qsamplerChannelForm::updateInstrumentName (void) { - // FIXME: A better idea would be to use libgig - // to retrieve the REAL instrument name. - InstrumentNameTextLabel->setText(QFileInfo(InstrumentFileComboBox->currentText()).fileName() - + " [" + QString::number(InstrumentNrSpinBox->value()) + "]"); + qsamplerOptions *pOptions = m_pChannel->options(); + if (pOptions == NULL) + return; + + // Finally this better idea would be to use libgig + // to retrieve the REAL instrument names. + InstrumentNrComboBox->clear(); + InstrumentNrComboBox->insertStringList( + qsamplerChannel::getInstrumentList( + InstrumentFileComboBox->currentText(), + pOptions->bInstrumentNames) + ); optionsChanged(); }