void FileBrowserTreeWidget::handleFile(FileItem * f, InstrumentTrack * it ) { Engine::mixer()->lock(); switch( f->handling() ) { case FileItem::LoadAsProject: if( Engine::mainWindow()->mayChangeProject() ) { Engine::getSong()->loadProject( f->fullName() ); } break; case FileItem::LoadByPlugin: { const QString e = f->extension(); Instrument * i = it->instrument(); if( i == NULL || !i->descriptor()->supportsFileType( e ) ) { i = it->loadInstrument( Engine::pluginFileHandling()[e] ); } i->loadFile( f->fullName() ); break; } case FileItem::LoadAsPreset: { DataFile dataFile( f->fullName() ); InstrumentTrack::removeMidiPortNode( dataFile ); it->setSimpleSerializing(); it->loadSettings( dataFile.content().toElement() ); break; } case FileItem::ImportAsProject: if( f->type() == FileItem::FlpFile && !Engine::mainWindow()->mayChangeProject() ) { break; } ImportFilter::import( f->fullName(), Engine::getSong() ); break; case FileItem::NotSupported: default: break; } Engine::mixer()->unlock(); }
void InstrumentTrackWindow::dropEvent( QDropEvent* event ) { QString type = StringPairDrag::decodeKey( event ); QString value = StringPairDrag::decodeValue( event ); if( type == "instrument" ) { m_track->loadInstrument( value ); Engine::getSong()->setModified(); event->accept(); setFocus(); } else if( type == "presetfile" ) { DataFile dataFile( value ); InstrumentTrack::removeMidiPortNode( dataFile ); m_track->setSimpleSerializing(); m_track->loadSettings( dataFile.content().toElement() ); Engine::getSong()->setModified(); event->accept(); setFocus(); } else if( type == "pluginpresetfile" ) { const QString ext = FileItem::extension( value ); Instrument * i = m_track->instrument(); if( !i->descriptor()->supportsFileType( ext ) ) { i = m_track->loadInstrument( pluginFactory->pluginSupportingExtension(ext).name() ); } i->loadFile( value ); event->accept(); setFocus(); } }
PresetPreviewPlayHandle::PresetPreviewPlayHandle( const QString & _preset_file, bool _load_by_plugin, DataFile *dataFile ) : PlayHandle( TypePresetPreviewHandle ), m_previewNote( NULL ) { s_previewTC->lockData(); setUsesBuffer( false ); if( s_previewTC->previewNote() != NULL ) { s_previewTC->previewNote()->mute(); } const bool j = Engine::projectJournal()->isJournalling(); Engine::projectJournal()->setJournalling( false ); if( _load_by_plugin ) { Instrument * i = s_previewTC->previewInstrumentTrack()->instrument(); const QString ext = QFileInfo( _preset_file ). suffix().toLower(); if( i == NULL || !i->descriptor()->supportsFileType( ext ) ) { i = s_previewTC->previewInstrumentTrack()-> loadInstrument(pluginFactory->pluginSupportingExtension(ext).name()); } if( i != NULL ) { i->loadFile( _preset_file ); } } else { bool dataFileCreated = false; if( dataFile == 0 ) { dataFile = new DataFile( _preset_file ); dataFileCreated = true; } // vestige previews are bug prone; fallback on 3xosc with volume of 0 // without an instrument in preview track, it will segfault if(dataFile->content().elementsByTagName( "vestige" ).length() == 0 ) { s_previewTC->previewInstrumentTrack()-> loadTrackSpecificSettings( dataFile->content().firstChild().toElement() ); } else { s_previewTC->previewInstrumentTrack()->loadInstrument("tripleoscillator"); s_previewTC->previewInstrumentTrack()->setVolume( 0 ); } if( dataFileCreated ) { delete dataFile; } } dataFile = 0; // make sure, our preset-preview-track does not appear in any MIDI- // devices list, so just disable receiving/sending MIDI-events at all s_previewTC->previewInstrumentTrack()-> midiPort()->setMode( MidiPort::Disabled ); // create note-play-handle for it m_previewNote = NotePlayHandleManager::acquire( s_previewTC->previewInstrumentTrack(), 0, typeInfo<f_cnt_t>::max() / 2, Note( 0, 0, DefaultKey, 100 ) ); setAudioPort( s_previewTC->previewInstrumentTrack()->audioPort() ); s_previewTC->setPreviewNote( m_previewNote ); Engine::mixer()->addPlayHandle( m_previewNote ); s_previewTC->unlockData(); Engine::projectJournal()->setJournalling( j ); }