コード例 #1
0
ファイル: AudioChannel.cpp プロジェクト: nixtux/spring
void AudioChannel::PlayRandomSample(const GuiSoundSet& soundSet, const float3& pos)
{
	if (soundSet.sounds.empty())
		return;

	const int soundIdx = guRNG.NextInt(soundSet.sounds.size());
	const int soundID = soundSet.getID(soundIdx);
	const float soundVol = soundSet.getVolume(soundIdx);

	PlaySample(soundID, pos, soundVol);
}
コード例 #2
0
ファイル: AudioChannel.cpp プロジェクト: 304471720/spring
void AudioChannel::PlayRandomSample(const GuiSoundSet& soundSet, const float3& pos)
{
	const int soundIdx = soundSet.getRandomIdx();

	if (soundIdx < 0)
		return;

	const int soundID = soundSet.getID(soundIdx);
	const float soundVol = soundSet.getVolume(soundIdx);

	PlaySample(soundID, pos, soundVol);
}
コード例 #3
0
ファイル: WeaponDefHandler.cpp プロジェクト: mistletoe/spring
void CWeaponDefHandler::LoadSound(const LuaTable& wdTable,
                                  GuiSoundSet& gsound, const string& soundCat)
{
	string name = "";
	float volume = -1.0f;

	if (soundCat == "start") {
		name   = wdTable.GetString("soundStart", "");
		volume = wdTable.GetFloat("soundStartVolume", -1.0f);
	}
	else if (soundCat == "hit") {
		name   = wdTable.GetString("soundHit", "");
		volume = wdTable.GetFloat("soundHitVolume", -1.0f);
	}

	if (name != "") {
		const int id = LoadSoundFile(name);
		if (id > 0)
		{
			GuiSoundSet::Data soundData(name, 0, volume);
			gsound.sounds.push_back(soundData);
			gsound.setID(0, id);
		}
	}
}
コード例 #4
0
ファイル: WeaponDefHandler.cpp プロジェクト: Gepard/spring
void CWeaponDefHandler::LoadSound(const LuaTable& wdTable,
                                  GuiSoundSet& gsound, const string& soundCat)
{
	string name = "";
	float volume = -1.0f;

	if (soundCat == "start") {
		name   = wdTable.GetString("soundStart", "");
		volume = wdTable.GetFloat("soundStartVolume", -1.0f);
	}
	else if (soundCat == "hit") {
		name   = wdTable.GetString("soundHit", "");
		volume = wdTable.GetFloat("soundHitVolume", -1.0f);
	}

	if (name != "") {
		if (!sound->HasSoundItem(name))
		{
			if (name.find(".wav") == string::npos) {
				// .wav extension missing, add it
				name += ".wav";
			}
			const string soundPath = "sounds/" + name;
			CFileHandler sfile(soundPath);
			if (sfile.FileExists()) {
				// only push data if we extracted a valid name
				GuiSoundSet::Data soundData(name, 0, volume);
				gsound.sounds.push_back(soundData);
				int id = sound->GetSoundId(soundPath);
				gsound.setID(0, id);
			}
		}
		else
		{
			GuiSoundSet::Data soundData(name, 0, volume);
			gsound.sounds.push_back(soundData);
			int id = sound->GetSoundId(name);
			gsound.setID(0, id);
		}
	}
}