// Bank change slot. void patchesDialog::bankChanged (void) { if (m_pSynth == NULL) return; QTreeWidgetItem *pBankItem = m_bankListView->currentItem(); if (pBankItem == NULL) return; int iBankSelected = pBankItem->text(0).toInt(); // Clear up the program listview. m_progListView->setSortingEnabled(false); m_progListView->clear(); QTreeWidgetItem *pProgItem = NULL; // For all soundfonts (in reversed stack order) fill the available programs... int cSoundFonts = ::fluid_synth_sfcount(m_pSynth); for (int i = 0; i < cSoundFonts && !pProgItem; i++) { fluid_sfont_t *pSoundFont = ::fluid_synth_get_sfont(m_pSynth, i); if (pSoundFont) { #ifdef CONFIG_FLUID_BANK_OFFSET int iBankOffset = ::fluid_synth_get_bank_offset(m_pSynth, fluid_sfont_get_id(pSoundFont)); #endif fluid_sfont_iteration_start(pSoundFont); #if FLUIDSYNTH_VERSION_MAJOR < 2 fluid_preset_t preset; fluid_preset_t *pCurPreset = &preset; #else fluid_preset_t *pCurPreset; #endif while ((pCurPreset = fluid_sfont_iteration_next_wrapper(pSoundFont, pCurPreset))) { int iBank = fluid_preset_get_banknum(pCurPreset); #ifdef CONFIG_FLUID_BANK_OFFSET iBank += iBankOffset; #endif int iProg = fluid_preset_get_num(pCurPreset); if (iBank == iBankSelected && !findProgItem(iProg)) { pProgItem = new patchItem(m_progListView, pProgItem); if (pProgItem) { pProgItem->setText(0, QString::number(iProg)); pProgItem->setText(1, fluid_preset_get_name(pCurPreset)); //pProgItem->setText(2, QString::number(fluid_sfont_get_id(pSoundFont))); //pProgItem->setText(3, QFileInfo( // fluid_sfont_get_name(pSoundFont).baseName()); } } } } } m_progListView->setSortingEnabled(true); // Stabilize the form. stabilizeForm(); }
// Dialog setup loader. void patchesDialog::setup ( fluid_synth_t * pSynth, int iChan, const QString & _chanName, lcdSpinBoxModel * _bankModel, lcdSpinBoxModel * _progModel, QLabel * _patchLabel ) { // We'll going to changes the whole thing... m_dirty = 0; m_bankModel = _bankModel; m_progModel = _progModel; m_patchLabel = _patchLabel; // Set the proper caption... setWindowTitle( _chanName + " - Soundfont patches" ); // set m_pSynth to NULL so we don't trigger any progChanged events m_pSynth = NULL; // Load bank list from actual synth stack... m_bankListView->setSortingEnabled(false); m_bankListView->clear(); // now it should be safe to set internal stuff m_pSynth = pSynth; m_iChan = iChan; fluid_preset_t preset; QTreeWidgetItem *pBankItem = NULL; // For all soundfonts (in reversed stack order) fill the available banks... int cSoundFonts = ::fluid_synth_sfcount(m_pSynth); for (int i = 0; i < cSoundFonts; i++) { fluid_sfont_t *pSoundFont = ::fluid_synth_get_sfont(m_pSynth, i); if (pSoundFont) { #ifdef CONFIG_FLUID_BANK_OFFSET int iBankOffset = ::fluid_synth_get_bank_offset(m_pSynth, pSoundFont->id); #endif pSoundFont->iteration_start(pSoundFont); while (pSoundFont->iteration_next(pSoundFont, &preset)) { int iBank = preset.get_banknum(&preset); #ifdef CONFIG_FLUID_BANK_OFFSET iBank += iBankOffset; #endif if (!findBankItem(iBank)) { pBankItem = new patchItem(m_bankListView, pBankItem); if (pBankItem) pBankItem->setText(0, QString::number(iBank)); } } } } m_bankListView->setSortingEnabled(true); // Set the selected bank. m_iBank = 0; fluid_preset_t *pPreset = ::fluid_synth_get_channel_preset(m_pSynth, m_iChan); if (pPreset) { m_iBank = pPreset->get_banknum(pPreset); #ifdef CONFIG_FLUID_BANK_OFFSET m_iBank += ::fluid_synth_get_bank_offset(m_pSynth, (pPreset->sfont)->id); #endif } pBankItem = findBankItem(m_iBank); m_bankListView->setCurrentItem(pBankItem); m_bankListView->scrollToItem(pBankItem); bankChanged(); // Set the selected program. if (pPreset) m_iProg = pPreset->get_num(pPreset); QTreeWidgetItem *pProgItem = findProgItem(m_iProg); m_progListView->setCurrentItem(pProgItem); m_progListView->scrollToItem(pProgItem); // Done with setup... //m_iDirtySetup--; }