コード例 #1
0
ファイル: fluid_lash.c プロジェクト: jnetterf/creator-live
static void
fluid_lash_save (fluid_synth_t * synth)
{
  int i;
  int sfcount;
  fluid_sfont_t * sfont;
  lash_config_t * config;
  char num[32];

  sfcount = fluid_synth_sfcount (synth);

  config = lash_config_new ();
  lash_config_set_key (config, "soundfont count");
  lash_config_set_value_int (config, sfcount);
  lash_send_config (fluid_lash_client, config);

  for (i = sfcount - 1; i >= 0; i--)
    {
      sfont = fluid_synth_get_sfont (synth, i);
      config = lash_config_new ();

      sprintf (num, "%d", i);

      lash_config_set_key (config, num);
      lash_config_set_value_string (config, sfont->get_name (sfont));

      lash_send_config (fluid_lash_client, config);
    }
}
コード例 #2
0
ファイル: sf2_player.cpp プロジェクト: AHudon/lmms
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
		{
			// TODO: Couldn't load file!
		}
	}

	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()->setName( QFileInfo( _sf2File ).baseName() );
	}
}