Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __SP_AUDIO_SOUNDDEVICE_H__
00009 #define __SP_AUDIO_SOUNDDEVICE_H__
00010
00011
00012 #include "Base/spStandard.hpp"
00013 #include "Base/spInputOutput.hpp"
00014 #include "SoundSystem/spSound.hpp"
00015 #include "SoundSystem/spSoundEffect.hpp"
00016 #include "FileFormats/Sound/spSoundLoader.hpp"
00017
00018 #include <list>
00019 #include <stdio.h>
00020
00021
00022 namespace sp
00023 {
00024
00025 class SoftPixelDevice;
00026
00027 #if defined(SP_PLATFORM_LINUX)
00028 class SoftPixelDeviceLinux;
00029 #endif
00030
00031 namespace audio
00032 {
00033
00034
00035
00036
00037
00038
00040 enum ESoundDevices
00041 {
00042 SOUNDDEVICE_AUTODETECT,
00043 SOUNDDEVICE_OPENAL,
00044 SOUNDDEVICE_XAUDIO2,
00045 SOUNDDEVICE_OPENSLES,
00046 SOUNDDEVICE_WINMM,
00047 SOUNDDEVICE_DUMMY,
00048 };
00049
00051 enum ENoteNames
00052 {
00053 NOTE_C = 0,
00054 NOTE_H_SHARP = 0,
00055 NOTE_C_SHARP = 1,
00056 NOTE_D_FLAT = 1,
00057 NOTE_D = 2,
00058 NOTE_D_SHARP = 3,
00059 NOTE_E_FLAT = 3,
00060 NOTE_E = 4,
00061 NOTE_F_FLAT = 4,
00062 NOTE_F = 5,
00063 NOTE_E_SHARP = 5,
00064 NOTE_F_SHARP = 6,
00065 NOTE_G_FLAT = 6,
00066 NOTE_G = 7,
00067 NOTE_G_SHARP = 8,
00068 NOTE_A_FLAT = 8,
00069 NOTE_A = 9,
00070 NOTE_A_SHARP = 10,
00071 NOTE_H_FLAT = 10,
00072 NOTE_H = 11,
00073 NOTE_C_FLAT = 11,
00074 };
00075
00076
00081 class SP_EXPORT SoundDevice
00082 {
00083
00084 public:
00085
00086 virtual ~SoundDevice();
00087
00088
00089
00091 virtual io::stringc getVersion() const;
00092
00094 virtual io::stringc getInterface() const = 0;
00095
00097 void printConsoleHeader();
00098
00100 virtual void updateSounds();
00101
00106 virtual Sound* createSound() = 0;
00107
00115 virtual Sound* loadSound(const io::stringc &Filename, u8 BufferCount = DEF_SOUND_BUFFERCOUNT);
00116
00118 virtual void deleteSound(Sound* &SoundObject);
00119
00124 virtual SoundEffect* createSoundEffect();
00126 virtual void deleteSoundDevice(SoundEffect* &SoundEffectObject);
00127
00128
00129
00134 virtual void setListenerPosition(const dim::vector3df &Position);
00135
00140 virtual void setListenerVelocity(const dim::vector3df &Velocity);
00141
00147 virtual void setListenerOrientation(const dim::matrix4f &Orientation);
00148
00157 virtual void setListenerRange(const f32 NearDist, const f32 FarDist, const f32 NearVol, const f32 FarVol);
00158 virtual void getListenerRange(f32 &NearDist, f32 &FarDist, f32 &NearVol, f32 &FarVol) const;
00159
00161 virtual void setListenerSpeed(f32 Speed);
00163 virtual f32 getListenerSpeed() const;
00164
00170 virtual void setEffectSlot(SoundEffect* Sfx);
00171
00172
00173
00184 SAudioBufferPtr loadAudioPCMBuffer(const io::stringc &Filename);
00185
00186
00187
00189 inline dim::vector3df getListenerPosition() const
00190 {
00191 return ListenerPosition_;
00192 }
00194 inline dim::vector3df getListenerVelocity() const
00195 {
00196 return ListenerVelocity_;
00197 }
00199 inline dim::matrix4f getListenerOrientation() const
00200 {
00201 return ListenerOrientation_;
00202 }
00203
00205 inline SoundEffect* getEffectSlot() const
00206 {
00207 return ActiveEffectSlot_;
00208 }
00209
00210
00211
00212 static void setMelodySpeed(f32 Speed);
00213
00222 static void playMelody(const ENoteNames Note, u8 Octave = 3, u32 Duration = 250, u32 Delay = 0);
00223
00236 static void playMelody(io::stringc MelodyCmdStr);
00237
00238 protected:
00239
00240 friend class sp::SoftPixelDevice;
00241
00242 #if defined(SP_PLATFORM_LINUX)
00243 friend class sp::SoftPixelDeviceLinux;
00244 #endif
00245
00246
00247
00248 SoundDevice(const ESoundDevices DeviceType);
00249
00250 virtual void updateSoundVolumetic(Sound* CurSound);
00251
00252
00253
00254 ESoundDevices DeviceType_;
00255
00256 std::list<Sound*> SoundList_;
00257 std::list<SoundEffect*> SoundEffectList_;
00258
00259 dim::vector3df ListenerPosition_;
00260 dim::vector3df ListenerVelocity_;
00261 dim::matrix4f ListenerOrientation_;
00262
00263 f32 NearVol_, FarVol_, MiddleVol_;
00264 f32 NearDist_, FarDist_, MiddleDist_;
00265
00266 f32 ListenerSpeed_;
00267
00268 SoundEffect* ActiveEffectSlot_;
00269
00270 static f32 MelodySpeed_;
00271
00272 };
00273
00274
00275 }
00276
00277 }
00278
00279
00280 #endif
00281
00282
00283
00284