29 #include "nomlib/audio/AL/Music.hpp"
36 NOM_LOG_TRACE ( NOM );
41 Music::Music (
const SoundBuffer& copy )
43 this->setBuffer ( copy );
46 Music::~Music (
void )
48 NOM_LOG_TRACE ( NOM );
53 void Music::setBuffer (
const SoundBuffer& copy )
55 NOM_LOG_TRACE ( NOM );
57 AL_CHECK_ERR ( alSourcei (
source_id, AL_BUFFER, copy.get() ) );
60 void Music::Play (
void )
62 AL_CHECK_ERR ( alSourcePlay (
source_id ) );
65 void Music::Stop (
void )
67 AL_CHECK_ERR ( alSourceStop (
source_id ) );
70 void Music::Pause (
void )
72 AL_CHECK_ERR ( alSourcePause (
source_id ) );
75 void Music::togglePause (
void )
77 if ( this->
getStatus() == SoundStatus::Paused )
81 else if ( this->
getStatus() == SoundStatus::Playing )
87 void Music::fadeOut (
float seconds )
90 float fade_step = current_volume / seconds;
92 while ( this->
getStatus() != SoundStatus::Paused && this->
getStatus() != SoundStatus::Stopped )
94 if ( current_volume > 0.0 )
96 std::cout <<
"\nFading out\n";
98 NOM_DUMP_VAR ( current_volume );
102 std::cout <<
"\nStopped\n";
106 current_volume = current_volume - fade_step;
void setVolume(float gain)
SoundStatus getStatus(void) const
Obtain current state of sound.
float getVolume(void) const
uint32 source_id
Source identification; used by OpenAL.