Changeset 824
- Timestamp:
- 02/21/09 00:05:30 (4 years ago)
- Location:
- branches/jackMidi/gui/src
- Files:
-
- 4 modified
-
AudioFileBrowser/AudioFileBrowser.cpp (modified) (17 diffs)
-
AudioFileBrowser/AudioFileBrowser.h (modified) (2 diffs)
-
AudioFileBrowser/AudioFileBrowser_UI.ui (modified) (4 diffs)
-
InstrumentEditor/InstrumentEditor.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/jackMidi/gui/src/AudioFileBrowser/AudioFileBrowser.cpp
r822 r824 20 20 * 21 21 */ 22 23 22 24 23 #include "AudioFileBrowser.h" … … 34 33 #include <hydrogen/audio_engine.h> 35 34 35 #include <QModelIndex> 36 36 #include <QTreeWidget> 37 37 #include <QMessageBox> … … 44 44 , Object ( "AudioFileBrowser" ) 45 45 { 46 47 46 setupUi ( this ); 48 47 INFOLOG ( "INIT" ); … … 50 49 setFixedSize ( width(), height() ); 51 50 installEventFilter( this ); 52 53 51 54 52 model = new QDirModel(); … … 68 66 tree->setAlternatingRowColors( true ); 69 67 tree->setRootIndex( model->index( Preferences::getInstance()->__lastsampleDirectory ) ); 70 68 71 69 pathLineEdit->setText( Preferences::getInstance()->__lastsampleDirectory ); 72 70 m_psamplefilename = ""; 73 m_pselectedFile << "false" << "false" << "";71 m_pselectedFile << "false" << "false"; 74 72 75 73 sEmptySampleFilename = DataPath::get_data_path() + "/emptySample.wav"; … … 82 80 83 81 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() ) ); 86 83 } 87 84 … … 94 91 INFOLOG ( "DESTROY" ); 95 92 } 93 94 95 96 void 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 106 void AudioFileBrowser::keyReleaseEvent (QKeyEvent *ev) 107 { 108 tree->setSelectionMode( QAbstractItemView::SingleSelection ); 109 } 110 96 111 97 112 … … 113 128 } 114 129 130 131 115 132 void AudioFileBrowser::clicked( const QModelIndex& index ) 116 133 { … … 142 159 pathLineEdit->setText( onlypath ); 143 160 161 QApplication::setOverrideCursor(Qt::WaitCursor); 144 162 145 163 if ( … … 154 172 ) { 155 173 156 157 174 Sample *pNewSample = Sample::load( path2 ); 175 158 176 if ( pNewSample ) { 159 177 m_pNBytesLable->setText( trUtf8( "Size: %1 bytes" ).arg( pNewSample->get_size() / 2 ) ); … … 167 185 m_psamplefilename = path2; 168 186 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!! 170 193 if (playSamplescheckBox->isChecked()){ 171 194 if ( sec <= 600.00){ … … 176 199 } 177 200 } 178 179 m_pSampleWaveDisplay->updateDisplay( path2 );180 m_pPlayBtn->setEnabled( true );181 openBTN->setEnabled( true );182 183 201 } 184 202 … … 195 213 m_psamplefilename = ""; 196 214 } 215 QApplication::restoreOverrideCursor(); 197 216 } 198 217 … … 213 232 214 233 234 215 235 void AudioFileBrowser::on_m_pStopBtn_clicked() 216 236 { … … 227 247 m_pselectedFile << "false" << "false" << ""; 228 248 reject(); 229 230 249 } 231 250 … … 234 253 void AudioFileBrowser::on_openBTN_clicked() 235 254 { 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; 252 278 } 279 } 253 280 Preferences::getInstance()->__lastsampleDirectory = pathLineEdit->text(); 254 281 accept(); … … 305 332 tree->collapse( model->index( updir ) ); 306 333 } 334 335 336 337 void 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 62 62 void on_m_pPathUptoolButton_clicked(); 63 63 void on_playSamplescheckBox_clicked(); 64 void on_hiddenCB_clicked(); 65 66 virtual void keyPressEvent (QKeyEvent *ev); 67 virtual void keyReleaseEvent (QKeyEvent *ev); 64 68 65 69 … … 68 72 QString m_psamplefilename; 69 73 QStringList m_pselectedFile; 74 70 75 QDirModel *model; 71 76 QTreeView *tree; 77 QModelIndex __index; 78 79 72 80 SampleWaveDisplay *m_pSampleWaveDisplay; 73 81 QString sEmptySampleFilename; 74 82 QStringList filters; 75 QModelIndex __index;83 76 84 77 85 -
branches/jackMidi/gui/src/AudioFileBrowser/AudioFileBrowser_UI.ui
r822 r824 90 90 <x>10</x> 91 91 <y>530</y> 92 <width>2 71</width>92 <width>216</width> 93 93 <height>21</height> 94 94 </rect> … … 110 110 <item> 111 111 <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> 112 122 </item> 113 123 <item> … … 231 241 <tabstops> 232 242 <tabstop>pathLineEdit</tabstop> 243 <tabstop>hiddenCB</tabstop> 233 244 <tabstop>m_pPathUptoolButton</tabstop> 234 245 <tabstop>m_pPathHometoolButton</tabstop> … … 239 250 <tabstop>useNameCheckBox</tabstop> 240 251 <tabstop>playSamplescheckBox</tabstop> 252 <tabstop>autoVelCheckBox</tabstop> 241 253 <tabstop>openBTN</tabstop> 242 254 <tabstop>cancelBTN</tabstop> -
branches/jackMidi/gui/src/InstrumentEditor/InstrumentEditor.cpp
r823 r824 499 499 delete fb; 500 500 501 if ( filename[2] == "") return; 502 501 503 bool fnc = false; 502 504 if ( filename[0] == "true" ){ … … 504 506 } 505 507 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 } 545 568 } 546 569 … … 552 575 void InstrumentEditor::setAutoVelocity() 553 576 { 554 int layerinuse[ MAX_LAYERS - 1] = {0};577 int layerinuse[ MAX_LAYERS ] = {0}; 555 578 int layers = 0; 556 for ( int i = 0; i < MAX_LAYERS - 1; i++ ) {579 for ( int i = 0; i < MAX_LAYERS ; i++ ) { 557 580 InstrumentLayer *pLayers = m_pInstrument->get_layer( i ); 558 581 if ( pLayers ) { … … 564 587 float velocityrange = 1.0 / layers; 565 588 566 for ( int i = 0; i < MAX_LAYERS - 1; i++ ) {589 for ( int i = 0; i < MAX_LAYERS ; i++ ) { 567 590 if ( layerinuse[i] == i ){ 568 591 layers--;