RioEngine  0.1
My first attempt to create a 3D WYSIWYG Game Engine
ik_ISoundEngine.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2014 Nikolaus Gebhardt
2 // This file is part of the "irrKlang" library.
3 // For conditions of distribution and use, see copyright notice in irrKlang.h
4 
5 #ifndef __I_IRRKLANG_SOUND_ENGINE_H_INCLUDED__
6 #define __I_IRRKLANG_SOUND_ENGINE_H_INCLUDED__
7 
8 #include "ik_IRefCounted.h"
9 #include "ik_vec3d.h"
10 #include "ik_ISoundSource.h"
11 #include "ik_ISound.h"
12 #include "ik_EStreamModes.h"
13 #include "ik_IFileFactory.h"
15 
16 
17 namespace irrklang
18 {
19  class IAudioStreamLoader;
20  struct SInternalAudioInterface;
21 
23 
26  class ISoundEngine : public virtual irrklang::IRefCounted
27  {
28  public:
29 
31 
33  virtual const char* getDriverName() = 0;
34 
36 
56  virtual ISound* play2D(const char* soundFileName,
57  bool playLooped = false,
58  bool startPaused = false,
59  bool track = false,
60  E_STREAM_MODE streamMode = ESM_AUTO_DETECT,
61  bool enableSoundEffects = false) = 0;
62 
64 
84  virtual ISound* play2D(ISoundSource* source,
85  bool playLooped = false,
86  bool startPaused = false,
87  bool track = false,
88  bool enableSoundEffects = false) = 0;
89 
91 
113  virtual ISound* play3D(const char* soundFileName, vec3df pos,
114  bool playLooped = false,
115  bool startPaused = false,
116  bool track = false,
117  E_STREAM_MODE streamMode = ESM_AUTO_DETECT,
118  bool enableSoundEffects = false) = 0;
119 
121 
142  virtual ISound* play3D(ISoundSource* source, vec3df pos,
143  bool playLooped = false,
144  bool startPaused = false,
145  bool track = false,
146  bool enableSoundEffects = false) = 0;
147 
149  virtual void stopAllSounds() = 0;
150 
152  virtual void setAllSoundsPaused( bool bPaused = true ) = 0;
153 
155 
165  virtual ISoundSource* getSoundSource(const ik_c8* soundName, bool addIfNotFound=true) = 0;
166 
168 
173  virtual ISoundSource* getSoundSource(ik_s32 index) = 0;
174 
176  virtual ik_s32 getSoundSourceCount() = 0;
177 
179 
191  bool preload=false) = 0;
192 
194 
212  virtual ISoundSource* addSoundSourceFromMemory(void* memory, ik_s32 sizeInBytes, const ik_c8* soundName,
213  bool copyMemory=true) = 0;
214 
215 
217 
229  virtual ISoundSource* addSoundSourceFromPCMData(void* memory, ik_s32 sizeInBytes,
230  const ik_c8* soundName, SAudioStreamFormat format,
231  bool copyMemory=true) = 0;
232 
234 
243  virtual ISoundSource* addSoundSourceAlias(ISoundSource* baseSource, const ik_c8* soundName) = 0;
244 
246 
251  virtual void removeSoundSource(ISoundSource* source) = 0;
252 
254 
259  virtual void removeSoundSource(const ik_c8* name) = 0;
260 
262 
265  virtual void removeAllSoundSources() = 0;
266 
268 
269  virtual void setSoundVolume(ik_f32 volume) = 0;
270 
272  /* A value between 0.0 and 1.0. Default is 1.0. Can be changed using setSoundVolume(). */
273  virtual ik_f32 getSoundVolume() = 0;
274 
276 
285  virtual void setListenerPosition(const vec3df& pos,
286  const vec3df& lookdir,
287  const vec3df& velPerSecond = vec3df(0,0,0),
288  const vec3df& upVector = vec3df(0,1,0)) = 0;
289 
291 
296  virtual void update() = 0;
297 
299  virtual bool isCurrentlyPlaying(const char* soundName) = 0;
300 
302  virtual bool isCurrentlyPlaying(ISoundSource* source) = 0;
303 
305 
308  virtual void registerAudioStreamLoader(IAudioStreamLoader* loader) = 0;
309 
311 
312  virtual bool isMultiThreaded() const = 0;
313 
315 
317  virtual void addFileFactory(IFileFactory* fileFactory) = 0;
318 
320 
327  virtual void setDefault3DSoundMinDistance(ik_f32 minDistance) = 0;
328 
330 
336  virtual ik_f32 getDefault3DSoundMinDistance() = 0;
337 
339 
350  virtual void setDefault3DSoundMaxDistance(ik_f32 maxDistance) = 0;
351 
353 
363  virtual ik_f32 getDefault3DSoundMaxDistance() = 0;
364 
366 
369  virtual void setRolloffFactor(ik_f32 rolloff) = 0;
370 
372 
380  virtual void setDopplerEffectParameters(ik_f32 dopplerFactor=1.0f, ik_f32 distanceFactor=1.0f) = 0;
381 
383 
392  virtual bool loadPlugins(const ik_c8* path) = 0;
393 
395 
398 
400 
404  virtual bool setMixedDataOutputReceiver(ISoundMixedOutputReceiver* receiver) = 0;
405  };
406 
407 
409 
411  {
414 
417 
420 
423 
426  };
427 
428 
429 
430 } // end namespace irrklang
431 
432 
433 #endif
virtual void stopAllSounds()=0
Stops all currently playing sounds.
structure describing an audio stream format with helper functions
a 3d vector template class for representing vectors and points in 3d
Definition: ik_vec3d.h:17
virtual void setSoundVolume(ik_f32 volume)=0
Sets master sound volume. This value is multiplied with all sounds played.
virtual ik_f32 getDefault3DSoundMinDistance()=0
Returns the default minimal distance for 3D sounds.
virtual bool isMultiThreaded() const =0
Returns if irrKlang is running in the same thread as the application or is using multithreading.
virtual ISoundSource * addSoundSourceFromFile(const ik_c8 *fileName, E_STREAM_MODE mode=ESM_AUTO_DETECT, bool preload=false)=0
Adds sound source into the sound engine as file.
Base class of most objects of the irrKlang.
virtual bool setMixedDataOutputReceiver(ISoundMixedOutputReceiver *receiver)=0
Sets the OutputMixedDataReceiver, so you can receive the pure mixed output audio data while it is bei...
virtual void update()=0
Updates the audio engine. This should be called several times per frame if irrKlang was started in si...
virtual void registerAudioStreamLoader(IAudioStreamLoader *loader)=0
Registers a new audio stream loader in the sound engine.
virtual void setRolloffFactor(ik_f32 rolloff)=0
Sets a rolloff factor which influences the amount of attenuation that is applied to 3D sounds...
unsigned int ik_u32
32 bit unsigned variable.
virtual ISoundSource * getSoundSource(const ik_c8 *soundName, bool addIfNotFound=true)=0
Gets a sound source by sound name. Adds the sound source as file into the sound engine if not loaded ...
virtual const SInternalAudioInterface & getInternalAudioInterface()=0
Returns a pointer to internal sound engine pointers, like the DirectSound interface.
signed int ik_s32
32 bit signed variable.
Class which is able to create an audio file stream from a file.
char ik_c8
8 bit character variable.
virtual ik_f32 getSoundVolume()=0
Returns master sound volume.
Represents a sound which is currently played.
Definition: ik_ISound.h:24
Everything in the irrKlang Sound Engine can be found in this namespace.
E_STREAM_MODE
An enumeration for all types of supported stream modes.
void * pIDirectSound8
IDirectSound8 interface, this is not null when using the ESOD_DIRECT_SOUND8 audio driver...
A sound source describes an input file (.ogg, .mp3, .wav or similar) and its default settings...
Autodetects the best stream mode for a specified audio data.
vec3d< ik_f32 > vec3df
Typedef for a ik_f32 3d vector, a vector using floats for X, Y and Z.
Definition: ik_vec3d.h:250
void * pWinMM_HWaveOut
HWaveout interface, this is not null when using the ESOD_WIN_MM audio driver.
virtual void setDefault3DSoundMinDistance(ik_f32 minDistance)=0
Sets the default minimal distance for 3D sounds.
Interface to overwrite file access in irrKlang.
void * pALSA_SND_PCM
ALSA PCM Handle interface, this is not null when using the ESOD_ALSA audio driver.
virtual void setDefault3DSoundMaxDistance(ik_f32 maxDistance)=0
Sets the default maximal distance for 3D sounds.
virtual const char * getDriverName()=0
returns the name of the sound driver, like 'ALSA' for the alsa device
virtual ISoundSource * addSoundSourceFromMemory(void *memory, ik_s32 sizeInBytes, const ik_c8 *soundName, bool copyMemory=true)=0
Adds a sound source into the sound engine as memory source.
virtual ik_s32 getSoundSourceCount()=0
Returns amount of loaded sound sources.
virtual ISoundSource * addSoundSourceAlias(ISoundSource *baseSource, const ik_c8 *soundName)=0
Adds a sound source as alias for an existing sound source, but with a different name or optional diff...
virtual ISound * play2D(const char *soundFileName, bool playLooped=false, bool startPaused=false, bool track=false, E_STREAM_MODE streamMode=ESM_AUTO_DETECT, bool enableSoundEffects=false)=0
loads a sound source (if not loaded already) from a file and plays it.
float ik_f32
32 bit floating point variable.
Interface to be implemented by the user, which recieves the mixed output when it it played by the sou...
virtual void setListenerPosition(const vec3df &pos, const vec3df &lookdir, const vec3df &velPerSecond=vec3df(0, 0, 0), const vec3df &upVector=vec3df(0, 1, 0))=0
Sets the current listener 3d position.
virtual bool loadPlugins(const ik_c8 *path)=0
Loads irrKlang plugins from a custom path.
virtual void setAllSoundsPaused(bool bPaused=true)=0
Pauses or unpauses all currently playing sounds.
virtual void removeAllSoundSources()=0
Removes all sound sources from the engine.
virtual void setDopplerEffectParameters(ik_f32 dopplerFactor=1.0f, ik_f32 distanceFactor=1.0f)=0
Sets parameters affecting the doppler effect.
ik_u32 pCoreAudioDeciceID
AudioDeviceID handle, this is not null when using the ESOD_CORE_AUDIO audio driver.
virtual bool isCurrentlyPlaying(const char *soundName)=0
Returns if a sound with the specified name is currently playing.
virtual void addFileFactory(IFileFactory *fileFactory)=0
Adds a file factory to the sound engine, making it possible to override file access of the sound engi...
structure for returning pointers to the internal audio interface.
virtual ISoundSource * addSoundSourceFromPCMData(void *memory, ik_s32 sizeInBytes, const ik_c8 *soundName, SAudioStreamFormat format, bool copyMemory=true)=0
Adds a sound source into the sound engine from plain PCM data in memory.
virtual ik_f32 getDefault3DSoundMaxDistance()=0
Returns the default maximal distance for 3D sounds.
void * pIDirectSound
IDirectSound interface, this is not null when using the ESOD_DIRECT_SOUND audio driver.
Interface to the sound engine, for playing 3d and 2d sound and music.
virtual ISound * play3D(const char *soundFileName, vec3df pos, bool playLooped=false, bool startPaused=false, bool track=false, E_STREAM_MODE streamMode=ESM_AUTO_DETECT, bool enableSoundEffects=false)=0
Loads a sound source (if not loaded already) from a file and plays it as 3D sound.
virtual void removeSoundSource(ISoundSource *source)=0
Removes a sound source from the engine, freeing the memory it occupies.