Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

Music.cpp

Go to the documentation of this file.
00001 
00007 #include "Music.h"
00008 
00009 Music::Music() {
00010         mod = NULL;
00011 }
00012 
00013 Music::~Music() {
00014         //unload();
00015 }
00016 
00017 bool Music::load(const char *filename) {
00018         playing = false;
00019         mod = FMUSIC_LoadSong(filename);
00020         if (!mod) {
00021                 LOG_ERROR(("%s\n", FMOD_ErrorString(FSOUND_GetError())));
00022                 return false;
00023         }
00024 
00025         LOG_SUCCESS(("Music << %s >> loaded", filename));
00026         return true;
00027 }
00028 
00029 bool Music::unload() {
00030         FMUSIC_FreeSong(mod);
00031 
00032         LOG_SUCCESS(("Music unloaded"));
00033         return true;
00034 }
00035 
00036 void Music::play(int volume) {
00037         if (playing)
00038                 return;
00039 
00040         volume = (volume > 255) ? 255 : ((volume < 0) ? 0 : volume);
00041         FMUSIC_SetMasterVolume(mod, volume);
00042         FMUSIC_PlaySong(mod);
00043         playing = true;
00044 }
00045 
00046 void Music::stop() {
00047         if (playing) {
00048                 FMUSIC_StopSong(mod);
00049                 playing = false;
00050         }
00051 }

Generated on Sun Jun 5 15:47:04 2005 for Defacto by  doxygen 1.4.3