}
PlayingSound* createPlayingSound(SoundBuffer *buf, bool loop,
- float volume)
+ float volume, float pitch)
{
infostream<<"OpenALSoundManager: Creating playing sound"<<std::endl;
assert(buf);
alSourcei(sound->source_id, AL_LOOPING, loop ? AL_TRUE : AL_FALSE);
volume = MYMAX(0.0, volume);
alSourcef(sound->source_id, AL_GAIN, volume);
+ alSourcef(sound->source_id, AL_PITCH, pitch);
alSourcePlay(sound->source_id);
warn_if_error(alGetError(), "createPlayingSound");
return sound;
}
PlayingSound* createPlayingSoundAt(SoundBuffer *buf, bool loop,
- float volume, v3f pos)
+ float volume, v3f pos, float pitch)
{
infostream<<"OpenALSoundManager: Creating positional playing sound"
<<std::endl;
alSourcei(sound->source_id, AL_LOOPING, loop ? AL_TRUE : AL_FALSE);
volume = MYMAX(0.0, volume);
alSourcef(sound->source_id, AL_GAIN, volume);
+ alSourcef(sound->source_id, AL_PITCH, pitch);
alSourcePlay(sound->source_id);
warn_if_error(alGetError(), "createPlayingSoundAt");
return sound;
}
- int playSoundRaw(SoundBuffer *buf, bool loop, float volume)
+ int playSoundRaw(SoundBuffer *buf, bool loop, float volume, float pitch)
{
assert(buf);
- PlayingSound *sound = createPlayingSound(buf, loop, volume);
+ PlayingSound *sound = createPlayingSound(buf, loop, volume, pitch);
if(!sound)
return -1;
int id = m_next_id++;
return id;
}
- int playSoundRawAt(SoundBuffer *buf, bool loop, float volume, v3f pos)
+ int playSoundRawAt(SoundBuffer *buf, bool loop, float volume, v3f pos, float pitch)
{
assert(buf);
- PlayingSound *sound = createPlayingSoundAt(buf, loop, volume, pos);
+ PlayingSound *sound = createPlayingSoundAt(buf, loop, volume, pos, pitch);
if(!sound)
return -1;
int id = m_next_id++;
alListenerf(AL_GAIN, gain);
}
- int playSound(const std::string &name, bool loop, float volume, float fade)
+ int playSound(const std::string &name, bool loop, float volume, float fade, float pitch)
{
maintain();
if(name == "")
}
int handle = -1;
if (fade > 0) {
- handle = playSoundRaw(buf, loop, 0);
+ handle = playSoundRaw(buf, loop, 0.0f, 0.0f);
fadeSound(handle, fade, volume);
} else {
- handle = playSoundRaw(buf, loop, volume);
+ handle = playSoundRaw(buf, loop, volume, pitch);
}
return handle;
}
- int playSoundAt(const std::string &name, bool loop, float volume, v3f pos)
+ int playSoundAt(const std::string &name, bool loop, float volume, v3f pos, float pitch)
{
maintain();
if(name == "")
<<std::endl;
return -1;
}
- return playSoundRawAt(buf, loop, volume, pos);
+ return playSoundRawAt(buf, loop, volume, pos, pitch);
}
void stopSound(int sound)