00001 // ///////////////////////////////////////////////////////////////////////////// 00002 // 00003 // Name: SoundSourceComponent.h 00004 // Author: Michael Bartsch (ZCCdark203) 00005 // 00006 // Desc : Declaration of the SoundSourceComponent class. 00007 // 00008 // License: Copyright (C) 2009 Michael Bartsch and Contributors 00009 // 00010 // This program is free software: you can redistribute it 00011 // and/or modify it under the terms of the zlib/libpng License. 00012 // See main.cpp for conditions of distribution and use. 00013 // 00014 // ///////////////////////////////////////////////////////////////////////////// 00015 00016 #ifndef __SOUNDSOURCECOMPONENT_H__ 00017 #define __SOUNDSOURCECOMPONENT_H__ 00018 00019 // Include files 00020 #include "../../dependencies.h" 00021 #include "../../core/EntityComponent.h" 00022 00023 00024 // SoundSourceComponent class 00026 class SoundSourceComponent : public EntityComponent 00027 { 00028 public: 00029 00030 // Initialisation and deinitialisation 00033 SoundSourceComponent(Entity *parent); 00035 ~SoundSourceComponent(); 00036 00037 // AngelScript binding 00040 static SoundSourceComponent* refFactory(Entity *parent); 00041 00042 // Methods 00045 sf::Sound* getSound(); 00048 sf::Music* getMusic(); 00049 00052 bool loadMusic(const std::string &fileName); 00056 bool loadSoundBuffer(const std::string &bufferName); 00057 00059 void unloadData(); 00060 00062 void play(); 00064 void pause(); 00066 void stop(); 00067 00069 f32 getAttenuation() const; 00071 bool getIsPaused() const; 00073 bool getIsPlaying() const; 00075 bool getIsStopped() const; 00077 bool getLoop() const; 00079 f32 getMinDistance() const; 00082 f32 getOffset() const; 00084 f32 getPitch() const; 00086 f32 getVolume() const; 00087 00092 void setAttenuation(f32 attenuation); 00095 void setLoop(bool value); 00098 void setMinDistance(f32 minDistance); 00101 void setOffset(f32 offset); 00103 void setPitch(f32 pitch); 00105 void setVolume(f32 volume); 00106 00107 // Events 00110 void onPositionChange(void *p); 00113 void onPause(void *p); 00116 void onUnPause(void *p); 00117 00118 private: 00119 00120 // Members 00121 sf::Sound *mSound; 00122 sf::Music *mMusic; 00123 00124 c8 *mBuffer; 00125 long mBufferSize; 00126 00127 f32 mAttenuation; 00128 bool mLoop; 00129 f32 mMinDistance; 00130 f32 mPitch; 00131 vector3df mPosition; 00132 f32 mVolume; 00133 00134 bool mWasPaused; 00135 00136 }; 00137 00138 00139 // SoundSourceComponent Angelscript binding. 00141 extern void bindSoundSourceComponent(asIScriptEngine *engine); 00142 00143 #endif 00144