/[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 115 by capela, Mon Jun 7 21:41:43 2004 UTC revision 758 by capela, Sun Aug 28 00:31:34 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 20  Line 20 
20    
21  *****************************************************************************/  *****************************************************************************/
22    
23    #include "qsamplerAbout.h"
24    #include "qsamplerDeviceForm.h"
25    
26  #include <qvalidator.h>  #include <qvalidator.h>
27  #include <qmessagebox.h>  #include <qmessagebox.h>
28  #include <qfiledialog.h>  #include <qfiledialog.h>
29  #include <qfileinfo.h>  #include <qfileinfo.h>
30  #include <qlistbox.h>  #include <qlistbox.h>
31    
 #include "qsamplerOptions.h"  
 #include "qsamplerChannelStrip.h"  
   
 #include "config.h"  
   
32    
33  // Kind of constructor.  // Kind of constructor.
34  void qsamplerChannelForm::init (void)  void qsamplerChannelForm::init (void)
35  {  {
36      // Initialize locals.          // Initialize locals.
37      m_pChannel = NULL;          m_pChannel = NULL;
38    
39            m_iDirtySetup = 0;
40            m_iDirtyCount = 0;
41    
42      m_iDirtySetup = 0;          m_midiDevices.setAutoDelete(true);
43      m_iDirtyCount = 0;          m_audioDevices.setAutoDelete(true);
44    
45      // Try to restore normal window positioning.          m_pDeviceForm = NULL;
46      adjustSize();  
47            // Try to restore normal window positioning.
48            adjustSize();
49  }  }
50    
51    
52  // Kind of destructor.  // Kind of destructor.
53  void qsamplerChannelForm::destroy (void)  void qsamplerChannelForm::destroy (void)
54  {  {
55            if (m_pDeviceForm)
56                    delete m_pDeviceForm;
57            m_pDeviceForm = NULL;
58  }  }
59    
60    
61  // Channel dialog setup formal initializer.  // Channel dialog setup formal initializer.
62  void qsamplerChannelForm::setup ( qsamplerChannelStrip *pChannel )  void qsamplerChannelForm::setup ( qsamplerChannel *pChannel )
63  {  {
64      m_pChannel = pChannel;          m_pChannel = pChannel;
65    
66            m_iDirtySetup = 0;
67            m_iDirtyCount = 0;
68    
69      m_iDirtySetup = 0;          if (m_pChannel == NULL)
70      m_iDirtyCount = 0;                  return;
71    
72      if (m_pChannel == NULL)          // It can be a brand new channel, remember?
73          return;          bool bNew = (m_pChannel->channelID() < 0);
74            setCaption(QSAMPLER_TITLE ": " + m_pChannel->channelName());
75      setCaption(m_pChannel->caption());  
76            // Check if we're up and connected.
77      // Check if we're up and connected.          if (m_pChannel->client() == NULL)
78      if (m_pChannel->client() == NULL)                  return;
79          return;  
80            qsamplerOptions *pOptions = m_pChannel->options();
81      qsamplerOptions *pOptions = m_pChannel->options();          if (pOptions == NULL)
82      if (pOptions == NULL)                  return;
83          return;  
84            // Avoid nested changes.
85      // Avoid nested changes.          m_iDirtySetup++;
86      m_iDirtySetup++;  
87            // Load combo box history...
88      // Load combo box history...          pOptions->loadComboBoxHistory(InstrumentFileComboBox);
89      pOptions->loadComboBoxHistory(InstrumentFileComboBox);  
90            // Notify.that we've just changed one audio route.
91      // Populate Engines list.          QObject::connect(AudioRoutingTable, SIGNAL(valueChanged(int,int)),
92      const char **ppszEngines = ::lscp_get_available_engines(m_pChannel->client());                  this, SLOT(changeAudioRouting(int,int)));
93      if (ppszEngines) {  
94          EngineNameComboBox->clear();          // Populate Engines list.
95          for (int iEngine = 0; ppszEngines[iEngine]; iEngine++)          const char **ppszEngines = ::lscp_list_available_engines(m_pChannel->client());
96              EngineNameComboBox->insertItem(ppszEngines[iEngine]);          if (ppszEngines) {
97      }                  EngineNameComboBox->clear();
98      else m_pChannel->appendMessagesClient("lscp_get_available_engines");                  for (int iEngine = 0; ppszEngines[iEngine]; iEngine++)
99  /*                          EngineNameComboBox->insertItem(ppszEngines[iEngine]);
100      // Populate Audio output type list.          }
101      const char **ppszAudioDrivers = ::lscp_get_available_audio_drivers(m_pChannel->client());          else m_pChannel->appendMessagesClient("lscp_list_available_engines");
102      if (ppszAudioDrivers) {  
103          AudioDriverComboBox->clear();          // Populate Audio output type list.
104          for (int iAudioDriver = 0; ppszAudioDrivers[iAudioDriver]; iAudioDriver++)          AudioDriverComboBox->clear();
105              AudioDriverComboBox->insertItem(ppszAudioDrivers[iAudioDriver]);          AudioDriverComboBox->insertStringList(
106      }                  qsamplerDevice::getDrivers(m_pChannel->client(), qsamplerDevice::Audio));
107      else m_pChannel->appendMessagesClient("lscp_get_available_audio_drivers");  
108            // Populate MIDI input type list.
109      // Populate MIDI input type list.          MidiDriverComboBox->clear();
110      const char **ppszMidiDrivers = ::lscp_get_available_midi_drivers(m_pChannel->client());          MidiDriverComboBox->insertStringList(
111      if (ppszMidiDrivers) {                  qsamplerDevice::getDrivers(m_pChannel->client(), qsamplerDevice::Midi));
112          MidiDriverComboBox->clear();  
113          for (int iMidiDriver = 0; ppszMidiDrivers[iMidiDriver]; iMidiDriver++)          // Read proper channel information,
114              MidiDriverComboBox->insertItem(ppszMidiDrivers[iMidiDriver]);          // and populate the channel form fields.
115      }  
116      else m_pChannel->appendMessagesClient("lscp_get_available_midi_drivers");          // Engine name...
117  */          QString sEngineName = pChannel->engineName();
118      // Read proper channel information,          if (sEngineName.isEmpty() || bNew)
119      // and populate the channel form fields.                  sEngineName = pOptions->sEngineName;
120            if (sEngineName.isEmpty())
121      // Engine name...                  sEngineName = qsamplerChannel::noEngineName();
122      const QString& sEngineName = pChannel->engineName();          if (EngineNameComboBox->listBox()->findItem(sEngineName,
123      if (!sEngineName.isEmpty()) {                          Qt::ExactMatch | Qt::CaseSensitive) == NULL) {
124          if (EngineNameComboBox->listBox()->findItem(sEngineName, Qt::ExactMatch) == NULL)                  EngineNameComboBox->insertItem(sEngineName);
125              EngineNameComboBox->insertItem(sEngineName);          }
126          EngineNameComboBox->setCurrentText(sEngineName);          EngineNameComboBox->setCurrentText(sEngineName);
127      }          // Instrument filename and index...
128      // Instrument filename and index...          QString sInstrumentFile = pChannel->instrumentFile();
129      InstrumentFileComboBox->setCurrentText(pChannel->instrumentFile());          if (sInstrumentFile.isEmpty())
130      InstrumentNrSpinBox->setValue(pChannel->instrumentNr());                  sInstrumentFile = qsamplerChannel::noInstrumentName();
131      // MIDI input...          InstrumentFileComboBox->setCurrentText(sInstrumentFile);
132      const QString& sMidiDriver = pChannel->midiDriver();          InstrumentNrComboBox->clear();
133      if (!sMidiDriver.isEmpty()) {          InstrumentNrComboBox->insertStringList(
134          if (MidiDriverComboBox->listBox()->findItem(sMidiDriver, Qt::ExactMatch) == NULL)                  qsamplerChannel::getInstrumentList(sInstrumentFile,
135              MidiDriverComboBox->insertItem(sMidiDriver);                  pOptions->bInstrumentNames));
136          MidiDriverComboBox->setCurrentText(sMidiDriver);          InstrumentNrComboBox->setCurrentItem(pChannel->instrumentNr());
137      }  
138      MidiPortSpinBox->setValue(pChannel->midiPort());          // MIDI input device...
139      MidiChannelSpinBox->setValue(pChannel->midiChannel());          qsamplerDevice midiDevice(m_pChannel->mainForm(),
140      // Audio output...                  qsamplerDevice::Midi, m_pChannel->midiDevice());
141      const QString& sAudioDriver = pChannel->audioDriver();          // MIDI input driver...
142      if (!sAudioDriver.isEmpty()) {          QString sMidiDriver = midiDevice.driverName();
143          if (AudioDriverComboBox->listBox()->findItem(sAudioDriver, Qt::ExactMatch) == NULL)          if (sMidiDriver.isEmpty() || bNew)
144              AudioDriverComboBox->insertItem(sAudioDriver);                  sMidiDriver = pOptions->sMidiDriver.upper();
145          AudioDriverComboBox->setCurrentText(sAudioDriver);          if (!sMidiDriver.isEmpty()) {
146      }                  if (MidiDriverComboBox->listBox()->findItem(sMidiDriver,
147      // FIXME: Disable this while we don't know what to do.                                  Qt::ExactMatch | Qt::CaseSensitive) == NULL) {
148      MidiPortTextLabel->setEnabled(false);                          MidiDriverComboBox->insertItem(sMidiDriver);
149      MidiPortSpinBox->setEnabled(false);                  }
150      // Done.                  MidiDriverComboBox->setCurrentText(sMidiDriver);
151      m_iDirtySetup--;          }
152      stabilizeForm();          selectMidiDriverItem(sMidiDriver);
153            if (!bNew)
154                    MidiDeviceComboBox->setCurrentText(midiDevice.deviceName());
155            selectMidiDeviceItem(MidiDeviceComboBox->currentItem());
156            // MIDI input port...
157            MidiPortSpinBox->setValue(pChannel->midiPort());
158            // MIDI input channel...
159            int iMidiChannel = pChannel->midiChannel();
160            // When new, try to suggest a sensible MIDI channel...
161            if (iMidiChannel < 0)
162                    iMidiChannel = (::lscp_get_channels(m_pChannel->client()) % 16);
163            MidiChannelComboBox->setCurrentItem(iMidiChannel);
164    
165            // Audio output device...
166            qsamplerDevice audioDevice(m_pChannel->mainForm(),
167                    qsamplerDevice::Audio, m_pChannel->audioDevice());
168            // Audio output driver...
169            QString sAudioDriver = audioDevice.driverName();
170            if (sAudioDriver.isEmpty() || bNew)
171                    sAudioDriver = pOptions->sAudioDriver.upper();
172            if (!sAudioDriver.isEmpty()) {
173                    if (AudioDriverComboBox->listBox()->findItem(sAudioDriver,
174                                    Qt::ExactMatch | Qt::CaseSensitive) == NULL) {
175                            AudioDriverComboBox->insertItem(sAudioDriver);
176                    }
177                    AudioDriverComboBox->setCurrentText(sAudioDriver);
178            }
179            selectAudioDriverItem(sAudioDriver);
180            if (!bNew)
181                    AudioDeviceComboBox->setCurrentText(audioDevice.deviceName());
182            selectAudioDeviceItem(AudioDeviceComboBox->currentItem());
183    
184            // As convenient, make it ready on stabilizeForm() for
185            // prompt acceptance, if we got the minimum required...
186            if (sEngineName != qsamplerChannel::noEngineName() &&
187                    sInstrumentFile != qsamplerChannel::noInstrumentName())
188                    m_iDirtyCount++;
189            // Done.
190            m_iDirtySetup--;
191            stabilizeForm();
192  }  }
193    
194    
195  // Accept settings (OK button slot).  // Accept settings (OK button slot).
196  void qsamplerChannelForm::accept (void)  void qsamplerChannelForm::accept (void)
197  {  {
198      if (m_pChannel == NULL)          if (m_pChannel == NULL)
199          return;                  return;
200    
201      qsamplerOptions *pOptions = m_pChannel->options();          qsamplerOptions *pOptions = m_pChannel->options();
202      if (pOptions == NULL)          if (pOptions == NULL)
203          return;                  return;
204    
205      // We'll go for it!          // We'll go for it!
206      if (m_iDirtyCount > 0) {          if (m_iDirtyCount > 0) {
207          int iErrors = 0;                  int iErrors = 0;
208          // Audio output driver type...                  // Are we a new channel?
209          if (!m_pChannel->setAudioDriver(AudioDriverComboBox->currentText()))                  if (!m_pChannel->addChannel())
210              iErrors++;                          iErrors++;
211          // MIDI input driver type...                  // Accept Audio driver or device selection...
212          if (!m_pChannel->setMidiDriver(MidiDriverComboBox->currentText()))                  if (m_audioDevices.isEmpty()) {
213              iErrors++;                          if (!m_pChannel->setAudioDriver(AudioDriverComboBox->currentText()))
214          // MIDI input port number...                                  iErrors++;
215          if (!m_pChannel->setMidiPort(MidiPortSpinBox->value()))                  } else {
216              iErrors++;                          qsamplerDevice *pDevice = m_audioDevices.at(AudioDeviceComboBox->currentItem());
217          // MIDI input channel...                          if (pDevice == NULL)
218          if (!m_pChannel->setMidiChannel(MidiChannelSpinBox->value()))                                  iErrors++;
219              iErrors++;                          else if (!m_pChannel->setAudioDevice(pDevice->deviceID()))
220          // Engine name...                                  iErrors++;
221          if (!m_pChannel->loadEngine(EngineNameComboBox->currentText()))                          else if (!m_audioRouting.isEmpty()) {
222              iErrors++;                                  // Set the audio route changes...
223          // Instrument file and index...                                  qsamplerChannelRoutingMap::ConstIterator iter;
224          if (!m_pChannel->loadInstrument(InstrumentFileComboBox->currentText(), InstrumentNrSpinBox->value()))                                  for (iter = m_audioRouting.begin();
225              iErrors++;                                                  iter != m_audioRouting.end(); ++iter) {
226          // Show error messages?                                          if (!m_pChannel->setAudioChannel(iter.key(), iter.data()))
227          if (iErrors > 0)                                                  iErrors++;
228              m_pChannel->appendMessagesError(tr("Some channel settings could not be set.\n\nSorry."));                                  }
229      }                          }
230                    }
231      // Save default instrument directory and history...                  // Accept MIDI driver or device selection...
232      pOptions->sInstrumentDir = QFileInfo(InstrumentFileComboBox->currentText()).dirPath(true);                  if (m_midiDevices.isEmpty()) {
233      pOptions->saveComboBoxHistory(InstrumentFileComboBox);                          if (!m_pChannel->setMidiDriver(MidiDriverComboBox->currentText()))
234                                    iErrors++;
235                    } else {
236                            qsamplerDevice *pDevice = m_midiDevices.at(MidiDeviceComboBox->currentItem());
237                            if (pDevice == NULL)
238                                    iErrors++;
239                            else if (!m_pChannel->setMidiDevice(pDevice->deviceID()))
240                                    iErrors++;
241                    }
242                    // MIDI input port number...
243                    if (!m_pChannel->setMidiPort(MidiPortSpinBox->value()))
244                            iErrors++;
245                    // MIDI input channel...
246                    if (!m_pChannel->setMidiChannel(MidiChannelComboBox->currentItem()))
247                            iErrors++;
248                    // Engine name...
249                    if (!m_pChannel->loadEngine(EngineNameComboBox->currentText()))
250                            iErrors++;
251                    // Instrument file and index...
252                    if (!m_pChannel->loadInstrument(InstrumentFileComboBox->currentText(), InstrumentNrComboBox->currentItem()))
253                            iErrors++;
254                    // Show error messages?
255                    if (iErrors > 0)
256                            m_pChannel->appendMessagesError(tr("Some channel settings could not be set.\n\nSorry."));
257            }
258    
259            // Save default engine name, instrument directory and history...
260            pOptions->sInstrumentDir = QFileInfo(InstrumentFileComboBox->currentText()).dirPath(true);
261            pOptions->sEngineName  = EngineNameComboBox->currentText();
262            pOptions->sAudioDriver = AudioDriverComboBox->currentText();
263            pOptions->sMidiDriver  = MidiDriverComboBox->currentText();
264            pOptions->saveComboBoxHistory(InstrumentFileComboBox);
265    
266      // Just go with dialog acceptance.          // Just go with dialog acceptance.
267      QDialog::accept();          QDialog::accept();
268  }  }
269    
270    
271  // Reject settings (Cancel button slot).  // Reject settings (Cancel button slot).
272  void qsamplerChannelForm::reject (void)  void qsamplerChannelForm::reject (void)
273  {  {
274      bool bReject = true;          bool bReject = true;
275    
276      // Check if there's any pending changes...          // Check if there's any pending changes...
277      if (m_iDirtyCount > 0) {          if (m_iDirtyCount > 0 && OkPushButton->isEnabled()) {
278          switch (QMessageBox::warning(this, tr("Warning"),                  switch (QMessageBox::warning(this,
279              tr("Some channel settings have been changed.\n\n"                          QSAMPLER_TITLE ": " + tr("Warning"),
280                 "Do you want to apply the changes?"),                          tr("Some channel settings have been changed.\n\n"
281              tr("Apply"), tr("Discard"), tr("Cancel"))) {                          "Do you want to apply the changes?"),
282          case 0:     // Apply...                          tr("Apply"), tr("Discard"), tr("Cancel"))) {
283              accept();                  case 0:     // Apply...
284              return;                          accept();
285          case 1:     // Discard                          return;
286              break;                  case 1:     // Discard
287          default:    // Cancel.                          break;
288              bReject = false;                  default:    // Cancel.
289          }                          bReject = false;
290      }                  }
291            }
292    
293      if (bReject)          if (bReject)
294          QDialog::reject();                  QDialog::reject();
295  }  }
296    
297    
298  // Browse and open an instrument file.  // Browse and open an instrument file.
299  void qsamplerChannelForm::openInstrumentFile (void)  void qsamplerChannelForm::openInstrumentFile (void)
300  {  {
301      qsamplerOptions *pOptions = m_pChannel->options();          qsamplerOptions *pOptions = m_pChannel->options();
302      if (pOptions == NULL)          if (pOptions == NULL)
303          return;                  return;
304    
305      // FIXME: the instrument file filters should be restricted,          // FIXME: the instrument file filters should be restricted,
306      // depending on the current engine.          // depending on the current engine.
307      QString sInstrumentFile = QFileDialog::getOpenFileName(          QString sInstrumentFile = QFileDialog::getOpenFileName(
308              pOptions->sInstrumentDir,                   // Start here.                  pOptions->sInstrumentDir,                   // Start here.
309              tr("Instrument files") + " (*.gig *.dls)",  // Filter (GIG and DLS files)                  tr("Instrument files") + " (*.gig *.dls)",  // Filter (GIG and DLS files)
310              this, 0,                                    // Parent and name (none)                  this, 0,                                    // Parent and name (none)
311              tr("Instrument files")                      // Caption.                  QSAMPLER_TITLE ": " + tr("Instrument files")    // Caption.
312      );          );
313    
314      if (sInstrumentFile.isEmpty())          if (sInstrumentFile.isEmpty())
315          return;                  return;
316    
317      InstrumentFileComboBox->setCurrentText(sInstrumentFile);          InstrumentFileComboBox->setCurrentText(sInstrumentFile);
318            updateInstrumentName();
319  }  }
320    
321    
322  // Refresh the actual instrument name.  // Refresh the actual instrument name.
323  void qsamplerChannelForm::updateInstrumentName (void)  void qsamplerChannelForm::updateInstrumentName (void)
324  {  {
325      // FIXME: A better idea would be to use libgig          qsamplerOptions *pOptions = m_pChannel->options();
326      // to retrieve the REAL instrument name.          if (pOptions == NULL)
327      InstrumentNameTextLabel->setText(QFileInfo(InstrumentFileComboBox->currentText()).fileName()                  return;
328          + " [" + QString::number(InstrumentNrSpinBox->value()) + "]");  
329            // Finally this better idea would be to use libgig
330            // to retrieve the REAL instrument names.
331            InstrumentNrComboBox->clear();
332            InstrumentNrComboBox->insertStringList(
333                    qsamplerChannel::getInstrumentList(
334                            InstrumentFileComboBox->currentText(),
335                            pOptions->bInstrumentNames)
336            );
337    
338            optionsChanged();
339    }
340    
341    // Show device options dialog.
342    void qsamplerChannelForm::setupDevice ( qsamplerDevice *pDevice,
343            qsamplerDevice::qsamplerDeviceType deviceTypeMode,
344            const QString& sDriverName )
345    {
346            // Create the device form if not already...
347            if (m_pDeviceForm == NULL) {
348                    m_pDeviceForm = new qsamplerDeviceForm(this, 0,
349                            WType_Dialog | WShowModal);
350                    m_pDeviceForm->setMainForm(m_pChannel->mainForm());
351                    QObject::connect(m_pDeviceForm, SIGNAL(devicesChanged()),
352                            this, SLOT(updateDevices()));
353            }
354    
355            // Refresh the device form with selected data.
356            if (m_pDeviceForm) {
357                    m_pDeviceForm->setDeviceTypeMode(deviceTypeMode);
358                    m_pDeviceForm->setClient(m_pChannel->client()); // -> refreshDevices();
359                    m_pDeviceForm->setDevice(pDevice);
360                    m_pDeviceForm->setDriverName(sDriverName);
361                    m_pDeviceForm->show();
362            }
363    }
364    
365    
366    // Refresh MIDI driver item devices.
367    void qsamplerChannelForm::selectMidiDriverItem ( const QString& sMidiDriver )
368    {
369            const QString sDriverName = sMidiDriver.upper();
370    
371            // Save current device id.
372            int iDeviceID = -1;
373            qsamplerDevice *pDevice = m_midiDevices.at(MidiDeviceComboBox->currentItem());
374            if (pDevice)
375                    iDeviceID = pDevice->deviceID();
376    
377            // Clean maplist.
378            MidiDeviceComboBox->clear();
379            m_midiDevices.clear();
380    
381            // Populate with the current ones...
382            const QPixmap& midiPixmap = QPixmap::fromMimeSource("midi2.png");
383            int *piDeviceIDs = qsamplerDevice::getDevices(m_pChannel->client(),
384                    qsamplerDevice::Midi);
385            for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {
386                    pDevice = new qsamplerDevice(m_pChannel->mainForm(),
387                            qsamplerDevice::Midi, piDeviceIDs[i]);
388                    if (pDevice->driverName().upper() == sDriverName) {
389                            MidiDeviceComboBox->insertItem(midiPixmap, pDevice->deviceName());
390                            m_midiDevices.append(pDevice);
391                    } else {
392                            delete pDevice;
393                    }
394            }
395    
396            // Do proper enabling...
397            bool bEnabled = !m_midiDevices.isEmpty();
398            if (!bEnabled) {
399                    MidiDeviceComboBox->insertItem(
400                            tr("(New MIDI %1 device)").arg(sMidiDriver));
401            } else if (iDeviceID >= 0) {
402                    // Select the previous current device...
403                    int iMidiItem = 0;
404                    for (pDevice = m_midiDevices.first();
405                                    pDevice;
406                                            pDevice = m_midiDevices.next()) {
407                            if (pDevice->deviceID() == iDeviceID) {
408                                    MidiDeviceComboBox->setCurrentItem(iMidiItem);
409                                    selectMidiDeviceItem(iMidiItem);
410                                    break;
411                            }
412                            iMidiItem++;
413                    }
414            }
415            MidiDeviceTextLabel->setEnabled(bEnabled);
416            MidiDeviceComboBox->setEnabled(bEnabled);
417    }
418    
419    
420    // Refresh MIDI device options slot.
421    void qsamplerChannelForm::selectMidiDriver ( const QString& sMidiDriver )
422    {
423            if (m_iDirtySetup > 0)
424                    return;
425    
426            selectMidiDriverItem(sMidiDriver);
427            optionsChanged();
428    }
429    
430    
431    // Select MIDI device item.
432    void qsamplerChannelForm::selectMidiDeviceItem ( int iMidiItem )
433    {
434            qsamplerDevice *pDevice = m_midiDevices.at(iMidiItem);
435            if (pDevice) {
436                    const qsamplerDeviceParamMap& params = pDevice->params();
437                    int iPorts = params["PORTS"].value.toInt();
438                    MidiPortTextLabel->setEnabled(iPorts > 0);
439                    MidiPortSpinBox->setEnabled(iPorts > 0);
440                    if (iPorts > 0)
441                            MidiPortSpinBox->setMaxValue(iPorts - 1);
442            }
443    }
444    
445    
446    // Select MIDI device options slot.
447    void qsamplerChannelForm::selectMidiDevice ( int iMidiItem )
448    {
449            if (m_iDirtySetup > 0)
450                    return;
451    
452            selectMidiDeviceItem(iMidiItem);
453            optionsChanged();
454    }
455    
456    
457    // MIDI device options.
458    void qsamplerChannelForm::setupMidiDevice (void)
459    {
460            setupDevice(m_midiDevices.at(MidiDeviceComboBox->currentItem()),
461                    qsamplerDevice::Midi, MidiDriverComboBox->currentText());
462    }
463    
464    
465    // Refresh Audio driver item devices.
466    void qsamplerChannelForm::selectAudioDriverItem ( const QString& sAudioDriver )
467    {
468            const QString sDriverName = sAudioDriver.upper();
469    
470            // Save current device id.
471            int iDeviceID = -1;
472            qsamplerDevice *pDevice = m_audioDevices.at(AudioDeviceComboBox->currentItem());
473            if (pDevice)
474                    iDeviceID = pDevice->deviceID();
475    
476            // Clean maplist.
477            AudioDeviceComboBox->clear();
478            m_audioDevices.clear();
479    
480            // Populate with the current ones...
481            const QPixmap& audioPixmap = QPixmap::fromMimeSource("audio2.png");
482            int *piDeviceIDs = qsamplerDevice::getDevices(m_pChannel->client(),
483                    qsamplerDevice::Audio);
484            for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {
485                    pDevice = new qsamplerDevice(m_pChannel->mainForm(),
486                            qsamplerDevice::Audio, piDeviceIDs[i]);
487                    if (pDevice->driverName().upper() == sDriverName) {
488                            AudioDeviceComboBox->insertItem(audioPixmap, pDevice->deviceName());
489                            m_audioDevices.append(pDevice);
490                    } else {
491                            delete pDevice;
492                    }
493            }
494    
495            // Do proper enabling...
496            bool bEnabled = !m_audioDevices.isEmpty();
497            if (!bEnabled) {
498                    AudioDeviceComboBox->insertItem(
499                            tr("(New Audio %1 device)").arg(sAudioDriver));
500            } else if (iDeviceID >= 0) {
501                    // Select the previous current device...
502                    int iAudioItem = 0;
503                    for (pDevice = m_audioDevices.first();
504                                    pDevice;
505                                            pDevice = m_audioDevices.next()) {
506                            if (pDevice->deviceID() == iDeviceID) {
507                                    AudioDeviceComboBox->setCurrentItem(iAudioItem);
508                                    selectAudioDeviceItem(iAudioItem);
509                                    break;
510                            }
511                            iAudioItem++;
512                    }
513            }
514            AudioDeviceTextLabel->setEnabled(bEnabled);
515            AudioDeviceComboBox->setEnabled(bEnabled);
516            AudioRoutingTable->setEnabled(bEnabled);
517            if (!bEnabled)
518                    AudioRoutingTable->setNumRows(0);
519    }
520    
521    
522    // Refresh Audio device options slot.
523    void qsamplerChannelForm::selectAudioDriver ( const QString& sAudioDriver )
524    {
525            if (m_iDirtySetup > 0)
526                    return;
527    
528            selectAudioDriverItem(sAudioDriver);
529            optionsChanged();
530    }
531    
532    
533    // Select Audio device item.
534    void qsamplerChannelForm::selectAudioDeviceItem ( int iAudioItem )
535    {
536            qsamplerDevice *pDevice = m_audioDevices.at(iAudioItem);
537            if (pDevice) {
538                    // Refresh the audio routing table.
539                    AudioRoutingTable->refresh(pDevice, m_pChannel->audioRouting());
540                    // Reset routing change map.
541                    m_audioRouting.clear();
542            }
543    }
544    
545    
546    // Select Audio device options slot.
547    void qsamplerChannelForm::selectAudioDevice ( int iAudioItem )
548    {
549            if (m_iDirtySetup > 0)
550                    return;
551    
552            selectAudioDeviceItem(iAudioItem);
553            optionsChanged();
554    }
555    
556    
557    // Audio device options.
558    void qsamplerChannelForm::setupAudioDevice (void)
559    {
560            setupDevice(m_audioDevices.at(AudioDeviceComboBox->currentItem()),
561                    qsamplerDevice::Audio, AudioDriverComboBox->currentText());
562    }
563    
564    
565      optionsChanged();  // Audio routing change slot.
566    void qsamplerChannelForm::changeAudioRouting ( int iRow, int iCol )
567    {
568            if (m_iDirtySetup > 0)
569                    return;
570            if (iRow < 0 || iCol < 0)
571                    return;
572    
573            // Verify that this is a QComboTableItem (magic rtti == 1)
574            QTableItem *pItem = AudioRoutingTable->item(iRow, iCol);
575            if (pItem == NULL)
576                    return;
577            if (pItem->rtti() == 1) {       // 1 == QComboTableItem
578                    QComboTableItem *pComboItem = (QComboTableItem *) pItem;
579                    // FIXME: Its not garanteed that we must have
580                    // iAudioOut == iRow on all times forth!
581                    m_audioRouting[iRow] = pComboItem->currentItem();
582                    // And let's get dirty...
583                    m_iDirtyCount++;
584            }
585  }  }
586    
587    
588    // UPdate all device lists slot.
589    void qsamplerChannelForm::updateDevices (void)
590    {
591            if (m_iDirtySetup > 0)
592                    return;
593    
594            selectMidiDriverItem(MidiDriverComboBox->currentText());
595            selectAudioDriverItem(AudioDriverComboBox->currentText());
596            optionsChanged();
597    }
598    
599    
600  // Dirty up settings.  // Dirty up settings.
601  void qsamplerChannelForm::optionsChanged (void)  void qsamplerChannelForm::optionsChanged (void)
602  {  {
603      if (m_iDirtySetup > 0)          if (m_iDirtySetup > 0)
604          return;                  return;
605    
606      m_iDirtyCount++;          m_iDirtyCount++;
607      stabilizeForm();          stabilizeForm();
608  }  }
609    
610    
611  // Stabilize current form state.  // Stabilize current form state.
612  void qsamplerChannelForm::stabilizeForm (void)  void qsamplerChannelForm::stabilizeForm (void)
613  {  {
614      const QString sFilename = InstrumentFileComboBox->currentText();          const QString& sFilename = InstrumentFileComboBox->currentText();
615      OkPushButton->setEnabled(m_iDirtyCount > 0 && !sFilename.isEmpty() && QFileInfo(sFilename).exists());          OkPushButton->setEnabled(m_iDirtyCount > 0 && !sFilename.isEmpty() && QFileInfo(sFilename).exists());
616  }  }
617    
618    
619  // end of qsamplerChannelForm.ui.h  // end of qsamplerChannelForm.ui.h
   

Legend:
Removed from v.115  
changed lines
  Added in v.758

  ViewVC Help
Powered by ViewVC