Generate an accompaniement for a given melody
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Track Class Reference

Public Member Functions

 Track (const std::string &filename)
 Initializes the track from the sound described in the filename The sound can be abc, midi, mp3 The volume is at max, repeat is set to false, speed is set to 1 the sound is in pause, and mute is set to false. More...
 
 Track ()
 Creates an invalid Track The volume is at max, repeat is set to false, speed i set to 1 and mute is set to false.
 
 Track (const Track &)=delete
 
Trackoperator= (const Track &)=delete
 
void play ()
 If the Track is valid, plays the sound.
 
void pause ()
 If the Track is valid, pauses the sound.
 
Time getDuration () const
 If the track is valid, returns the duration of the sound at the current speed, otherwise, returns 0. More...
 
void setVolume (float vol)
 Sets the Volume of the sound (or sets the volume for future use). This function does not unmute if it is mute. More...
 
float getVolume () const
 Returns the volume of the sound independently of its validity The value does not depend on the "mute" state. More...
 
void setSound (const std::string &filename)
 Sets the Track to a new Sound The speed is reset to the speed of the new Sound, the volume, the repeat and mute options are kept unchanged. More...
 
 operator bool () const
 
void mute ()
 Mutes the sound.
 
void unmute ()
 Unmutes the Sound.
 
bool isMute () const
 return whether the sound is muted (independently of its validity)
 
void setSpeed (float s)
 Sets the speed. A speed of 2 corresponds to twice the normal speed. More...
 
float getSpeed () const
 returns the speed
 
void close ()
 Closes the sound (The Track becomes invalid)
 
void setRepeat (bool repeat)
 Set the repeat option independently of the validity of the track.
 
bool getRepeat () const
 Return the repeat state independently of the validity of the track.
 
void setPosition (const Time &t)
 If the track is valid, sets the position in the track, otherwise it does nothing.
 
Time getPosition () const
 Returns the position in the Track (taking the speed into account) if the Track is valid, 0 otherwise.
 
 ~Track ()
 The Music stops when the object is destroyed.
 
void stop ()
 
bool isFinished () const
 
bool isPaused () const
 

Constructor & Destructor Documentation

Track::Track ( const std::string &  filename)

Initializes the track from the sound described in the filename The sound can be abc, midi, mp3 The volume is at max, repeat is set to false, speed is set to 1 the sound is in pause, and mute is set to false.

Parameters
Filenameis the location of the sound
Exceptions
std::runtime_error("Unableto load file")

Member Function Documentation

Time Track::getDuration ( ) const

If the track is valid, returns the duration of the sound at the current speed, otherwise, returns 0.

Returns
The duration of the sound at the current speed if the track is valid, otherwise 0
float Track::getVolume ( ) const

Returns the volume of the sound independently of its validity The value does not depend on the "mute" state.

Returns
Returns the volume of the sound.
Track::operator bool ( ) const
Returns
if the track is valid
void Track::setSound ( const std::string &  filename)

Sets the Track to a new Sound The speed is reset to the speed of the new Sound, the volume, the repeat and mute options are kept unchanged.

Parameters
Filenameis the location of the sound
Exceptions
std::runtime_error("Unableto load file")
void Track::setSpeed ( float  s)

Sets the speed. A speed of 2 corresponds to twice the normal speed.

Parameters
sis the new speed
Exceptions
std::domain_error("%fis an invalid speed") if speed <0
void Track::setVolume ( float  vol)

Sets the Volume of the sound (or sets the volume for future use). This function does not unmute if it is mute.

Parameters
volis the new Volume. The Volume range is [0,1]
Exceptions
std::domain_error("%fis an invalid volume")

The documentation for this class was generated from the following file: