void VstEffect::openPlugin( const QString & _plugin ) { TextFloat * tf = TextFloat::displayMessage( VstPlugin::tr( "Loading plugin" ), VstPlugin::tr( "Please wait while loading VST plugin..." ), PLUGIN_NAME::getIconPixmap( "logo", 24, 24 ), 0 ); m_pluginMutex.lock(); m_plugin = new VstPlugin( _plugin ); if( m_plugin->failed() ) { m_pluginMutex.unlock(); closePlugin(); delete tf; collectErrorForUI( VstPlugin::tr( "The VST plugin %1 could not be loaded." ).arg( _plugin ) ); return; } VstPlugin::connect( Engine::getSong(), SIGNAL( tempoChanged( bpm_t ) ), m_plugin, SLOT( setTempo( bpm_t ) ) ); m_plugin->setTempo( Engine::getSong()->getTempo() ); m_pluginMutex.unlock(); delete tf; m_key.attributes["file"] = _plugin; }
void sf2Instrument::openFile( const QString & _sf2File, bool updateTrackName ) { emit fileLoading(); // Used for loading file char * sf2Ascii = qstrdup( qPrintable( SampleBuffer::tryToMakeAbsolute( _sf2File ) ) ); QString relativePath = SampleBuffer::tryToMakeRelative( _sf2File ); // free reference to soundfont if one is selected freeFont(); m_synthMutex.lock(); s_fontsMutex.lock(); // Increment Reference if( s_fonts.contains( relativePath ) ) { qDebug() << "Using existing reference to " << relativePath; m_font = s_fonts[ relativePath ]; m_font->refCount++; m_fontId = fluid_synth_add_sfont( m_synth, m_font->fluidFont ); } // Add to map, if doesn't exist. else { m_fontId = fluid_synth_sfload( m_synth, sf2Ascii, true ); if( fluid_synth_sfcount( m_synth ) > 0 ) { // Grab this sf from the top of the stack and add to list m_font = new sf2Font( fluid_synth_get_sfont( m_synth, 0 ) ); s_fonts.insert( relativePath, m_font ); } else { collectErrorForUI( sf2Instrument::tr( "A soundfont %1 could not be loaded." ).arg( QFileInfo( _sf2File ).baseName() ) ); // TODO: Why is the filename missing when the file does not exist? } } s_fontsMutex.unlock(); m_synthMutex.unlock(); if( m_fontId >= 0 ) { // Don't reset patch/bank, so that it isn't cleared when // someone resolves a missing file //m_patchNum.setValue( 0 ); //m_bankNum.setValue( 0 ); m_filename = relativePath; emit fileChanged(); } delete[] sf2Ascii; if( updateTrackName || instrumentTrack()->displayName() == displayName() ) { instrumentTrack()->setName( QFileInfo( _sf2File ).baseName() ); } }