00001 #ifndef _OF_SAMPLE_SOUND 00002 #define _OF_SAMPLE_SOUND 00003 00004 #include "ofConstants.h" 00005 00006 #ifndef TARGET_OF_IPHONE 00007 extern "C" { 00008 #include "fmod.h" 00009 #include "fmod_errors.h" 00010 } 00011 #endif 00012 00013 // TO DO : 00014 // --------------------------- 00015 // -fft via fmod, as in the last time... 00016 // -close fmod if it's up 00017 // -loadSoundForStreaming(char * fileName); 00018 // --------------------------- 00019 00020 // interesting: 00021 // http://www.compuphase.com/mp3/mp3loops.htm 00022 00023 00024 // ---------------------------------------------------------------------------- SOUND SYSTEM FMOD 00025 00026 // --------------------- global functions: 00027 void ofSoundStopAll(); 00028 void ofSoundSetVolume(float vol); 00029 float * ofSoundGetSpectrum(int nBands); // max 512... 00030 00031 00032 // --------------------- player functions: 00033 class ofSoundPlayer { 00034 00035 public: 00036 00037 ofSoundPlayer(); 00038 virtual ~ofSoundPlayer(); 00039 00040 void loadSound(string fileName, bool stream = false); 00041 void unloadSound(); 00042 void play(); 00043 void stop(); 00044 00045 void setVolume(float vol); 00046 void setPan(float vol); 00047 void setSpeed(float spd); 00048 void setPaused(bool bP); 00049 void setLoop(bool bLp); 00050 void setMultiPlay(bool bMp); 00051 void setPosition(float pct); // 0 = start, 1 = end; 00052 00053 float getPosition(); 00054 bool getIsPlaying(); 00055 float getSpeed(); 00056 float getPan(); 00057 00058 static void initializeFmod(); 00059 static void closeFmod(); 00060 00061 bool isStreaming; 00062 bool bMultiPlay; 00063 bool bLoop; 00064 bool bLoadedOk; 00065 bool bPaused; 00066 float pan; // 0 - 1 00067 float volume; // 0 - 1 00068 float internalFreq; // 44100 ? 00069 float speed; // -n to n, 1 = normal, -1 backwards 00070 unsigned int length; // in samples; 00071 00072 #ifndef TARGET_OF_IPHONE 00073 FMOD_RESULT result; 00074 FMOD_CHANNEL * channel; 00075 FMOD_SOUND * sound; 00076 #endif 00077 }; 00078 00079 #endif // _OF_SAMPLE_SOUND