Ejemplo n.º 1
0
MusicPlayer::MusicPlayer()
{
    /* Create the settings. */
    this->settings = new_fluid_settings();

    fluid_sfloader_t* loader;

    /* Change the settings if necessary*/
    fluid_settings_setstr(this->settings, "synth.reverb.active", "yes");
    fluid_settings_setstr(this->settings, "synth.chorus.active", "no");
    fluid_settings_setstr(this->settings, "synth.midi-bank-select", "mma");
    fluid_settings_setint(this->settings, "synth.midi-channels", 48);
    fluid_settings_setstr(this->settings, "player.timing-source", "system");

    /* Create the synthesizer. */
    this->synth = new_fluid_synth(this->settings);


    // allocate and add our custom memory sfont loader
    loader = new_memsfloader(settings);

    if (loader == NULL) {
        FLUID_LOG(FLUID_WARN, "Failed to create the default SoundFont loader");
    } else {
        fluid_synth_add_sfloader(synth, loader);
    }


    //    fluid_synth_set_reverb(synth, 0.5, 0.8, FLUID_REVERB_DEFAULT_WIDTH, 0.5);
    fluid_synth_set_reverb(this->synth, 0.7, 0.8, 0.9, 0.4);
    //fluid_synth_set_interp_method(synth, -1, FLUID_INTERP_NONE);

//    this->player = new_vgmtrans_fluid_player(this->synth);
//    fluid_player_set_playback_callback(this->player, &midi_event_callback, this->synth);
}
Ejemplo n.º 2
0
void soundfonts_reverb_level(t_soundfonts *instance, t_floatarg amount)
{
    fluid_synth_set_reverb(instance->synth, instance->reverb_size, instance->reverb_damping, instance->reverb_width, amount);
    instance->reverb_level = amount;
}
Ejemplo n.º 3
0
void sf2Instrument::updateReverb()
{
	fluid_synth_set_reverb( m_synth, m_reverbRoomSize.value(),
			m_reverbDamping.value(), m_reverbWidth.value(),
			m_reverbLevel.value() );
}
Ejemplo n.º 4
0
int MidiDriver_FluidSynth::open() {
	if (_isOpen)
		return MERR_ALREADY_OPEN;

	if (!ConfMan.hasKey("soundfont"))
		error("FluidSynth requires a 'soundfont' setting");

	_settings = new_fluid_settings();

	// The default gain setting is ridiculously low - at least for me. This
	// cannot be fixed by ScummVM's volume settings because they can only
	// soften the sound, not amplify it, so instead we add an option to
	// adjust the gain of FluidSynth itself.

	double gain = (double)ConfMan.getInt("midi_gain") / 100.0;

	setNum("synth.gain", gain);
	setNum("synth.sample-rate", _outputRate);

	_synth = new_fluid_synth(_settings);

	if (ConfMan.getBool("fluidsynth_chorus_activate")) {
		fluid_synth_set_chorus_on(_synth, 1);

		int chorusNr = ConfMan.getInt("fluidsynth_chorus_nr");
		double chorusLevel = (double)ConfMan.getInt("fluidsynth_chorus_level") / 100.0;
		double chorusSpeed = (double)ConfMan.getInt("fluidsynth_chorus_speed") / 100.0;
		double chorusDepthMs = (double)ConfMan.getInt("fluidsynth_chorus_depth") / 10.0;

		Common::String chorusWaveForm = ConfMan.get("fluidsynth_chorus_waveform");
		int chorusType = FLUID_CHORUS_MOD_SINE;
		if (chorusWaveForm == "sine") {
			chorusType = FLUID_CHORUS_MOD_SINE;
		} else {
			chorusType = FLUID_CHORUS_MOD_TRIANGLE;
		}

		fluid_synth_set_chorus(_synth, chorusNr, chorusLevel, chorusSpeed, chorusDepthMs, chorusType);
	} else {
		fluid_synth_set_chorus_on(_synth, 0);
	}

	if (ConfMan.getBool("fluidsynth_reverb_activate")) {
		fluid_synth_set_reverb_on(_synth, 1);

		double reverbRoomSize = (double)ConfMan.getInt("fluidsynth_reverb_roomsize") / 100.0;
		double reverbDamping = (double)ConfMan.getInt("fluidsynth_reverb_damping") / 100.0;
		int reverbWidth = ConfMan.getInt("fluidsynth_reverb_width");
		double reverbLevel = (double)ConfMan.getInt("fluidsynth_reverb_level") / 100.0;

		fluid_synth_set_reverb(_synth, reverbRoomSize, reverbDamping, reverbWidth, reverbLevel);
	} else {
		fluid_synth_set_reverb_on(_synth, 0);
	}

	Common::String interpolation = ConfMan.get("fluidsynth_misc_interpolation");
	int interpMethod = FLUID_INTERP_4THORDER;

	if (interpolation == "none") {
		interpMethod = FLUID_INTERP_NONE;
	} else if (interpolation == "linear") {
		interpMethod = FLUID_INTERP_LINEAR;
	} else if (interpolation == "4th") {
		interpMethod = FLUID_INTERP_4THORDER;
	} else if (interpolation == "7th") {
		interpMethod = FLUID_INTERP_7THORDER;
	}

	fluid_synth_set_interp_method(_synth, -1, interpMethod);

	const char *soundfont = ConfMan.get("soundfont").c_str();

	_soundFont = fluid_synth_sfload(_synth, soundfont, 1);
	if (_soundFont == -1)
		error("Failed loading custom sound font '%s'", soundfont);

	MidiDriver_Emulated::open();

	_mixer->playStream(Audio::Mixer::kPlainSoundType, &_mixerSoundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true);
	return 0;
}