Changeset 824

Show
Ignore:
Timestamp:
02/21/09 00:05:30 (4 years ago)
Author:
gabriel@…
Message:

Merge rev 580:592 from trunk

Location:
branches/jackMidi/gui/src
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • branches/jackMidi/gui/src/AudioFileBrowser/AudioFileBrowser.cpp

    r822 r824  
    2020 * 
    2121 */ 
    22  
    2322 
    2423#include "AudioFileBrowser.h" 
     
    3433#include <hydrogen/audio_engine.h> 
    3534 
     35#include <QModelIndex> 
    3636#include <QTreeWidget> 
    3737#include <QMessageBox> 
     
    4444                , Object ( "AudioFileBrowser" ) 
    4545{ 
    46  
    4746        setupUi ( this ); 
    4847        INFOLOG ( "INIT" ); 
     
    5049        setFixedSize ( width(), height() ); 
    5150        installEventFilter( this ); 
    52  
    5351 
    5452        model = new QDirModel(); 
     
    6866        tree->setAlternatingRowColors( true ); 
    6967        tree->setRootIndex( model->index( Preferences::getInstance()->__lastsampleDirectory ) ); 
    70  
     68         
    7169        pathLineEdit->setText( Preferences::getInstance()->__lastsampleDirectory ); 
    7270        m_psamplefilename = "";  
    73         m_pselectedFile << "false" << "false" << ""; 
     71        m_pselectedFile << "false" << "false"; 
    7472 
    7573        sEmptySampleFilename = DataPath::get_data_path() + "/emptySample.wav"; 
     
    8280 
    8381        connect( tree, SIGNAL( clicked( const QModelIndex&) ), SLOT( clicked( const QModelIndex& ) ) ); 
    84         connect( pathLineEdit, SIGNAL( returnPressed() ), SLOT( updateModelIndex() ) ); 
    85          
     82        connect( pathLineEdit, SIGNAL( returnPressed() ), SLOT( updateModelIndex() ) );  
    8683} 
    8784 
     
    9491        INFOLOG ( "DESTROY" ); 
    9592} 
     93 
     94 
     95 
     96void AudioFileBrowser::keyPressEvent (QKeyEvent *ev) 
     97{ 
     98        if( ev->modifiers()==Qt::ControlModifier ){ 
     99                tree->setSelectionMode( QAbstractItemView::MultiSelection ); 
     100                openBTN->setEnabled( true ); 
     101        }        
     102} 
     103 
     104 
     105 
     106void AudioFileBrowser::keyReleaseEvent (QKeyEvent *ev) 
     107{ 
     108        tree->setSelectionMode( QAbstractItemView::SingleSelection ); 
     109} 
     110 
    96111 
    97112 
     
    113128} 
    114129 
     130 
     131 
    115132void AudioFileBrowser::clicked( const QModelIndex& index ) 
    116133{ 
     
    142159        pathLineEdit->setText( onlypath ); 
    143160 
     161        QApplication::setOverrideCursor(Qt::WaitCursor); 
    144162 
    145163        if      ( 
     
    154172                ) { 
    155173 
    156  
    157174                        Sample *pNewSample = Sample::load( path2 ); 
     175 
    158176                        if ( pNewSample ) { 
    159177                                m_pNBytesLable->setText( trUtf8( "Size: %1 bytes" ).arg( pNewSample->get_size() / 2 ) ); 
     
    167185                                m_psamplefilename = path2; 
    168186 
    169                                  
     187                                m_pSampleWaveDisplay->updateDisplay( path2 ); 
     188                                m_pPlayBtn->setEnabled( true ); 
     189                                openBTN->setEnabled( true ); 
     190 
     191                                //important this will only working correct if m_pSampleWaveDisplay->updateDisplay( file ) 
     192                                //is ready with painting the wav file. else the playing sample get crackled sound!! 
    170193                                if (playSamplescheckBox->isChecked()){ 
    171194                                        if ( sec <= 600.00){ 
     
    176199                                        } 
    177200                                } 
    178  
    179                                 m_pSampleWaveDisplay->updateDisplay( path2 ); 
    180                                 m_pPlayBtn->setEnabled( true ); 
    181                                 openBTN->setEnabled( true ); 
    182  
    183201                        } 
    184202                 
     
    195213                        m_psamplefilename = ""; 
    196214                } 
     215        QApplication::restoreOverrideCursor(); 
    197216} 
    198217 
     
    213232 
    214233 
     234 
    215235void AudioFileBrowser::on_m_pStopBtn_clicked() 
    216236{ 
     
    227247        m_pselectedFile << "false" << "false" << ""; 
    228248        reject(); 
    229  
    230249} 
    231250 
     
    234253void AudioFileBrowser::on_openBTN_clicked() 
    235254{ 
    236         if      ( 
    237                 ( ( filelineedit->text().endsWith( ".wav" ) ) || 
    238                 ( filelineedit->text().endsWith( ".WAV" ) ) || 
    239                 ( filelineedit->text().endsWith( ".au" ) ) || 
    240                 ( filelineedit->text().endsWith( ".AU" ) ) || 
    241                 ( filelineedit->text().endsWith( ".aiff" ) ) || 
    242                 ( filelineedit->text().endsWith( ".AIFF" ) ) || 
    243                 ( filelineedit->text().endsWith( ".flac" ) ) || 
    244                 ( filelineedit->text().endsWith( ".FLAC" ) ) ) && 
    245                 ( QFile( filelineedit->text() ).exists() == true ) 
    246                 ) {              
    247                         m_pselectedFile[2] = filelineedit->text(); 
    248                          
    249                 }else 
    250                 { 
    251                         m_pselectedFile << "false" << "false" << ""; 
     255        if( tree->selectionModel()->selectedIndexes().size() / 4 > 0){ 
     256 
     257                QList<QModelIndex>::iterator i; 
     258                QList<QModelIndex> list = tree->selectionModel()->selectedIndexes();     
     259 
     260                for (i = list.begin(); i != list.end(); ++i){ 
     261                        QString path2 = (*i).data().toString(); 
     262                        if      ( 
     263                        ( path2.endsWith( ".wav" ) ) || 
     264                        ( path2.endsWith( ".WAV" ) ) || 
     265                        ( path2.endsWith( ".au" ) ) || 
     266                        ( path2.endsWith( ".AU" ) ) || 
     267                        ( path2.endsWith( ".aiff" ) ) || 
     268                        ( path2.endsWith( ".AIFF" ) ) || 
     269                        ( path2.endsWith( ".flac" ) ) || 
     270                        ( path2.endsWith( ".FLAC" ) ) 
     271                        ) { 
     272                                QString path = pathLineEdit->text(); 
     273                                QString act_filename = path + path2; 
     274                                m_pselectedFile << act_filename ; 
     275                 
     276                        } 
     277                        ++i;++i;++i; 
    252278                } 
     279        } 
    253280        Preferences::getInstance()->__lastsampleDirectory = pathLineEdit->text(); 
    254281        accept(); 
     
    305332        tree->collapse( model->index( updir  ) ); 
    306333} 
     334 
     335 
     336 
     337void AudioFileBrowser::on_hiddenCB_clicked() 
     338{ 
     339        if ( hiddenCB->isChecked() ){ 
     340                model->setFilter( QDir::AllDirs | QDir::AllEntries | QDir::NoDotAndDotDot | QDir::Hidden ); 
     341        }else 
     342        { 
     343                model->setFilter( QDir::AllDirs | QDir::AllEntries | QDir::NoDotAndDotDot ); 
     344                tree->setRootIndex( model->index( pathLineEdit->text() ) ); 
     345        } 
     346} 
  • branches/jackMidi/gui/src/AudioFileBrowser/AudioFileBrowser.h

    r822 r824  
    6262                void on_m_pPathUptoolButton_clicked(); 
    6363                void on_playSamplescheckBox_clicked(); 
     64                void on_hiddenCB_clicked(); 
     65                 
     66                virtual void keyPressEvent (QKeyEvent *ev); 
     67                virtual void keyReleaseEvent (QKeyEvent *ev); 
    6468 
    6569 
     
    6872                QString m_psamplefilename; 
    6973                QStringList m_pselectedFile; 
     74                 
    7075                QDirModel *model; 
    7176                QTreeView *tree; 
     77                QModelIndex __index; 
     78 
     79 
    7280                SampleWaveDisplay *m_pSampleWaveDisplay; 
    7381                QString sEmptySampleFilename; 
    7482                QStringList filters; 
    75                 QModelIndex __index; 
     83                 
    7684 
    7785 
  • branches/jackMidi/gui/src/AudioFileBrowser/AudioFileBrowser_UI.ui

    r822 r824  
    9090     <x>10</x> 
    9191     <y>530</y> 
    92      <width>271</width> 
     92     <width>216</width> 
    9393     <height>21</height> 
    9494    </rect> 
     
    110110    <item> 
    111111     <widget class="QLineEdit" name="pathLineEdit" /> 
     112    </item> 
     113    <item> 
     114     <widget class="QRadioButton" name="hiddenCB" > 
     115      <property name="toolTip" > 
     116       <string>View hidden folders</string> 
     117      </property> 
     118      <property name="text" > 
     119       <string/> 
     120      </property> 
     121     </widget> 
    112122    </item> 
    113123    <item> 
     
    231241 <tabstops> 
    232242  <tabstop>pathLineEdit</tabstop> 
     243  <tabstop>hiddenCB</tabstop> 
    233244  <tabstop>m_pPathUptoolButton</tabstop> 
    234245  <tabstop>m_pPathHometoolButton</tabstop> 
     
    239250  <tabstop>useNameCheckBox</tabstop> 
    240251  <tabstop>playSamplescheckBox</tabstop> 
     252  <tabstop>autoVelCheckBox</tabstop> 
    241253  <tabstop>openBTN</tabstop> 
    242254  <tabstop>cancelBTN</tabstop> 
  • branches/jackMidi/gui/src/InstrumentEditor/InstrumentEditor.cpp

    r823 r824  
    499499        delete fb; 
    500500 
     501        if ( filename[2] == "") return; 
     502 
    501503        bool fnc = false;        
    502504        if ( filename[0] ==  "true" ){ 
     
    504506        } 
    505507 
    506         if (filename[2] != "") { 
    507  
    508                 Sample *newSample = Sample::load( filename[2] ); 
    509  
    510                 H2Core::Instrument *pInstr = NULL; 
    511  
    512                 AudioEngine::get_instance()->lock( "InstrumentPropertiesDialog::browseBtnClicked" ); 
    513                 Song *song = engine->getSong(); 
    514                 InstrumentList *instrList = song->get_instrument_list(); 
    515                 pInstr = instrList->get( engine->getSelectedInstrumentNumber() ); 
    516  
    517                 H2Core::InstrumentLayer *pLayer = pInstr->get_layer( m_nSelectedLayer ); 
    518                 if (pLayer != NULL) { 
    519                         // delete old sample 
    520                         Sample *oldSample = pLayer->get_sample(); 
    521                         delete oldSample; 
    522  
    523                         // insert new sample from newInstrument 
    524                         pLayer->set_sample( newSample ); 
    525                 } 
    526                 else { 
    527                         pLayer = new H2Core::InstrumentLayer(newSample); 
    528                         pInstr->set_layer( pLayer, m_nSelectedLayer ); 
    529                 } 
    530  
    531                 if ( fnc ){ 
    532                         QString newfilename = filename[2].section( '/', -1 ); 
    533                                 newfilename.replace( "." + newfilename.section( '.', -1 ), ""); 
    534                         m_pInstrument->set_name( newfilename ); 
    535                 } 
    536  
    537                 //set automatic velocity 
    538                 if ( filename[1] ==  "true" ){ 
    539                         setAutoVelocity(); 
    540                 } 
    541  
    542                 pInstr->set_drumkit_name( "" );   // external sample, no drumkit info 
    543  
    544                 AudioEngine::get_instance()->unlock(); 
     508        //use auto velocity if we want to work with multiple filenames 
     509        if ( filename.size() > 3) filename[1] = "true"; 
     510 
     511        int selectedLayer =  m_nSelectedLayer; 
     512         
     513         
     514 
     515        if (filename.size() > 2) { 
     516                 
     517                for(int i=2;i < filename.size();++i)  
     518                { 
     519                        if( i-2 >= MAX_LAYERS ) break; 
     520 
     521                        Sample *newSample = Sample::load( filename[i] ); 
     522         
     523                        H2Core::Instrument *pInstr = NULL; 
     524         
     525                        AudioEngine::get_instance()->lock( "InstrumentPropertiesDialog::browseBtnClicked" ); 
     526                        Song *song = engine->getSong(); 
     527                        InstrumentList *instrList = song->get_instrument_list(); 
     528                        pInstr = instrList->get( engine->getSelectedInstrumentNumber() ); 
     529         
     530                        /*  
     531                                if we're using multiple layers, we start inserting the first layer  
     532                                at m_nSelectedLayer and the next layer at m_nSelectedLayer+1 
     533                        */ 
     534                         
     535                        selectedLayer = m_nSelectedLayer + i - 2; 
     536 
     537                         
     538                        H2Core::InstrumentLayer *pLayer = pInstr->get_layer( selectedLayer ); 
     539                        if (pLayer != NULL) { 
     540                                // delete old sample 
     541                                Sample *oldSample = pLayer->get_sample(); 
     542                                delete oldSample; 
     543         
     544                                // insert new sample from newInstrument 
     545                                pLayer->set_sample( newSample ); 
     546                        } 
     547                        else { 
     548                                pLayer = new H2Core::InstrumentLayer(newSample); 
     549                                pInstr->set_layer( pLayer, selectedLayer ); 
     550                        } 
     551         
     552                        if ( fnc ){ 
     553                                QString newfilename = filename[i].section( '/', -1 ); 
     554                                        newfilename.replace( "." + newfilename.section( '.', -1 ), ""); 
     555                                m_pInstrument->set_name( newfilename ); 
     556                        } 
     557         
     558                        //set automatic velocity 
     559                        if ( filename[1] ==  "true" ){ 
     560                                setAutoVelocity(); 
     561                        } 
     562         
     563                        pInstr->set_drumkit_name( "" );   // external sample, no drumkit info 
     564         
     565                        AudioEngine::get_instance()->unlock(); 
     566 
     567                } 
    545568        } 
    546569 
     
    552575void InstrumentEditor::setAutoVelocity() 
    553576{ 
    554         int layerinuse[ MAX_LAYERS - 1 ] = {0}; 
     577        int layerinuse[ MAX_LAYERS ] = {0}; 
    555578        int layers = 0; 
    556         for ( int i = 0; i < MAX_LAYERS - 1; i++ ) { 
     579        for ( int i = 0; i < MAX_LAYERS ; i++ ) { 
    557580                InstrumentLayer *pLayers = m_pInstrument->get_layer( i ); 
    558581                if ( pLayers ) { 
     
    564587        float velocityrange = 1.0 / layers; 
    565588 
    566         for ( int i = 0; i < MAX_LAYERS - 1; i++ ) { 
     589        for ( int i = 0; i < MAX_LAYERS ; i++ ) { 
    567590                if ( layerinuse[i] == i ){ 
    568591                        layers--;