Source: src/cl_sound.cc


Annotated List
Files
Globals
Hierarchy
Index
//Sound controlling object

#include "cl_sound.h"

void SOUND_DRIVER::init()
{
	data.clear();
	freq = BASIC_FREQUENCY;
	vol = BASIC_VOLUME;
	pan = BASIC_PAN;
}

void SOUND_DRIVER::load(string name, string file)
{
	SAMPLE *tmp;
	destroy(name);
	tmp = load_sample(file.c_str());
	if(tmp) {
	//	message("Loaded sample %s from file %s", name.c_str(), file.c_str());
		data[name] = tmp;
	} else {
		error("Unable to load sample %s from file %s", name.c_str(), file.c_str());
	}
}

void SOUND_DRIVER::play(string name)
{
	if(data[name]) {
		play_sample(data[name], vol, pan, freq, 0);
	}
}

void SOUND_DRIVER::stop(string name)
{
	if(data[name]) {			//stop if looping, else stop all instances
		stop_sample(data[name]);
	}
}


void SOUND_DRIVER::destroy(string name)
{
	if(data[name]) {
		message("Destroying sound %s", name.c_str());
		destroy_sample(data[name]);
		data[name] = NULL;
	}
}

Generated by: georgik on armada on Sat Jul 24 07:07:15 2004, using kdoc 2.0a54.