Beispiel #1
0
/* Low level sound player */
static void StartSound(SoundID sound_id, float pan, uint volume)
{
	if (volume == 0) return;

	const SoundEntry *sound = GetSound(sound_id);
	if (sound == NULL) return;

	/* Empty sound? */
	if (sound->rate == 0) return;

	MixerChannel *mc = MxAllocateChannel();
	if (mc == NULL) return;

	if (!SetBankSource(mc, sound)) return;

	/* Apply the sound effect's own volume. */
	volume = sound->volume * volume;

	MxSetChannelVolume(mc, volume, pan);
	MxActivateChannel(mc);
}
Beispiel #2
0
/* Low level sound player */
static void StartSound(SoundID sound_id, int panning, uint volume)
{
	if (volume == 0) return;

	const SoundEntry *sound = GetSound(sound_id);
	if (sound == NULL) return;

	MixerChannel *mc = MxAllocateChannel();
	if (mc == NULL) return;

	if (!SetBankSource(mc, sound)) return;

	/* Apply the sound effect's own volume. */
	volume = (sound->volume * volume) / 128;

	panning = Clamp(panning, -PANNING_LEVELS, PANNING_LEVELS);
	uint left_vol = (volume * PANNING_LEVELS) - (volume * panning);
	uint right_vol = (volume * PANNING_LEVELS) + (volume * panning);
	MxSetChannelVolume(mc, left_vol * 128 / PANNING_LEVELS, right_vol * 128 / PANNING_LEVELS);
	MxActivateChannel(mc);
}