/[svn]/qsampler/trunk/src/qsamplerChannelForm.ui.h
ViewVC logotype

Diff of /qsampler/trunk/src/qsamplerChannelForm.ui.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 295 by capela, Tue Nov 16 15:26:18 2004 UTC revision 462 by capela, Tue Mar 15 11:39:12 2005 UTC
# Line 2  Line 2 
2  //  //
3  // ui.h extension file, included from the uic-generated form implementation.  // ui.h extension file, included from the uic-generated form implementation.
4  /****************************************************************************  /****************************************************************************
5     Copyright (C) 2004, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2005, rncbc aka Rui Nuno Capela. All rights reserved.
6    
7     This program is free software; you can redistribute it and/or     This program is free software; you can redistribute it and/or
8     modify it under the terms of the GNU General Public License     modify it under the terms of the GNU General Public License
# Line 38  void qsamplerChannelForm::init (void) Line 38  void qsamplerChannelForm::init (void)
38      m_iDirtySetup = 0;      m_iDirtySetup = 0;
39      m_iDirtyCount = 0;      m_iDirtyCount = 0;
40    
41            m_midiDevices.setAutoDelete(true);
42            m_audioDevices.setAutoDelete(true);
43    
44      // Try to restore normal window positioning.      // Try to restore normal window positioning.
45      adjustSize();      adjustSize();
46  }  }
# Line 88  void qsamplerChannelForm::setup ( qsampl Line 91  void qsamplerChannelForm::setup ( qsampl
91      else m_pChannel->appendMessagesClient("lscp_get_available_engines");      else m_pChannel->appendMessagesClient("lscp_get_available_engines");
92    
93      // Populate Audio output type list.      // Populate Audio output type list.
94      const char **ppszAudioDrivers = ::lscp_get_available_audio_drivers(m_pChannel->client());      AudioDriverComboBox->clear();
95      if (ppszAudioDrivers) {      AudioDriverComboBox->insertStringList(
96          AudioDriverComboBox->clear();                  qsamplerDevice::getDrivers(m_pChannel->client(), qsamplerDevice::Audio));
         for (int iAudioDriver = 0; ppszAudioDrivers[iAudioDriver]; iAudioDriver++)  
             AudioDriverComboBox->insertItem(ppszAudioDrivers[iAudioDriver]);  
     }  
     else m_pChannel->appendMessagesClient("lscp_get_available_audio_drivers");  
97    
98      // Populate MIDI input type list.      // Populate MIDI input type list.
99      const char **ppszMidiDrivers = ::lscp_get_available_midi_drivers(m_pChannel->client());      MidiDriverComboBox->clear();
100      if (ppszMidiDrivers) {      MidiDriverComboBox->insertStringList(
101          MidiDriverComboBox->clear();                  qsamplerDevice::getDrivers(m_pChannel->client(), qsamplerDevice::Midi));
         for (int iMidiDriver = 0; ppszMidiDrivers[iMidiDriver]; iMidiDriver++)  
             MidiDriverComboBox->insertItem(ppszMidiDrivers[iMidiDriver]);  
     }  
     else m_pChannel->appendMessagesClient("lscp_get_available_midi_drivers");  
102    
103      // Read proper channel information,      // Read proper channel information,
104      // and populate the channel form fields.      // and populate the channel form fields.
105    
106      // Engine name...      // Engine name...
107      QString sEngineName = pChannel->engineName();      QString sEngineName = pChannel->engineName();
108      if (sEngineName.isEmpty() && bNew)      if (sEngineName.isEmpty() || bNew)
109          sEngineName = pOptions->sEngineName;          sEngineName = pOptions->sEngineName;
110      if (sEngineName.isEmpty())      if (sEngineName.isEmpty())
111          sEngineName = tr("(No engine)");          sEngineName = qsamplerChannel::noEngineName();
112      if (EngineNameComboBox->listBox()->findItem(sEngineName, Qt::ExactMatch) == NULL)      if (EngineNameComboBox->listBox()->findItem(sEngineName, Qt::ExactMatch) == NULL)
113          EngineNameComboBox->insertItem(sEngineName);          EngineNameComboBox->insertItem(sEngineName);
114      EngineNameComboBox->setCurrentText(sEngineName);      EngineNameComboBox->setCurrentText(sEngineName);
115      // Instrument filename and index...      // Instrument filename and index...
116      QString sInstrumentFile = pChannel->instrumentFile();      QString sInstrumentFile = pChannel->instrumentFile();
117      if (sInstrumentFile.isEmpty())      if (sInstrumentFile.isEmpty())
118          sInstrumentFile = tr("(No instrument)");          sInstrumentFile = qsamplerChannel::noInstrumentName();
119      InstrumentFileComboBox->setCurrentText(sInstrumentFile);      InstrumentFileComboBox->setCurrentText(sInstrumentFile);
120      InstrumentNrSpinBox->setValue(pChannel->instrumentNr());      InstrumentNrComboBox->clear();
121        InstrumentNrComboBox->insertStringList(
122                    qsamplerChannel::getInstrumentList(sInstrumentFile,
123                    pOptions->bInstrumentNames));
124        InstrumentNrComboBox->setCurrentItem(pChannel->instrumentNr());
125        
126            // MIDI input device...
127            qsamplerDevice midiDevice(m_pChannel->client(),
128                    qsamplerDevice::Midi, m_pChannel->midiDevice());
129      // MIDI input driver...      // MIDI input driver...
130      QString sMidiDriver = pChannel->midiDriver();          QString sMidiDriver = midiDevice.driverName();
131      if (sMidiDriver.isEmpty() || bNew)          if (sMidiDriver.isEmpty() || bNew)
132          sMidiDriver = pOptions->sMidiDriver;                  sMidiDriver = pOptions->sMidiDriver;
133      if (!sMidiDriver.isEmpty()) {          if (!sMidiDriver.isEmpty()) {
134          if (MidiDriverComboBox->listBox()->findItem(sMidiDriver, Qt::ExactMatch) == NULL)                  if (MidiDriverComboBox->listBox()->findItem(sMidiDriver, Qt::ExactMatch) == NULL)
135              MidiDriverComboBox->insertItem(sMidiDriver);                          MidiDriverComboBox->insertItem(sMidiDriver);
136          MidiDriverComboBox->setCurrentText(sMidiDriver);                  MidiDriverComboBox->setCurrentText(sMidiDriver);
137      }          }
138            selectMidiDriver(sMidiDriver);
139            if (!bNew)
140                    MidiDeviceComboBox->setCurrentText(midiDevice.deviceName());
141            selectMidiDevice(MidiDeviceComboBox->currentItem());
142      // MIDI input port...      // MIDI input port...
143      MidiPortSpinBox->setValue(pChannel->midiPort());      MidiPortSpinBox->setValue(pChannel->midiPort());
144      // MIDI input channel...      // MIDI input channel...
# Line 140  void qsamplerChannelForm::setup ( qsampl Line 147  void qsamplerChannelForm::setup ( qsampl
147      if (iMidiChannel < 0)      if (iMidiChannel < 0)
148          iMidiChannel = (::lscp_get_channels(m_pChannel->client()) % 16);          iMidiChannel = (::lscp_get_channels(m_pChannel->client()) % 16);
149      MidiChannelComboBox->setCurrentItem(iMidiChannel);      MidiChannelComboBox->setCurrentItem(iMidiChannel);
150      // Audio output driver...  
151      QString sAudioDriver = pChannel->audioDriver();          // Audio output device...
152      if (sAudioDriver.isEmpty() || bNew)          qsamplerDevice audioDevice(m_pChannel->client(),
153          sAudioDriver = pOptions->sAudioDriver;                  qsamplerDevice::Audio, m_pChannel->audioDevice());
154      if (!sAudioDriver.isEmpty()) {          // Audio output driver...
155          if (AudioDriverComboBox->listBox()->findItem(sAudioDriver, Qt::ExactMatch) == NULL)          QString sAudioDriver = audioDevice.driverName();
156              AudioDriverComboBox->insertItem(sAudioDriver);          if (sAudioDriver.isEmpty() || bNew)
157          AudioDriverComboBox->setCurrentText(sAudioDriver);                  sAudioDriver = pOptions->sAudioDriver;
158      }          if (!sAudioDriver.isEmpty()) {
159                    if (AudioDriverComboBox->listBox()->findItem(sAudioDriver, Qt::ExactMatch) == NULL)
160                            AudioDriverComboBox->insertItem(sAudioDriver);
161                    AudioDriverComboBox->setCurrentText(sAudioDriver);
162            }
163            selectAudioDriver(sAudioDriver);
164            if (!bNew)
165                    AudioDeviceComboBox->setCurrentText(audioDevice.deviceName());
166            selectAudioDevice(AudioDeviceComboBox->currentItem());
167    
168            // As convenient, make it ready on stabilizeForm() for
169            // prompt acceptance, if we got the minimum required...
170            if (sEngineName != qsamplerChannel::noEngineName() &&
171                    sInstrumentFile != qsamplerChannel::noInstrumentName())
172                    m_iDirtyCount++;
173            // FIXME: These are better leave disabled...
174        MidiPortTextLabel->setEnabled(false);
175        MidiPortSpinBox->setEnabled(false);
176      // Done.      // Done.
177      m_iDirtySetup--;      m_iDirtySetup--;
178      stabilizeForm();      stabilizeForm();
# Line 171  void qsamplerChannelForm::accept (void) Line 195  void qsamplerChannelForm::accept (void)
195          // Are we a new channel?          // Are we a new channel?
196          if (!m_pChannel->addChannel())          if (!m_pChannel->addChannel())
197              iErrors++;              iErrors++;
198          // Audio output driver type...                  // Accept Audio driver or device selection...
199          if (!m_pChannel->setAudioDriver(AudioDriverComboBox->currentText()))                  if (m_audioDevices.isEmpty()) {
200              iErrors++;                          if (!m_pChannel->setAudioDriver(AudioDriverComboBox->currentText()))
201          // MIDI input driver type...                                  iErrors++;
202          if (!m_pChannel->setMidiDriver(MidiDriverComboBox->currentText()))                  } else {
203              iErrors++;                          qsamplerDevice *pDevice = m_audioDevices.at(AudioDeviceComboBox->currentItem());
204                            if (pDevice == NULL)
205                                    iErrors++;
206                            else if (!m_pChannel->setAudioDevice(pDevice->deviceID()))
207                                    iErrors++;
208                    }
209                    // Accept MIDI driver or device selection...
210                    if (m_midiDevices.isEmpty()) {
211                            if (!m_pChannel->setMidiDriver(MidiDriverComboBox->currentText()))
212                                    iErrors++;
213                    } else {
214                            qsamplerDevice *pDevice = m_midiDevices.at(MidiDeviceComboBox->currentItem());
215                            if (pDevice == NULL)
216                                    iErrors++;
217                            else if (!m_pChannel->setMidiDevice(pDevice->deviceID()))
218                                    iErrors++;
219                    }
220          // MIDI input port number...          // MIDI input port number...
221          if (!m_pChannel->setMidiPort(MidiPortSpinBox->value()))          if (!m_pChannel->setMidiPort(MidiPortSpinBox->value()))
222              iErrors++;              iErrors++;
# Line 187  void qsamplerChannelForm::accept (void) Line 227  void qsamplerChannelForm::accept (void)
227          if (!m_pChannel->loadEngine(EngineNameComboBox->currentText()))          if (!m_pChannel->loadEngine(EngineNameComboBox->currentText()))
228              iErrors++;              iErrors++;
229          // Instrument file and index...          // Instrument file and index...
230          if (!m_pChannel->loadInstrument(InstrumentFileComboBox->currentText(), InstrumentNrSpinBox->value()))          if (!m_pChannel->loadInstrument(InstrumentFileComboBox->currentText(), InstrumentNrComboBox->currentItem()))
231              iErrors++;              iErrors++;
232          // Show error messages?          // Show error messages?
233          if (iErrors > 0)          if (iErrors > 0)
# Line 258  void qsamplerChannelForm::openInstrument Line 298  void qsamplerChannelForm::openInstrument
298  // Refresh the actual instrument name.  // Refresh the actual instrument name.
299  void qsamplerChannelForm::updateInstrumentName (void)  void qsamplerChannelForm::updateInstrumentName (void)
300  {  {
301      // FIXME: A better idea would be to use libgig      qsamplerOptions *pOptions = m_pChannel->options();
302      // to retrieve the REAL instrument name.      if (pOptions == NULL)
303      InstrumentNameTextLabel->setText(QFileInfo(InstrumentFileComboBox->currentText()).fileName()          return;
304          + " [" + QString::number(InstrumentNrSpinBox->value()) + "]");  
305        // Finally this better idea would be to use libgig
306        // to retrieve the REAL instrument names.
307        InstrumentNrComboBox->clear();
308        InstrumentNrComboBox->insertStringList(
309            qsamplerChannel::getInstrumentList(
310                            InstrumentFileComboBox->currentText(),
311                            pOptions->bInstrumentNames)
312        );
313    
314      optionsChanged();      optionsChanged();
315  }  }
316    
317    
318    // Refresh MIDI device options.
319    void qsamplerChannelForm::selectMidiDriver ( const QString& sMidiDriver )
320    {
321            const QString sDriverName = sMidiDriver.upper();
322            
323            MidiDeviceComboBox->clear();
324            m_audioDevices.clear();
325    
326            const QPixmap& midiPixmap = QPixmap::fromMimeSource("midi2.png");
327            int *piDeviceIDs = qsamplerDevice::getDevices(m_pChannel->client(),
328                    qsamplerDevice::Midi);
329            for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {
330                    qsamplerDevice *pDevice = new qsamplerDevice(m_pChannel->client(),
331                            qsamplerDevice::Midi, piDeviceIDs[i]);
332                    if (pDevice->driverName().upper() == sDriverName) {
333                            MidiDeviceComboBox->insertItem(midiPixmap, pDevice->deviceName());
334                            m_midiDevices.append(pDevice);
335                    } else {
336                            delete pDevice;
337                    }
338            }
339    
340            bool bEnabled = !m_midiDevices.isEmpty();
341            if (!bEnabled)
342                    MidiDeviceComboBox->insertItem(tr("(New MIDI device)"));
343            MidiDeviceTextLabel->setEnabled(bEnabled);
344            MidiDeviceComboBox->setEnabled(bEnabled);
345            optionsChanged();
346    }
347    
348    
349    // Select MIDI device options.
350    void qsamplerChannelForm::selectMidiDevice ( int iMidiItem )
351    {
352            qsamplerDevice *pDevice = m_midiDevices.at(iMidiItem);
353            if (pDevice) {
354                    const qsamplerDeviceParamMap& params = pDevice->params();
355                    int iPorts = params["PORTS"].value.toInt();
356                    MidiPortTextLabel->setEnabled(iPorts > 0);
357                    MidiPortSpinBox->setEnabled(iPorts > 0);
358                    if (iPorts > 0)
359                            MidiPortSpinBox->setMaxValue(iPorts - 1);
360            }
361            optionsChanged();
362    }
363    
364    
365    // Refresh Audio device options.
366    void qsamplerChannelForm::selectAudioDriver ( const QString& sAudioDriver )
367    {
368            const QString sDriverName = sAudioDriver.upper();
369    
370            AudioDeviceComboBox->clear();
371            m_audioDevices.clear();
372    
373            const QPixmap& audioPixmap = QPixmap::fromMimeSource("audio2.png");
374            int *piDeviceIDs = qsamplerDevice::getDevices(m_pChannel->client(),
375                    qsamplerDevice::Audio);
376            for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {
377                    qsamplerDevice *pDevice = new qsamplerDevice(m_pChannel->client(),
378                            qsamplerDevice::Audio, piDeviceIDs[i]);
379                    if (pDevice->driverName().upper() == sDriverName) {
380                            AudioDeviceComboBox->insertItem(audioPixmap, pDevice->deviceName());
381                            m_audioDevices.append(pDevice);
382                    } else {
383                            delete pDevice;
384                    }
385            }
386    
387            bool bEnabled = !m_audioDevices.isEmpty();
388            if (!bEnabled)
389                    AudioDeviceComboBox->insertItem(tr("(New Audio device)"));
390            AudioDeviceTextLabel->setEnabled(bEnabled);
391            AudioDeviceComboBox->setEnabled(bEnabled);
392            optionsChanged();
393    }
394    
395    
396    // Select Audio device options.
397    void qsamplerChannelForm::selectAudioDevice ( int iAudioItem )
398    {
399            qsamplerDevice *pDevice = m_audioDevices.at(iAudioItem);
400            if (pDevice) {
401                    // Is there anything to do here?
402            }
403            optionsChanged();
404    }
405    
406    
407  // Dirty up settings.  // Dirty up settings.
408  void qsamplerChannelForm::optionsChanged (void)  void qsamplerChannelForm::optionsChanged (void)

Legend:
Removed from v.295  
changed lines
  Added in v.462

  ViewVC Help
Powered by ViewVC