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

Sound.cpp

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

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