3 #include "sound_source.hpp"
4 #include "sound_manager.hpp"
6 SoundSource::SoundSource()
8 alGenSources(1, &source);
9 SoundManager::check_al_error("Couldn't create audio source: ");
10 set_reference_distance(128);
13 SoundSource::~SoundSource()
16 alDeleteSources(1, &source);
23 alSourcei(source, AL_BUFFER, AL_NONE);
24 SoundManager::check_al_error("Problem stopping audio source: ");
31 SoundManager::check_al_error("Couldn't start audio source: ");
35 SoundSource::playing()
37 ALint state = AL_PLAYING;
38 alGetSourcei(source, AL_SOURCE_STATE, &state);
39 return state != AL_STOPPED;
48 SoundSource::set_looping(bool looping)
50 alSourcei(source, AL_LOOPING, looping ? AL_TRUE : AL_FALSE);
54 SoundSource::set_position(Vector position)
56 alSource3f(source, AL_POSITION, position.x, position.y, 0);
60 SoundSource::set_velocity(Vector velocity)
62 alSource3f(source, AL_VELOCITY, velocity.x, velocity.y, 0);
66 SoundSource::set_gain(float gain)
68 alSourcef(source, AL_GAIN, gain);
72 SoundSource::set_reference_distance(float distance)
74 alSourcef(source, AL_REFERENCE_DISTANCE, distance);