diff --git a/ChangeLog b/ChangeLog index 9db9cee6c..2aa7d0db6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2008-08-01 Tobias Doerffel + * plugins/sf2_player/patches_dialog.cpp: + * plugins/sf2_player/sf2_player.cpp: + * plugins/sf2_player/patches_dialog.h: + * plugins/sf2_player/sf2_player.h: + * data/themes/default/style.css: + - integrated patch by Csaba Hruska + - fixed spinbox-ranges + * plugins/vst_base/CMakeLists.txt: fixed include-directories for lvsl_server-target for allowing out-of-tree builds diff --git a/data/themes/default/style.css b/data/themes/default/style.css index 14dce7b6d..e6215d8ac 100644 --- a/data/themes/default/style.css +++ b/data/themes/default/style.css @@ -85,7 +85,7 @@ trackWidget { /* border-bottom: 1px solid rgb(0, 0, 0);*/ background-color: rgb(0, 0, 0); } -nameLabel, effectLabel > QLabel { +nameLabel, effectLabel, sf2InstrumentView > QLabel { font-size:10px; } diff --git a/plugins/sf2_player/patches_dialog.cpp b/plugins/sf2_player/patches_dialog.cpp index 567f96c47..68675d3b8 100644 --- a/plugins/sf2_player/patches_dialog.cpp +++ b/plugins/sf2_player/patches_dialog.cpp @@ -111,17 +111,21 @@ patchesDialog::~patchesDialog() // Dialog setup loader. -void patchesDialog::setup ( fluid_synth_t *pSynth, int iChan, const QString & _chanName, - lcdSpinBoxModel * _bankModel, lcdSpinBoxModel * _progModel ) +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"); + setWindowTitle( _chanName + " - Soundfont patches" ); // set m_pSynth to NULL so we don't trigger any progChanged events m_pSynth = NULL; @@ -232,8 +236,10 @@ void patchesDialog::accept() setBankProg(iBank, iProg); if (m_dirty > 0) { - m_bankModel->setValue(iBank); - m_progModel->setValue(iProg); + m_bankModel->setValue( iBank ); + m_progModel->setValue( iProg ); + m_patchLabel->setText( m_progListView-> + currentItem()->text( 1 ) ); } // Do remember preview state... diff --git a/plugins/sf2_player/patches_dialog.h b/plugins/sf2_player/patches_dialog.h index a7d191485..a429c90dc 100644 --- a/plugins/sf2_player/patches_dialog.h +++ b/plugins/sf2_player/patches_dialog.h @@ -31,6 +31,7 @@ #include #include +#include //---------------------------------------------------------------------------- // qsynthPresetForm -- UI wrapper form. @@ -49,7 +50,7 @@ public: void setup(fluid_synth_t *pSynth, int iChan, const QString & _chanName, - lcdSpinBoxModel * _bankModel, lcdSpinBoxModel * _progModel ); + lcdSpinBoxModel * _bankModel, lcdSpinBoxModel * _progModel, QLabel *_patchLabel ); public slots: @@ -86,6 +87,7 @@ private: lcdSpinBoxModel * m_bankModel; lcdSpinBoxModel * m_progModel; + QLabel *m_patchLabel; }; diff --git a/plugins/sf2_player/sf2_player.cpp b/plugins/sf2_player/sf2_player.cpp index e78799a7a..cf6e68ba2 100644 --- a/plugins/sf2_player/sf2_player.cpp +++ b/plugins/sf2_player/sf2_player.cpp @@ -76,8 +76,8 @@ sf2Instrument::sf2Instrument( instrumentTrack * _instrument_track ) : m_fontId( 0 ), m_filename( "" ), m_lastMidiPitch( 8192 ), - m_bankNum( -1, -1, 999, this, tr("Bank") ), - m_patchNum( -1, -1, 127, this, tr("Patch") ), + m_bankNum( 0, 0, 999, this, tr("Bank") ), + m_patchNum( 0, 0, 127, this, tr("Patch") ), m_gain( 1.0f, 0.0f, 5.0f, 0.01f, this, tr( "Gain" ) ), m_reverbOn( 0, this, tr( "Reverb" ) ), m_reverbRoomSize( FLUID_REVERB_DEFAULT_ROOMSIZE, 0, 1.0, 0.01f, @@ -362,6 +362,46 @@ void sf2Instrument::updatePatch( void ) +QString sf2Instrument::getCurrentPatchName( void ) +{ + int iBankSelected = m_bankNum.value(); + int iProgSelected = m_patchNum.value(); + + fluid_preset_t preset; + // For all soundfonts (in reversed stack order) fill the available programs... + int cSoundFonts = ::fluid_synth_sfcount( m_synth ); + for( int i = 0; i < cSoundFonts; i++ ) + { + fluid_sfont_t *pSoundFont = fluid_synth_get_sfont( m_synth, i ); + if (pSoundFont) { +#ifdef CONFIG_FLUID_BANK_OFFSET + int iBankOffset = + fluid_synth_get_bank_offset( + m_synth, 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 + int iProg = preset.get_num( &preset ); + if( iBank == iBankSelected && iProg == + iProgSelected ) + { + return preset.get_name( &preset ); + } + } + } + } + return ""; +} + + + + void sf2Instrument::updateGain( void ) { fluid_synth_set_gain( m_synth, m_gain.value() ); @@ -613,6 +653,13 @@ sf2InstrumentView::sf2InstrumentView( instrument * _instrument, // QVBoxLayout * vl = new QVBoxLayout( this ); // QHBoxLayout * hl = new QHBoxLayout(); + sf2Instrument * k = castModel(); + connect( &k->m_bankNum, SIGNAL( dataChanged() ), + this, SLOT( updatePatchName() ) ); + + connect( &k->m_patchNum, SIGNAL( dataChanged() ), + this, SLOT( updatePatchName() ) ); + // File Button m_fileDialogButton = new pixmapButton( this ); m_fileDialogButton->setCursor( QCursor( Qt::PointingHandCursor ) ); @@ -646,12 +693,12 @@ sf2InstrumentView::sf2InstrumentView( instrument * _instrument, // LCDs m_bankNumLcd = new lcdSpinBox( 3, "21pink", this ); m_bankNumLcd->move(131, 62); - m_bankNumLcd->addTextForValue( -1, "---" ); +// m_bankNumLcd->addTextForValue( -1, "---" ); // m_bankNumLcd->setEnabled( FALSE ); m_patchNumLcd = new lcdSpinBox( 3, "21pink", this ); m_patchNumLcd->move(190, 62); - m_patchNumLcd->addTextForValue( -1, "---" ); +// m_patchNumLcd->addTextForValue( -1, "---" ); // m_patchNumLcd->setEnabled( FALSE ); /*hl->addWidget( m_fileDialogButton ); @@ -666,7 +713,9 @@ sf2InstrumentView::sf2InstrumentView( instrument * _instrument, //hl = new QHBoxLayout(); m_filenameLabel = new QLabel( this ); - m_filenameLabel->setGeometry( 56, 109, 156, 11 ); + m_filenameLabel->setGeometry( 58, 109, 156, 11 ); + m_patchLabel = new QLabel( this ); + m_patchLabel->setGeometry( 58, 127, 156, 11 ); //hl->addWidget( m_filenameLabel ); // vl->addLayout( hl ); @@ -817,7 +866,7 @@ void sf2InstrumentView::modelChanged( void ) void sf2InstrumentView::updateFilename( void ) { sf2Instrument * i = castModel(); - QFontMetrics fm( font() ); + QFontMetrics fm( m_filenameLabel->font() ); QString file = i->m_filename.endsWith( ".sf2", Qt::CaseInsensitive ) ? i->m_filename.left( i->m_filename.length() - 4 ) : i->m_filename; @@ -828,6 +877,24 @@ void sf2InstrumentView::updateFilename( void ) m_patchDialogButton->setEnabled( !i->m_filename.isEmpty() ); + updatePatchName(); + + update(); +} + + + + +void sf2InstrumentView::updatePatchName( void ) +{ + sf2Instrument * i = castModel(); + QFontMetrics fm( font() ); + QString patch = i->getCurrentPatchName(); + m_patchLabel->setText( + fm.elidedText( patch, Qt::ElideLeft, + m_patchLabel->width() ) ); + + update(); } @@ -844,7 +911,6 @@ void sf2InstrumentView::invalidateFile( void ) void sf2InstrumentView::showFileDialog( void ) { - printf("CLICKED\n"); sf2Instrument * k = castModel(); QFileDialog ofd( NULL, tr( "Open SoundFont file" ) ); @@ -905,7 +971,7 @@ void sf2InstrumentView::showPatchDialog( void ) } s_patchDialog->setup( k->m_synth, 1, k->getInstrumentTrack()->name(), - &k->m_bankNum, &k->m_patchNum ); + &k->m_bankNum, &k->m_patchNum, m_patchLabel ); s_patchDialog->exec(); } diff --git a/plugins/sf2_player/sf2_player.h b/plugins/sf2_player/sf2_player.h index 6ec498bf9..3bba2a331 100644 --- a/plugins/sf2_player/sf2_player.h +++ b/plugins/sf2_player/sf2_player.h @@ -91,6 +91,8 @@ public: } virtual pluginView * instantiateView( QWidget * _parent ); + + QString getCurrentPatchName(); public slots: @@ -197,6 +199,7 @@ private: lcdSpinBox * m_patchNumLcd; QLabel * m_filenameLabel; + QLabel * m_patchLabel; knob * m_gainKnob; @@ -219,6 +222,7 @@ protected slots: void showFileDialog( void ); void showPatchDialog( void ); void updateFilename( void ); + void updatePatchName( void ); } ;