smfMidiChannel * create( TrackContainer* tc, QString tn ) { if( !it ) { // Keep LMMS responsive qApp->processEvents(); it = dynamic_cast<InstrumentTrack *>( Track::create( Track::InstrumentTrack, tc ) ); #ifdef LMMS_HAVE_FLUIDSYNTH it_inst = it->loadInstrument( "sf2player" ); if( it_inst ) { isSF2 = true; it_inst->loadFile( ConfigManager::inst()->defaultSoundfont() ); it_inst->childModel( "bank" )->setValue( 0 ); it_inst->childModel( "patch" )->setValue( 0 ); } else { it_inst = it->loadInstrument( "patman" ); } #else it_inst = it->loadInstrument( "patman" ); #endif trackName = tn; if( trackName != "") { it->setName( tn ); } lastEnd = 0; // General MIDI default it->pitchRangeModel()->setInitValue( 2 ); } return this; }
smfMidiChannel * create( TrackContainer* tc ) { if( !it ) { it = dynamic_cast<InstrumentTrack *>( track::create( track::InstrumentTrack, tc ) ); #ifdef LMMS_HAVE_FLUIDSYNTH it_inst = it->loadInstrument( "sf2player" ); if( it_inst ) { isSF2 = true; it_inst->loadFile( ConfigManager::inst()->defaultSoundfont() ); it_inst->childModel( "bank" )->setValue( 0 ); it_inst->childModel( "patch" )->setValue( 0 ); } else { it_inst = it->loadInstrument( "patman" ); } #else it_inst = it->loadInstrument( "patman" ); #endif lastEnd = 0; } return this; }
void TrackContainerView::dropEvent( QDropEvent * _de ) { QString type = StringPairDrag::decodeKey( _de ); QString value = StringPairDrag::decodeValue( _de ); if( type == "instrument" ) { InstrumentTrack * it = dynamic_cast<InstrumentTrack *>( Track::create( Track::InstrumentTrack, m_tc ) ); InstrumentLoaderThread *ilt = new InstrumentLoaderThread( this, it, value ); ilt->start(); //it->toggledInstrumentTrackButton( true ); _de->accept(); } else if( type == "samplefile" || type == "pluginpresetfile" || type == "soundfontfile" || type == "vstpluginfile") { InstrumentTrack * it = dynamic_cast<InstrumentTrack *>( Track::create( Track::InstrumentTrack, m_tc ) ); Instrument * i = it->loadInstrument( pluginFactory->pluginSupportingExtension(FileItem::extension(value)).name()); i->loadFile( value ); //it->toggledInstrumentTrackButton( true ); _de->accept(); } else if( type == "presetfile" ) { DataFile dataFile( value ); InstrumentTrack * it = dynamic_cast<InstrumentTrack *>( Track::create( Track::InstrumentTrack, m_tc ) ); it->setSimpleSerializing(); it->loadSettings( dataFile.content().toElement() ); //it->toggledInstrumentTrackButton( true ); _de->accept(); } else if( type == "importedproject" ) { ImportFilter::import( value, m_tc ); _de->accept(); } else if( type == "projectfile") { if( gui->mainWindow()->mayChangeProject(true) ) { Engine::getSong()->loadProject( value ); } _de->accept(); } else if( type.left( 6 ) == "track_" ) { DataFile dataFile( value.toUtf8() ); Track::create( dataFile.content().firstChild().toElement(), m_tc ); _de->accept(); } }
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 TrackContainerView::dropEvent( QDropEvent * _de ) { QString type = stringPairDrag::decodeKey( _de ); QString value = stringPairDrag::decodeValue( _de ); if( type == "instrument" ) { InstrumentTrack * it = dynamic_cast<InstrumentTrack *>( track::create( track::InstrumentTrack, m_tc ) ); it->loadInstrument( value ); //it->toggledInstrumentTrackButton( true ); _de->accept(); } else if( type == "samplefile" || type == "pluginpresetfile" || type == "soundfontfile" || type == "vstpluginfile") { InstrumentTrack * it = dynamic_cast<InstrumentTrack *>( track::create( track::InstrumentTrack, m_tc ) ); Instrument * i = it->loadInstrument( engine::pluginFileHandling()[fileItem::extension( value )]); i->loadFile( value ); //it->toggledInstrumentTrackButton( true ); _de->accept(); } else if( type == "presetfile" ) { DataFile dataFile( value ); InstrumentTrack * it = dynamic_cast<InstrumentTrack *>( track::create( track::InstrumentTrack, m_tc ) ); it->setSimpleSerializing(); it->loadSettings( dataFile.content().toElement() ); //it->toggledInstrumentTrackButton( true ); _de->accept(); } else if( type == "importedproject" ) { ImportFilter::import( value, m_tc ); _de->accept(); } else if( type.left( 6 ) == "track_" ) { DataFile dataFile( value.toUtf8() ); track::create( dataFile.content().firstChild().toElement(), m_tc ); _de->accept(); } }
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 ); }