コード例 #1
0
void SoundInterface::commandStopSound(void) {
	int32_t id = cb->popValue().getInt();
	CBChannel* channel = getChannel(id);
	if (channel) {
		channel->stop();
	}
}
コード例 #2
0
void SoundInterface::functionSoundPlaying(void) {
	int32_t id = cb->popValue().getInt();
	CBChannel *channel = getChannel(id);
	if (channel == NULL){
		cb->pushValue(0);
		return;
	}
	int32_t playing = channel->isPlaying();
	cb->pushValue(playing);
}
コード例 #3
0
void SoundInterface::commandSetSound(void) {
	int32_t freq = cb->popValue().toInt();
	float balance = cb->popValue().toFloat();
	float volume = cb->popValue().toFloat();
	bool looping = cb->popValue().toInt();
	int32_t id = cb->popValue().toInt();
	CBChannel* channel = getChannel(id);
	if (channel) {
		channel->setSound(looping, volume, balance, freq);
	}
}
コード例 #4
0
void SoundInterface::functionPlaySound(void) {
	int32_t freg = cb->popValue().toInt();
	float balance = cb->popValue().toFloat();
	float volume = cb->popValue().toFloat();
	const Any &any = cb->popValue();
	if (any.type() == Any::Int) {//Loaded sound
		CBChannel* channel = new CBChannel;
		int32_t id = any.toInt();
		channel->setMixer(al_get_default_mixer());
		channel->playSound((*sounds[id]), volume, balance, freg);
		int32_t nextChannel = nextChannelId();
		channels[nextChannel] = channel;
		cb->pushValue(nextChannel);
	}
	else {
		CBChannel* channel = new CBChannel;
		channel->setMixer(al_get_default_mixer());
		string file = any.toString().getRef();
		INFO(file.c_str())
		channel->playSound(file, volume, balance, freg);
		int32_t nextChannel = nextChannelId();
		channels[nextChannel] = channel;
		cb->pushValue(nextChannel);
	}
}
コード例 #5
0
void SoundInterface::commandPlaySound(void) {
	int32_t freg = cb->popValue().toInt();
	float balance = cb->popValue().toFloat();
	float volume = cb->popValue().toFloat();
	Any any = cb->popValue();
	
	// If passed parameter is integer, the sound is preloaded. Otherwise load it.
	if (any.type() == Any::Int) {
		CBChannel* channel = new CBChannel;
		channel->setMixer(al_get_default_mixer());
		int32_t id = any.toInt();
		channel->playSound((*sounds[id]), volume, balance, freg);
		int32_t nextChannel = nextChannelId();
		channels[nextChannel] = channel;
	}
	else {
		CBChannel* channel = new CBChannel;
		channel->setMixer(al_get_default_mixer());
		ALLEGRO_PATH *path = any.toString().getPath();
		const char *cpath = al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP);
		channel->playSound(cpath, volume, balance, freg);
		int32_t nextChannel = nextChannelId();
		channels[nextChannel] = channel;
	}
}