Esempio n. 1
0
/**
 * @brief Adds ambient sounds from misc_sound entities
 * @sa CL_SpawnParseEntitystring
 */
void LE_AddAmbientSound (const char* sound, const vec3_t origin, int levelflags, float volume, float attenuation)
{
	if (strstr(sound, "sound/"))
		sound += 6;

	int sampleIdx = S_LoadSampleIdx(sound);
	if (!sampleIdx)
		return;

	le_t* le = LE_Add(0);
	if (!le) {
		Com_Printf("Could not add ambient sound entity\n");
		return;
	}
	le->type = ET_SOUND;
	le->sampleIdx = sampleIdx;
	VectorCopy(origin, le->origin);
	LE_SetInvisible(le);
	le->levelflags = levelflags;
	le->attenuation = attenuation;

	if (volume < 0.0f || volume > 1.0f) {
		le->volume = SND_VOLUME_DEFAULT;
		Com_Printf("Invalid volume for local entity given - only values between 0.0 and 1.0 are valid\n");
	} else {
		le->volume = volume;
	}

	Com_DPrintf(DEBUG_SOUND, "Add ambient sound '%s' with volume %f\n", sound, volume);
}
Esempio n. 2
0
/**
 * @brief Loads and registers a sound file for later use
 * @param[in] soundFile The name of the soundfile, relative to the sounds dir
 */
s_sample_t *S_LoadSample (const char *soundFile)
{
    int sampleIdx = S_LoadSampleIdx(soundFile);
    return S_GetSample(sampleIdx);
}