Esempio n. 1
0
const char *MusicDriver_FluidSynth::Start(const char * const *param)
{
	const char *driver_name = GetDriverParam(param, "driver");
	const char *sfont_name = GetDriverParam(param, "soundfont");
	int sfont_id;

	if (!driver_name) driver_name = "alsa";

	DEBUG(driver, 1, "Fluidsynth: driver %s, sf %s", driver_name, sfont_name);

	/* Create the settings. */
	_midi.settings = new_fluid_settings();
	if (!_midi.settings) return "Could not create midi settings";

	if (fluid_settings_setstr(_midi.settings, "audio.driver", driver_name) != 1) {
		return "Could not set audio driver name";
	}

	/* Create the synthesizer. */
	_midi.synth = new_fluid_synth(_midi.settings);
	if (!_midi.synth) return "Could not open synth";

	/* Create the audio driver. The synthesizer starts playing as soon
	   as the driver is created. */
	_midi.adriver = new_fluid_audio_driver(_midi.settings, _midi.synth);
	if (!_midi.adriver) return "Could not open audio driver";

	/* Load a SoundFont and reset presets (so that new instruments
	 * get used from the SoundFont) */
	if (!sfont_name) {
		int i;
		sfont_id = FLUID_FAILED;
		for (i = 0; default_sf[i]; i++) {
			if (!fluid_is_soundfont(default_sf[i])) continue;
			sfont_id = fluid_synth_sfload(_midi.synth, default_sf[i], 1);
			if (sfont_id != FLUID_FAILED) break;
		}
		if (sfont_id == FLUID_FAILED) return "Could not open any sound font";
	} else {
		sfont_id = fluid_synth_sfload(_midi.synth, sfont_name, 1);
		if (sfont_id == FLUID_FAILED) return "Could not open sound font";
	}

	_midi.player = NULL;

	return NULL;
}
Esempio n. 2
0
const char *VideoDriver_SDL::Start(const char * const *parm)
{
	char buf[30];
	_use_hwpalette = GetDriverParamInt(parm, "hw_palette", 2);

	const char *s = SdlOpen(SDL_INIT_VIDEO);
	if (s != NULL) return s;

	GetVideoModes();
	if (!CreateMainSurface(_cur_resolution.width, _cur_resolution.height)) {
		return SDL_CALL SDL_GetError();
	}

	SDL_CALL SDL_VideoDriverName(buf, sizeof buf);
	DEBUG(driver, 1, "SDL: using driver '%s'", buf);

	MarkWholeScreenDirty();
	SetupKeyboard();

	_draw_threaded = GetDriverParam(parm, "no_threads") == NULL && GetDriverParam(parm, "no_thread") == NULL;

	return NULL;
}
Esempio n. 3
0
const char *MusicDriver_ExtMidi::Start(const char * const * parm)
{
	if (strcmp(_video_driver->GetName(), "allegro") == 0 ||
			strcmp(_sound_driver->GetName(), "allegro") == 0) {
		return "the extmidi driver does not work when Allegro is loaded.";
	}

	const char *command = GetDriverParam(parm, "cmd");
	if (StrEmpty(command)) command = EXTERNAL_PLAYER;

	this->command = strdup(command);
	this->song[0] = '\0';
	this->pid = -1;
	return NULL;
}
Esempio n. 4
0
const char *VideoDriver_SDL::Start(const char * const *parm)
{
	char buf[30];

	const char *s = SdlOpen(SDL_INIT_VIDEO);
	if (s != NULL) return s;

	GetVideoModes();
	if (!CreateMainSurface(_cur_resolution.width, _cur_resolution.height)) {
		return SDL_CALL SDL_GetError();
	}

	SDL_CALL SDL_VideoDriverName(buf, sizeof buf);
	DEBUG(driver, 1, "SDL: using driver '%s'", buf);

	MarkWholeScreenDirty();

	SDL_CALL SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
	SDL_CALL SDL_EnableUNICODE(1);

	_draw_threaded = GetDriverParam(parm, "no_threads") == NULL && GetDriverParam(parm, "no_thread") == NULL;

	return NULL;
}
int GetDriverParamInt(const char * const *parm, const char *name, int def)
{
	const char *p = GetDriverParam(parm, name);
	return p != NULL ? atoi(p) : def;
}
bool GetDriverParamBool(const char * const *parm, const char *name)
{
	return GetDriverParam(parm, name) != NULL;
}