* Forgot include files for irrklang in last commit

This commit is contained in:
Shlainn 2010-08-18 15:58:30 +02:00
parent 87b5a5f765
commit 1fede6d76c
20 changed files with 3012 additions and 2950 deletions

View File

@ -1,78 +1,78 @@
// Copyright (C) 2002-2008 Nikolaus Gebhardt // Copyright (C) 2002-2009 Nikolaus Gebhardt
// This file is part of the "irrKlang" library. // This file is part of the "irrKlang" library.
// For conditions of distribution and use, see copyright notice in irrKlang.h // For conditions of distribution and use, see copyright notice in irrKlang.h
#ifndef __E_IRRKLANG_SOUND_ENGINE_OPTIONS_H_INCLUDED__ #ifndef __E_IRRKLANG_SOUND_ENGINE_OPTIONS_H_INCLUDED__
#define __E_IRRKLANG_SOUND_ENGINE_OPTIONS_H_INCLUDED__ #define __E_IRRKLANG_SOUND_ENGINE_OPTIONS_H_INCLUDED__
namespace irrklang namespace irrklang
{ {
//! An enumeration for all options for starting up the sound engine //! An enumeration for all options for starting up the sound engine
/** When using createIrrKlangDevice, use a combination of this these /** When using createIrrKlangDevice, use a combination of this these
as 'options' parameter to start up the engine. By default, irrKlang as 'options' parameter to start up the engine. By default, irrKlang
uses ESEO_DEFAULT_OPTIONS, which is set to the combination uses ESEO_DEFAULT_OPTIONS, which is set to the combination
ESEO_MULTI_THREADED | ESEO_LOAD_PLUGINS | ESEO_USE_3D_BUFFERS | ESEO_PRINT_DEBUG_INFO_TO_DEBUGGER | ESEO_PRINT_DEBUG_INFO_TO_STDOUT. */ ESEO_MULTI_THREADED | ESEO_LOAD_PLUGINS | ESEO_USE_3D_BUFFERS | ESEO_PRINT_DEBUG_INFO_TO_DEBUGGER | ESEO_PRINT_DEBUG_INFO_TO_STDOUT. */
enum E_SOUND_ENGINE_OPTIONS enum E_SOUND_ENGINE_OPTIONS
{ {
//! If specified (default), it will make irrKlang run in a separate thread. //! If specified (default), it will make irrKlang run in a separate thread.
/** Using this flag, irrKlang will update /** Using this flag, irrKlang will update
all streams, sounds, 3d positions and whatever automaticly. You also don't need to call ISoundEngine::update() all streams, sounds, 3d positions and whatever automaticly. You also don't need to call ISoundEngine::update()
if irrKlang is running multithreaded. However, if you want to run irrKlang in the same thread if irrKlang is running multithreaded. However, if you want to run irrKlang in the same thread
as your application (for easier debugging for example), don't set this. But you need to call ISoundEngine::update() as your application (for easier debugging for example), don't set this. But you need to call ISoundEngine::update()
as often as you can (at least about 2-3 times per second) to make irrKlang update everything correctly then. */ as often as you can (at least about 2-3 times per second) to make irrKlang update everything correctly then. */
ESEO_MULTI_THREADED = 0x01, ESEO_MULTI_THREADED = 0x01,
//! If the window of the application doesn't have the focus, irrKlang will be silent if this has been set. //! If the window of the application doesn't have the focus, irrKlang will be silent if this has been set.
/** This will only work when irrKlang is using the DirectSound output driver. */ /** This will only work when irrKlang is using the DirectSound output driver. */
ESEO_MUTE_IF_NOT_FOCUSED = 0x02, ESEO_MUTE_IF_NOT_FOCUSED = 0x02,
//! Automaticly loads external plugins when starting up. //! Automaticly loads external plugins when starting up.
/** Plugins usually are .dll, .so or .dylib /** Plugins usually are .dll, .so or .dylib
files named for example ikpMP3.dll (= short for irrKlangPluginMP3) which are executed files named for example ikpMP3.dll (= short for irrKlangPluginMP3) which are executed
after the startup of the sound engine and modify it for example to make it possible after the startup of the sound engine and modify it for example to make it possible
to play back mp3 files. Plugins are being loaded from the current working directory to play back mp3 files. Plugins are being loaded from the current working directory
as well as from the position where the .exe using the irrKlang library resides. as well as from the position where the .exe using the irrKlang library resides.
It is also possible to load the plugins after the engine has started up using It is also possible to load the plugins after the engine has started up using
ISoundEngine::loadPlugins(). */ ISoundEngine::loadPlugins(). */
ESEO_LOAD_PLUGINS = 0x04, ESEO_LOAD_PLUGINS = 0x04,
//! Uses 3D sound buffers instead of emulating them when playing 3d sounds (default). //! Uses 3D sound buffers instead of emulating them when playing 3d sounds (default).
/** If this flag is not specified, all buffers will by created /** If this flag is not specified, all buffers will by created
in 2D only and 3D positioning will be emulated in software, making the engine run in 2D only and 3D positioning will be emulated in software, making the engine run
faster if hardware 3d audio is slow on the system. */ faster if hardware 3d audio is slow on the system. */
ESEO_USE_3D_BUFFERS = 0x08, ESEO_USE_3D_BUFFERS = 0x08,
//! Prints debug messages to the debugger window. //! Prints debug messages to the debugger window.
/** irrKlang will print debug info and status messages to any windows debugger supporting /** irrKlang will print debug info and status messages to any windows debugger supporting
OutputDebugString() (like VisualStudio). OutputDebugString() (like VisualStudio).
This is useful if your application does not capture any console output (see ESEO_PRINT_DEBUG_INFO_TO_STDOUT). */ This is useful if your application does not capture any console output (see ESEO_PRINT_DEBUG_INFO_TO_STDOUT). */
ESEO_PRINT_DEBUG_INFO_TO_DEBUGGER = 0x10, ESEO_PRINT_DEBUG_INFO_TO_DEBUGGER = 0x10,
//! Prints debug messages to stdout (the ConsoleWindow). //! Prints debug messages to stdout (the ConsoleWindow).
/** irrKlang will print debug info and status messages stdout, the console window in Windows. */ /** irrKlang will print debug info and status messages stdout, the console window in Windows. */
ESEO_PRINT_DEBUG_INFO_TO_STDOUT = 0x20, ESEO_PRINT_DEBUG_INFO_TO_STDOUT = 0x20,
//! Uses linear rolloff for 3D sound. //! Uses linear rolloff for 3D sound.
/** If specified, instead of the default logarithmic one, irrKlang will /** If specified, instead of the default logarithmic one, irrKlang will
use a linear rolloff model which influences the attenuation use a linear rolloff model which influences the attenuation
of the sounds over distance. The volume is interpolated linearly between the MinDistance of the sounds over distance. The volume is interpolated linearly between the MinDistance
and MaxDistance, making it possible to adjust sounds more easily although this is not and MaxDistance, making it possible to adjust sounds more easily although this is not
physically correct. physically correct.
Note that this option may not work when used together with the ESEO_USE_3D_BUFFERS Note that this option may not work when used together with the ESEO_USE_3D_BUFFERS
option when using Direct3D for example, irrKlang will then turn off ESEO_USE_3D_BUFFERS option when using Direct3D for example, irrKlang will then turn off ESEO_USE_3D_BUFFERS
automaticly to be able to use this option and write out a warning. */ automaticly to be able to use this option and write out a warning. */
ESEO_LINEAR_ROLLOFF = 0x40, ESEO_LINEAR_ROLLOFF = 0x40,
//! Default parameters when starting up the engine. //! Default parameters when starting up the engine.
ESEO_DEFAULT_OPTIONS = ESEO_MULTI_THREADED | ESEO_LOAD_PLUGINS | ESEO_USE_3D_BUFFERS | ESEO_PRINT_DEBUG_INFO_TO_DEBUGGER | ESEO_PRINT_DEBUG_INFO_TO_STDOUT, ESEO_DEFAULT_OPTIONS = ESEO_MULTI_THREADED | ESEO_LOAD_PLUGINS | ESEO_USE_3D_BUFFERS | ESEO_PRINT_DEBUG_INFO_TO_DEBUGGER | ESEO_PRINT_DEBUG_INFO_TO_STDOUT,
//! Never used, it only forces the compiler to compile these enumeration values to 32 bit. //! Never used, it only forces the compiler to compile these enumeration values to 32 bit.
/** Don't use this. */ /** Don't use this. */
ESEO_FORCE_32_BIT = 0x7fffffff ESEO_FORCE_32_BIT = 0x7fffffff
}; };
} // end namespace irrklang } // end namespace irrklang
#endif #endif

View File

@ -1,56 +1,59 @@
// Copyright (C) 2002-2008 Nikolaus Gebhardt // Copyright (C) 2002-2009 Nikolaus Gebhardt
// This file is part of the "irrKlang" library. // This file is part of the "irrKlang" library.
// For conditions of distribution and use, see copyright notice in irrKlang.h // For conditions of distribution and use, see copyright notice in irrKlang.h
#ifndef __E_IRRKLANG_SOUND_OUTPUT_DRIVERS_H_INCLUDED__ #ifndef __E_IRRKLANG_SOUND_OUTPUT_DRIVERS_H_INCLUDED__
#define __E_IRRKLANG_SOUND_OUTPUT_DRIVERS_H_INCLUDED__ #define __E_IRRKLANG_SOUND_OUTPUT_DRIVERS_H_INCLUDED__
namespace irrklang namespace irrklang
{ {
//! An enumeration for all types of supported sound drivers //! An enumeration for all types of supported sound drivers
/** Values of this enumeration can be used as parameter when calling createIrrKlangDevice(). */ /** Values of this enumeration can be used as parameter when calling createIrrKlangDevice(). */
enum E_SOUND_OUTPUT_DRIVER enum E_SOUND_OUTPUT_DRIVER
{ {
//! Autodetects the best sound driver for the system //! Autodetects the best sound driver for the system
ESOD_AUTO_DETECT = 0, ESOD_AUTO_DETECT = 0,
//! DirectSound8 sound output driver, windows only. //! DirectSound8 sound output driver, windows only.
/** In contrast to ESOD_DIRECT_SOUND, this supports sophisticated sound effects /** In contrast to ESOD_DIRECT_SOUND, this supports sophisticated sound effects
but may not be available on old windows versions. It behaves very similar but may not be available on old windows versions. It behaves very similar
to ESOD_DIRECT_SOUND but also supports DX8 sound effects.*/ to ESOD_DIRECT_SOUND but also supports DX8 sound effects.*/
ESOD_DIRECT_SOUND_8, ESOD_DIRECT_SOUND_8,
//! DirectSound sound output driver, windows only. //! DirectSound sound output driver, windows only.
/* This uses DirectSound 3 or above, if available. If DX8 sound effects /** This uses DirectSound 3 or above, if available. If DX8 sound effects
are needed, use ESOD_DIRECT_SOUND_8 instead. The are needed, use ESOD_DIRECT_SOUND_8 instead. The
ESOD_DIRECT_SOUND driver may be available on more and older windows ESOD_DIRECT_SOUND driver may be available on more and older windows
versions than ESOD_DIRECT_SOUND_8.*/ versions than ESOD_DIRECT_SOUND_8.*/
ESOD_DIRECT_SOUND, ESOD_DIRECT_SOUND,
//! WinMM sound output driver, windows only. //! WinMM sound output driver, windows only.
ESOD_WIN_MM, /** Supports the ISoundMixedOutputReceiver interface using setMixedDataOutputReceiver. */
ESOD_WIN_MM,
//! ALSA sound output driver, linux only.
/* When using ESOD_ALSA in createIrrKlangDevice(), it is possible to set the third parameter, //! ALSA sound output driver, linux only.
'deviceID' to the name of specific ALSA pcm device, to the irrKlang force to use this one. /** When using ESOD_ALSA in createIrrKlangDevice(), it is possible to set the third parameter,
Set it to 'default', or 'plug:hw' or whatever you need it to be.*/ 'deviceID' to the name of specific ALSA pcm device, to the irrKlang force to use this one.
ESOD_ALSA, Set it to 'default', or 'plug:hw' or whatever you need it to be.
Supports the ISoundMixedOutputReceiver interface using setMixedDataOutputReceiver. */
//! Core Audio sound output driver, mac os only. ESOD_ALSA,
ESOD_CORE_AUDIO,
//! Core Audio sound output driver, mac os only.
//! Null driver, creating no sound output /** Supports the ISoundMixedOutputReceiver interface using setMixedDataOutputReceiver. */
ESOD_NULL, ESOD_CORE_AUDIO,
//! Amount of built-in sound output drivers //! Null driver, creating no sound output
ESOD_COUNT, ESOD_NULL,
//! This enumeration literal is never used, it only forces the compiler to //! Amount of built-in sound output drivers
//! compile these enumeration values to 32 bit. ESOD_COUNT,
ESOD_FORCE_32_BIT = 0x7fffffff
}; //! This enumeration literal is never used, it only forces the compiler to
//! compile these enumeration values to 32 bit.
} // end namespace irrklang ESOD_FORCE_32_BIT = 0x7fffffff
};
#endif
} // end namespace irrklang
#endif

View File

@ -1,31 +1,31 @@
// Copyright (C) 2002-2008 Nikolaus Gebhardt // Copyright (C) 2002-2009 Nikolaus Gebhardt
// This file is part of the "irrKlang" library. // This file is part of the "irrKlang" library.
// For conditions of distribution and use, see copyright notice in irrKlang.h // For conditions of distribution and use, see copyright notice in irrKlang.h
#ifndef __E_IRRKLANG_STREAM_MODES_H_INCLUDED__ #ifndef __E_IRRKLANG_STREAM_MODES_H_INCLUDED__
#define __E_IRRKLANG_STREAM_MODES_H_INCLUDED__ #define __E_IRRKLANG_STREAM_MODES_H_INCLUDED__
namespace irrklang namespace irrklang
{ {
//! An enumeration for all types of supported stream modes //! An enumeration for all types of supported stream modes
enum E_STREAM_MODE enum E_STREAM_MODE
{ {
//! Autodetects the best stream mode for a specified audio data. //! Autodetects the best stream mode for a specified audio data.
ESM_AUTO_DETECT = 0, ESM_AUTO_DETECT = 0,
//! Streams the audio data when needed. //! Streams the audio data when needed.
ESM_STREAMING, ESM_STREAMING,
//! Loads the whole audio data into the memory. //! Loads the whole audio data into the memory.
ESM_NO_STREAMING, ESM_NO_STREAMING,
//! This enumeration literal is never used, it only forces the compiler to //! This enumeration literal is never used, it only forces the compiler to
//! compile these enumeration values to 32 bit. //! compile these enumeration values to 32 bit.
ESM_FORCE_32_BIT = 0x7fffffff ESM_FORCE_32_BIT = 0x7fffffff
}; };
} // end namespace irrklang } // end namespace irrklang
#endif #endif

View File

@ -1,104 +1,110 @@
// Copyright (C) 2002-2008 Nikolaus Gebhardt // Copyright (C) 2002-2008 Nikolaus Gebhardt
// This file is part of the "irrKlang" library. // This file is part of the "irrKlang" library.
// For conditions of distribution and use, see copyright notice in irrKlang.h // For conditions of distribution and use, see copyright notice in irrKlang.h
#ifndef __I_IRRKLANG_AUDIO_RECORDER_H_INCLUDED__ #ifndef __I_IRRKLANG_AUDIO_RECORDER_H_INCLUDED__
#define __I_IRRKLANG_AUDIO_RECORDER_H_INCLUDED__ #define __I_IRRKLANG_AUDIO_RECORDER_H_INCLUDED__
#include "ik_IRefCounted.h" #include "ik_IRefCounted.h"
#include "ik_ISoundSource.h" #include "ik_ISoundSource.h"
namespace irrklang namespace irrklang
{ {
class ICapturedAudioDataReceiver; class ICapturedAudioDataReceiver;
//! Interface to an audio recorder. Create it using the createIrrKlangAudioRecorder() function. //! Interface to an audio recorder. Create it using the createIrrKlangAudioRecorder() function.
/** It creates sound sources into an ISoundEngine which then can be played there. /** It creates sound sources into an ISoundEngine which then can be played there.
See @ref recordingAudio for an example on how to use this. */ See @ref recordingAudio for an example on how to use this. */
class IAudioRecorder : public virtual IRefCounted class IAudioRecorder : public virtual IRefCounted
{ {
public: public:
//! Starts recording audio. //! Starts recording audio.
/** Clears all possibly previously recorded buffered audio data and starts to record. /** Clears all possibly previously recorded buffered audio data and starts to record.
When finished recording audio data, call stopRecordingAudio(). When finished recording audio data, call stopRecordingAudio().
All recorded audio data gets stored into an internal audio buffer, which All recorded audio data gets stored into an internal audio buffer, which
can then be accessed for example using addSoundSourceFromRecordedAudio() or can then be accessed for example using addSoundSourceFromRecordedAudio() or
getRecordedAudioData(). For recording audio data not into an internal audio getRecordedAudioData(). For recording audio data not into an internal audio
buffer, use startRecordingCustomHandledAudio(). buffer, use startRecordingCustomHandledAudio().
\param sampleRate: Sample rate of the recorded audio. \param sampleRate: Sample rate of the recorded audio.
\param sampleFormat: Sample format of the recorded audio. \param sampleFormat: Sample format of the recorded audio.
\return Returns true if successfully started recording and false if not.*/ \param channelCount: Amount of audio channels.
virtual bool startRecordingBufferedAudio(ik_s32 sampleRate=22000, ESampleFormat sampleFormat=ESF_S16) = 0; \return Returns true if successfully started recording and false if not.*/
virtual bool startRecordingBufferedAudio(ik_s32 sampleRate=22000,
//! Starts recording audio. ESampleFormat sampleFormat=ESF_S16,
/** Clears all possibly previously recorded buffered audio data and starts to record ik_s32 channelCount=1) = 0;
audio data, which is delivered to a custom user callback interface.
When finished recording audio data, call stopRecordingAudio(). If instead of //! Starts recording audio.
recording the data to the receiver interface recording into a managed buffer /** Clears all possibly previously recorded buffered audio data and starts to record
is wished, use startRecordingBufferedAudio() instead. audio data, which is delivered to a custom user callback interface.
\param receiver: Interface to be implemented by the user, gets called once for each When finished recording audio data, call stopRecordingAudio(). If instead of
captured audio data chunk. recording the data to the receiver interface recording into a managed buffer
\param sampleRate: Sample rate of the recorded audio. is wished, use startRecordingBufferedAudio() instead.
\param sampleFormat: Sample format of the recorded audio. \param receiver: Interface to be implemented by the user, gets called once for each
\return Returns true if successfully started recording and false if not. */ captured audio data chunk.
virtual bool startRecordingCustomHandledAudio(ICapturedAudioDataReceiver* receiver, \param sampleRate: Sample rate of the recorded audio.
ik_s32 sampleRate=22000, ESampleFormat sampleFormat=ESF_S16) = 0; \param sampleFormat: Sample format of the recorded audio.
\param channelCount: Amount of audio channels.
//! Stops recording audio. \return Returns true if successfully started recording and false if not. */
virtual void stopRecordingAudio() = 0; virtual bool startRecordingCustomHandledAudio(ICapturedAudioDataReceiver* receiver,
ik_s32 sampleRate=22000,
//! Creates a sound source for the recorded audio data. ESampleFormat sampleFormat=ESF_S16,
/** The returned sound source pointer then can be used to play back the recorded audio data ik_s32 channelCount=1) = 0;
using ISoundEngine::play2D(). This method only will succeed if the audio was recorded using
startRecordingBufferedAudio() and audio recording is currently stopped. //! Stops recording audio.
\param soundName Name of the virtual sound file (e.g. "someRecordedAudio"). You can also use this virtual void stopRecordingAudio() = 0;
name when calling play3D() or play2D(). */
virtual ISoundSource* addSoundSourceFromRecordedAudio(const char* soundName) = 0; //! Creates a sound source for the recorded audio data.
/** The returned sound source pointer then can be used to play back the recorded audio data
//! Clears recorded audio data buffer, freeing memory. using ISoundEngine::play2D(). This method only will succeed if the audio was recorded using
/** This method will only succeed if audio recording is currently stopped. */ startRecordingBufferedAudio() and audio recording is currently stopped.
virtual void clearRecordedAudioDataBuffer() = 0; \param soundName Name of the virtual sound file (e.g. "someRecordedAudio"). You can also use this
name when calling play3D() or play2D(). */
//! Returns if the recorder is currently recording audio. virtual ISoundSource* addSoundSourceFromRecordedAudio(const char* soundName) = 0;
virtual bool isRecording() = 0;
//! Clears recorded audio data buffer, freeing memory.
//! Returns the audio format of the recorded audio data. /** This method will only succeed if audio recording is currently stopped. */
/** Also contains informations about the length of the recorded audio stream. */ virtual void clearRecordedAudioDataBuffer() = 0;
virtual SAudioStreamFormat getAudioFormat() = 0;
//! Returns if the recorder is currently recording audio.
//! Returns a pointer to the recorded audio data. virtual bool isRecording() = 0;
/** This method will only succeed if audio recording is currently stopped and
something was recorded previously using startRecordingBufferedAudio(). //! Returns the audio format of the recorded audio data.
The lenght of the buffer can be retrieved using /** Also contains informations about the length of the recorded audio stream. */
getAudioFormat().getSampleDataSize(). Note that the pointer is only valid virtual SAudioStreamFormat getAudioFormat() = 0;
as long as not clearRecordedAudioDataBuffer() is called or another sample is
recorded.*/ //! Returns a pointer to the recorded audio data.
virtual void* getRecordedAudioData() = 0; /** This method will only succeed if audio recording is currently stopped and
something was recorded previously using startRecordingBufferedAudio().
//! returns the name of the sound driver, like 'ALSA' for the alsa device. The lenght of the buffer can be retrieved using
/** Possible returned strings are "NULL", "ALSA", "CoreAudio", "winMM", getAudioFormat().getSampleDataSize(). Note that the pointer is only valid
"DirectSound" and "DirectSound8". */ as long as not clearRecordedAudioDataBuffer() is called or another sample is
virtual const char* getDriverName() = 0; recorded.*/
}; virtual void* getRecordedAudioData() = 0;
//! returns the name of the sound driver, like 'ALSA' for the alsa device.
//! Interface to be implemented by the user if access to the recorded audio data is needed. /** Possible returned strings are "NULL", "ALSA", "CoreAudio", "winMM",
/** Is used as parameter in IAudioRecorder::startRecordingCustomHandledAudio. */ "DirectSound" and "DirectSound8". */
class ICapturedAudioDataReceiver : public IRefCounted virtual const char* getDriverName() = 0;
{ };
public:
//! Gets called once for each captured audio data chunk. //! Interface to be implemented by the user if access to the recorded audio data is needed.
/** See IAudioRecorder::startRecordingCustomHandledAudio for details. /** Is used as parameter in IAudioRecorder::startRecordingCustomHandledAudio. */
\param audioData: Pointer to a part of the recorded audio data class ICapturedAudioDataReceiver : public IRefCounted
\param lengthInBytes: Amount of bytes in the audioData buffer.*/ {
virtual void OnReceiveAudioDataStreamChunk(unsigned char* audioData, unsigned long lengthInBytes) = 0; public:
};
//! Gets called once for each captured audio data chunk.
/** See IAudioRecorder::startRecordingCustomHandledAudio for details.
} // end namespace irrklang \param audioData: Pointer to a part of the recorded audio data
\param lengthInBytes: Amount of bytes in the audioData buffer.*/
virtual void OnReceiveAudioDataStreamChunk(unsigned char* audioData, unsigned long lengthInBytes) = 0;
#endif };
} // end namespace irrklang
#endif

View File

@ -1,49 +1,49 @@
// Copyright (C) 2002-2008 Nikolaus Gebhardt // Copyright (C) 2002-2009 Nikolaus Gebhardt
// This file is part of the "irrKlang" library. // This file is part of the "irrKlang" library.
// For conditions of distribution and use, see copyright notice in irrKlang.h // For conditions of distribution and use, see copyright notice in irrKlang.h
#ifndef __I_IRRKLANG_AUDIO_STREAM_H_INCLUDED__ #ifndef __I_IRRKLANG_AUDIO_STREAM_H_INCLUDED__
#define __I_IRRKLANG_AUDIO_STREAM_H_INCLUDED__ #define __I_IRRKLANG_AUDIO_STREAM_H_INCLUDED__
#include "ik_IRefCounted.h" #include "ik_IRefCounted.h"
#include "ik_SAudioStreamFormat.h" #include "ik_SAudioStreamFormat.h"
namespace irrklang namespace irrklang
{ {
//! Reads and decodes audio data into an usable audio stream for the ISoundEngine //! Reads and decodes audio data into an usable audio stream for the ISoundEngine
class IAudioStream : public IRefCounted class IAudioStream : public IRefCounted
{ {
public: public:
//! destructor //! destructor
virtual ~IAudioStream() {}; virtual ~IAudioStream() {};
//! returns format of the audio stream //! returns format of the audio stream
virtual SAudioStreamFormat getFormat() = 0; virtual SAudioStreamFormat getFormat() = 0;
//! sets the position of the audio stream. //! sets the position of the audio stream.
/** For example to let the stream be read from the beginning of the file again, /** For example to let the stream be read from the beginning of the file again,
setPosition(0) would be called. This is usually done be the sound engine to setPosition(0) would be called. This is usually done be the sound engine to
loop a stream after if has reached the end. Return true if sucessful and 0 if not. loop a stream after if has reached the end. Return true if sucessful and 0 if not.
\param pos: Position in frames.*/ \param pos: Position in frames.*/
virtual bool setPosition(ik_s32 pos) = 0; virtual bool setPosition(ik_s32 pos) = 0;
//! returns true if the audio stream is seekable //! returns true if the audio stream is seekable
/* Some file formats like (MODs) don't support seeking */ /* Some file formats like (MODs) don't support seeking */
virtual bool getIsSeekingSupported() { return true; } virtual bool getIsSeekingSupported() { return true; }
//! tells the audio stream to read frameCountToRead audio frames into the specified buffer //! tells the audio stream to read frameCountToRead audio frames into the specified buffer
/** \param target: Target data buffer to the method will write the read frames into. The /** \param target: Target data buffer to the method will write the read frames into. The
specified buffer will be at least getFormat().getFrameSize()*frameCountToRead bytes big. specified buffer will be at least getFormat().getFrameSize()*frameCountToRead bytes big.
\param frameCountToRead: amount of frames to be read. \param frameCountToRead: amount of frames to be read.
\returns Returns amount of frames really read. Should be frameCountToRead in most cases. */ \returns Returns amount of frames really read. Should be frameCountToRead in most cases. */
virtual ik_s32 readFrames(void* target, ik_s32 frameCountToRead) = 0; virtual ik_s32 readFrames(void* target, ik_s32 frameCountToRead) = 0;
}; };
} // end namespace irrklang } // end namespace irrklang
#endif #endif

View File

@ -1,40 +1,40 @@
// Copyright (C) 2002-2008 Nikolaus Gebhardt // Copyright (C) 2002-2009 Nikolaus Gebhardt
// This file is part of the "irrKlang" library. // This file is part of the "irrKlang" library.
// For conditions of distribution and use, see copyright notice in irrKlang.h // For conditions of distribution and use, see copyright notice in irrKlang.h
#ifndef __I_IRRKLANG_AUDIO_STREAM_LOADER_H_INCLUDED__ #ifndef __I_IRRKLANG_AUDIO_STREAM_LOADER_H_INCLUDED__
#define __I_IRRKLANG_AUDIO_STREAM_LOADER_H_INCLUDED__ #define __I_IRRKLANG_AUDIO_STREAM_LOADER_H_INCLUDED__
#include "ik_IRefCounted.h" #include "ik_IRefCounted.h"
#include "ik_IFileReader.h" #include "ik_IFileReader.h"
namespace irrklang namespace irrklang
{ {
class IAudioStream; class IAudioStream;
//! Class which is able to create an audio file stream from a file. //! Class which is able to create an audio file stream from a file.
class IAudioStreamLoader : public IRefCounted class IAudioStreamLoader : public IRefCounted
{ {
public: public:
//! destructor //! destructor
virtual ~IAudioStreamLoader() {}; virtual ~IAudioStreamLoader() {};
//! Returns true if the file maybe is able to be loaded by this class. //! Returns true if the file maybe is able to be loaded by this class.
/** This decision should be based only on the file extension (e.g. ".wav"). The given /** This decision should be based only on the file extension (e.g. ".wav"). The given
filename string is guaranteed to be lower case. */ filename string is guaranteed to be lower case. */
virtual bool isALoadableFileExtension(const ik_c8* fileName) = 0; virtual bool isALoadableFileExtension(const ik_c8* fileName) = 0;
//! Creates an audio file input stream from a file //! Creates an audio file input stream from a file
/** \return Pointer to the created audio stream. Returns 0 if loading failed. /** \return Pointer to the created audio stream. Returns 0 if loading failed.
If you no longer need the stream, you should call IAudioFileStream::drop(). If you no longer need the stream, you should call IAudioFileStream::drop().
See IRefCounted::drop() for more information. */ See IRefCounted::drop() for more information. */
virtual IAudioStream* createAudioStream(IFileReader* file) = 0; virtual IAudioStream* createAudioStream(IFileReader* file) = 0;
}; };
} // end namespace irrklang } // end namespace irrklang
#endif #endif

View File

@ -1,41 +1,41 @@
// Copyright (C) 2002-2008 Nikolaus Gebhardt // Copyright (C) 2002-2009 Nikolaus Gebhardt
// This file is part of the "irrKlang" library. // This file is part of the "irrKlang" library.
// For conditions of distribution and use, see copyright notice in irrKlang.h // For conditions of distribution and use, see copyright notice in irrKlang.h
#ifndef __I_IRRKLANG_FILE_FACTORY_H_INCLUDED__ #ifndef __I_IRRKLANG_FILE_FACTORY_H_INCLUDED__
#define __I_IRRKLANG_FILE_FACTORY_H_INCLUDED__ #define __I_IRRKLANG_FILE_FACTORY_H_INCLUDED__
#include "ik_IRefCounted.h" #include "ik_IRefCounted.h"
namespace irrklang namespace irrklang
{ {
class IFileReader; class IFileReader;
//! Interface to overwrite file access in irrKlang. //! Interface to overwrite file access in irrKlang.
/** Derive your own class from IFileFactory, overwrite the createFileReader() /** Derive your own class from IFileFactory, overwrite the createFileReader()
method and return your own implemented IFileReader to overwrite file access of irrKlang. method and return your own implemented IFileReader to overwrite file access of irrKlang.
Use ISoundEngine::addFileFactory() to let irrKlang know about your class. Use ISoundEngine::addFileFactory() to let irrKlang know about your class.
Example code can be found in the tutorial 04.OverrideFileAccess. Example code can be found in the tutorial 04.OverrideFileAccess.
*/ */
class IFileFactory : public virtual IRefCounted class IFileFactory : public virtual IRefCounted
{ {
public: public:
virtual ~IFileFactory() {}; virtual ~IFileFactory() {};
//! Opens a file for read access. //! Opens a file for read access.
/** Derive your own class from IFileFactory, overwrite this /** Derive your own class from IFileFactory, overwrite this
method and return your own implemented IFileReader to overwrite file access of irrKlang. method and return your own implemented IFileReader to overwrite file access of irrKlang.
Use ISoundEngine::addFileFactory() to let irrKlang know about your class. Use ISoundEngine::addFileFactory() to let irrKlang know about your class.
Example code can be found in the tutorial 04.OverrideFileAccess. Example code can be found in the tutorial 04.OverrideFileAccess.
\param filename Name of file to open. \param filename Name of file to open.
\return Returns a pointer to the created file interface. \return Returns a pointer to the created file interface.
The returned pointer should be dropped when no longer needed. The returned pointer should be dropped when no longer needed.
See IRefCounted::drop() for more information. Returns 0 if file cannot be opened. */ See IRefCounted::drop() for more information. Returns 0 if file cannot be opened. */
virtual IFileReader* createFileReader(const ik_c8* filename) = 0; virtual IFileReader* createFileReader(const ik_c8* filename) = 0;
}; };
} // end namespace irrklang } // end namespace irrklang
#endif #endif

View File

@ -1,50 +1,50 @@
// Copyright (C) 2002-2008 Nikolaus Gebhardt // Copyright (C) 2002-2009 Nikolaus Gebhardt
// This file is part of the "irrKlang" library. // This file is part of the "irrKlang" library.
// For conditions of distribution and use, see copyright notice in irrKlang.h // For conditions of distribution and use, see copyright notice in irrKlang.h
#ifndef __I_IRRKLANG_READ_FILE_H_INCLUDED__ #ifndef __I_IRRKLANG_READ_FILE_H_INCLUDED__
#define __I_IRRKLANG_READ_FILE_H_INCLUDED__ #define __I_IRRKLANG_READ_FILE_H_INCLUDED__
#include "ik_IRefCounted.h" #include "ik_IRefCounted.h"
namespace irrklang namespace irrklang
{ {
//! Interface providing read acess to a file. //! Interface providing read acess to a file.
class IFileReader : public virtual IRefCounted class IFileReader : public virtual IRefCounted
{ {
public: public:
virtual ~IFileReader() {}; virtual ~IFileReader() {};
//! Reads an amount of bytes from the file. //! Reads an amount of bytes from the file.
//! \param buffer: Pointer to buffer where to read bytes will be written to. //! \param buffer: Pointer to buffer where to read bytes will be written to.
//! \param sizeToRead: Amount of bytes to read from the file. //! \param sizeToRead: Amount of bytes to read from the file.
//! \return Returns how much bytes were read. //! \return Returns how much bytes were read.
virtual ik_s32 read(void* buffer, ik_u32 sizeToRead) = 0; virtual ik_s32 read(void* buffer, ik_u32 sizeToRead) = 0;
//! Changes position in file, returns true if successful. //! Changes position in file, returns true if successful.
//! \param finalPos: Destination position in the file. //! \param finalPos: Destination position in the file.
//! \param relativeMovement: If set to true, the position in the file is //! \param relativeMovement: If set to true, the position in the file is
//! changed relative to current position. Otherwise the position is changed //! changed relative to current position. Otherwise the position is changed
//! from beginning of file. //! from beginning of file.
//! \return Returns true if successful, otherwise false. //! \return Returns true if successful, otherwise false.
virtual bool seek(ik_s32 finalPos, bool relativeMovement = false) = 0; virtual bool seek(ik_s32 finalPos, bool relativeMovement = false) = 0;
//! Returns size of file. //! Returns size of file.
//! \return Returns the size of the file in bytes. //! \return Returns the size of the file in bytes.
virtual ik_s32 getSize() = 0; virtual ik_s32 getSize() = 0;
//! Returns the current position in the file. //! Returns the current position in the file.
//! \return Returns the current position in the file in bytes. //! \return Returns the current position in the file in bytes.
virtual ik_s32 getPos() = 0; virtual ik_s32 getPos() = 0;
//! Returns name of file. //! Returns name of file.
//! \return Returns the file name as zero terminated character string. //! \return Returns the file name as zero terminated character string.
virtual const ik_c8* getFileName() = 0; virtual const ik_c8* getFileName() = 0;
}; };
} // end namespace irrklang } // end namespace irrklang
#endif #endif

View File

@ -1,131 +1,119 @@
// Copyright (C) 2002-2008 Nikolaus Gebhardt // Copyright (C) 2002-2009 Nikolaus Gebhardt
// This file is part of the "irrKlang" library. // This file is part of the "irrKlang" library.
// For conditions of distribution and use, see copyright notice in irrKlang.h // For conditions of distribution and use, see copyright notice in irrKlang.h
#ifndef __I_IRRKLANG_IREFERENCE_COUNTED_H_INCLUDED__ #ifndef __I_IRRKLANG_IREFERENCE_COUNTED_H_INCLUDED__
#define __I_IRRKLANG_IREFERENCE_COUNTED_H_INCLUDED__ #define __I_IRRKLANG_IREFERENCE_COUNTED_H_INCLUDED__
#include "ik_irrKlangTypes.h" #include "ik_irrKlangTypes.h"
namespace irrklang namespace irrklang
{ {
//! Base class of most objects of the irrKlang. //! Base class of most objects of the irrKlang.
/** This class provides reference counting through the methods grab() and drop(). /** This class provides reference counting through the methods grab() and drop().
It also is able to store a debug string for every instance of an object. It also is able to store a debug string for every instance of an object.
Most objects of irrKlang are derived from IRefCounted, and so they are reference counted. Most objects of irrKlang are derived from IRefCounted, and so they are reference counted.
When you create an object in irrKlang, calling a method When you receive an object in irrKlang (for example an ISound using play2D() or
which starts with 'create', an object is created, and you get a pointer play3D()), and you no longer need the object, you have
to the new object. If you no longer need the object, you have to call drop(). This will destroy the object, if grab() was not called
to call drop(). This will destroy the object, if grab() was not called in another part of you program, because this part still needs the object.
in another part of you program, because this part still needs the object. Note, that you only don't need to call drop() for all objects you receive, it
Note, that you only need to call drop() to the object, if you created it, will be explicitely noted in the documentation.
and the method had a 'create' in it.
A simple example:
A simple example:
If you want to play a sound, you may want to call the method
If you want to create a texture, you may want to call an imaginable method ISoundEngine::play2D. You call
IDriver::createTexture. You call ISound* mysound = engine->play2D("foobar.mp3", false, false true);
ITexture* texture = driver->createTexture(128, 128); If you no longer need the sound interface, call mysound->drop(). The
If you no longer need the texture, call texture->drop(). sound may still play on after this because the engine still has a reference
to that sound, but you can be sure that it's memory will be released as soon
If you want to load a texture, you may want to call imaginable method the sound is no longer used.
IDriver::loadTexture. You do this like
ITexture* texture = driver->loadTexture("example.jpg"); If you want to add a sound source, you may want to call a method
You will not have to drop the pointer to the loaded texture, because ISoundEngine::addSoundSourceFromFile. You do this like
the name of the method does not start with 'create'. The texture ISoundSource* mysource = engine->addSoundSourceFromFile("example.jpg");
is stored somewhere by the driver. You will not have to drop the pointer to the source, because
*/ sound sources are managed by the engine (it will live as long as the sound engine) and
class IRefCounted the documentation says so.
{ */
public: class IRefCounted
{
//! Constructor. public:
IRefCounted()
: ReferenceCounter(1) //! Constructor.
{ IRefCounted()
} : ReferenceCounter(1)
{
//! Destructor. }
virtual ~IRefCounted()
{ //! Destructor.
} virtual ~IRefCounted()
{
//! Grabs the object. Increments the reference counter by one. }
//! Someone who calls grab() to an object, should later also call
//! drop() to it. If an object never gets as much drop() as grab() //! Grabs the object. Increments the reference counter by one.
//! calls, it will never be destroyed. //! Someone who calls grab() to an object, should later also call
//! The IRefCounted class provides a basic reference counting mechanism //! drop() to it. If an object never gets as much drop() as grab()
//! with its methods grab() and drop(). Most objects of irrklang //! calls, it will never be destroyed.
//! are derived from IRefCounted, and so they are reference counted. //! The IRefCounted class provides a basic reference counting mechanism
//! //! with its methods grab() and drop(). Most objects of irrklang
//! When you create an object in irrKlang, calling a method //! are derived from IRefCounted, and so they are reference counted.
//! which starts with 'create', an object is created, and you get a pointer //!
//! to the new object. If you no longer need the object, you have //! When you receive an object in irrKlang (for example an ISound using play2D() or
//! to call drop(). This will destroy the object, if grab() was not called //! play3D()), and you no longer need the object, you have
//! in another part of you program, because this part still needs the object. //! to call drop(). This will destroy the object, if grab() was not called
//! Note, that you only need to call drop() to the object, if you created it, //! in another part of you program, because this part still needs the object.
//! and the method had a 'create' in it. //! Note, that you only don't need to call drop() for all objects you receive, it
//! //! will be explicitely noted in the documentation.
//! A simple example: //!
//! //! A simple example:
//! If you want to create a texture, you may want to call an imaginable method //!
//! IDriver::createTexture. You call //! If you want to play a sound, you may want to call the method
//! ITexture* texture = driver->createTexture(128, 128); //! ISoundEngine::play2D. You call
//! If you no longer need the texture, call texture->drop(). //! ISound* mysound = engine->play2D("foobar.mp3", false, false true);
//! If you want to load a texture, you may want to call imaginable method //! If you no longer need the sound interface, call mysound->drop(). The
//! IDriver::loadTexture. You do this like //! sound may still play on after this because the engine still has a reference
//! ITexture* texture = driver->loadTexture("example.jpg"); //! to that sound, but you can be sure that it's memory will be released as soon
//! You will not have to drop the pointer to the loaded texture, because //! the sound is no longer used.
//! the name of the method does not start with 'create'. The texture void grab() { ++ReferenceCounter; }
//! is stored somewhere by the driver.
void grab() { ++ReferenceCounter; } //! When you receive an object in irrKlang (for example an ISound using play2D() or
//! play3D()), and you no longer need the object, you have
//! Drops the object. Decrements the reference counter by one. //! to call drop(). This will destroy the object, if grab() was not called
//! Returns true, if the object was deleted. //! in another part of you program, because this part still needs the object.
//! The IRefCounted class provides a basic reference counting mechanism //! Note, that you only don't need to call drop() for all objects you receive, it
//! with its methods grab() and drop(). Most objects of irrKlang //! will be explicitely noted in the documentation.
//! Engine are derived from IRefCounted, and so they are reference counted. //!
//! //! A simple example:
//! When you create an object in irrKlang, calling a method //!
//! which starts with 'create', an object is created, and you get a pointer //! If you want to play a sound, you may want to call the method
//! to the new object. If you no longer need the object, you have //! ISoundEngine::play2D. You call
//! to call drop(). This will destroy the object, if grab() was not called //! ISound* mysound = engine->play2D("foobar.mp3", false, false true);
//! in another part of you program, because this part still needs the object. //! If you no longer need the sound interface, call mysound->drop(). The
//! Note, that you only need to call drop() to the object, if you created it, //! sound may still play on after this because the engine still has a reference
//! and the method had a 'create' in it. //! to that sound, but you can be sure that it's memory will be released as soon
//! //! the sound is no longer used.
//! A simple example: bool drop()
//! {
//! If you want to create a texture, you may want to call an imaginable method --ReferenceCounter;
//! IDriver::createTexture. You call
//! ITexture* texture = driver->createTexture(128, 128); if (!ReferenceCounter)
//! If you no longer need the texture, call texture->drop(). {
//! If you want to load a texture, you may want to call imaginable method delete this;
//! IDriver::loadTexture. You do this like return true;
//! ITexture* texture = driver->loadTexture("example.jpg"); }
//! You will not have to drop the pointer to the loaded texture, because
//! the name of the method does not start with 'create'. The texture return false;
//! is stored somewhere by the driver. }
bool drop()
{ private:
--ReferenceCounter;
ik_s32 ReferenceCounter;
if (!ReferenceCounter) };
{
delete this; } // end namespace irr
return true;
} #endif
return false;
}
private:
ik_s32 ReferenceCounter;
};
} // end namespace irr
#endif

View File

@ -1,193 +1,193 @@
// Copyright (C) 2002-2008 Nikolaus Gebhardt // Copyright (C) 2002-2009 Nikolaus Gebhardt
// This file is part of the "irrKlang" library. // This file is part of the "irrKlang" library.
// For conditions of distribution and use, see copyright notice in irrKlang.h // For conditions of distribution and use, see copyright notice in irrKlang.h
#ifndef __I_IRRKLANG_SOUND_H_INCLUDED__ #ifndef __I_IRRKLANG_SOUND_H_INCLUDED__
#define __I_IRRKLANG_SOUND_H_INCLUDED__ #define __I_IRRKLANG_SOUND_H_INCLUDED__
#include "ik_IVirtualRefCounted.h" #include "ik_IVirtualRefCounted.h"
#include "ik_ISoundEffectControl.h" #include "ik_ISoundEffectControl.h"
#include "ik_vec3d.h" #include "ik_vec3d.h"
namespace irrklang namespace irrklang
{ {
class ISoundSource; class ISoundSource;
class ISoundStopEventReceiver; class ISoundStopEventReceiver;
//! Represents a sound which is currently played. //! Represents a sound which is currently played.
/** The sound can be stopped, its volume or pan changed, effects added/removed /** The sound can be stopped, its volume or pan changed, effects added/removed
and similar using this interface. and similar using this interface.
Creating sounds is done using ISoundEngine::play2D() or ISoundEngine::play3D(). Creating sounds is done using ISoundEngine::play2D() or ISoundEngine::play3D().
More informations about the source of a sound can be obtained from the ISoundSource More informations about the source of a sound can be obtained from the ISoundSource
interface. */ interface. */
class ISound : public IVirtualRefCounted class ISound : public IVirtualRefCounted
{ {
public: public:
//! returns source of the sound which stores the filename and other informations about that sound //! returns source of the sound which stores the filename and other informations about that sound
/** \return Returns the sound source poitner of this sound. May return 0 if the sound source /** \return Returns the sound source poitner of this sound. May return 0 if the sound source
has been removed.*/ has been removed.*/
virtual ISoundSource* getSoundSource() = 0; virtual ISoundSource* getSoundSource() = 0;
//! returns if the sound is paused //! returns if the sound is paused
virtual void setIsPaused( bool paused = true) = 0; virtual void setIsPaused( bool paused = true) = 0;
//! returns if the sound is paused //! returns if the sound is paused
virtual bool getIsPaused() = 0; virtual bool getIsPaused() = 0;
//! Will stop the sound and free its resources. //! Will stop the sound and free its resources.
/** If you just want to pause the sound, use setIsPaused(). /** If you just want to pause the sound, use setIsPaused().
After calling stop(), isFinished() will usually return true. */ After calling stop(), isFinished() will usually return true. */
virtual void stop() = 0; virtual void stop() = 0;
//! returns volume of the sound, a value between 0 (mute) and 1 (full volume). //! returns volume of the sound, a value between 0 (mute) and 1 (full volume).
/** (this volume gets multiplied with the master volume of the sound engine /** (this volume gets multiplied with the master volume of the sound engine
and other parameters like distance to listener when played as 3d sound) */ and other parameters like distance to listener when played as 3d sound) */
virtual ik_f32 getVolume() = 0; virtual ik_f32 getVolume() = 0;
//! sets the volume of the sound, a value between 0 (mute) and 1 (full volume). //! sets the volume of the sound, a value between 0 (mute) and 1 (full volume).
/** This volume gets multiplied with the master volume of the sound engine /** This volume gets multiplied with the master volume of the sound engine
and other parameters like distance to listener when played as 3d sound. */ and other parameters like distance to listener when played as 3d sound. */
virtual void setVolume(ik_f32 volume) = 0; virtual void setVolume(ik_f32 volume) = 0;
//! sets the pan of the sound. Takes a value between -1 and 1, 0 is center. //! sets the pan of the sound. Takes a value between -1 and 1, 0 is center.
virtual void setPan(ik_f32 pan) = 0; virtual void setPan(ik_f32 pan) = 0;
//! returns the pan of the sound. Takes a value between -1 and 1, 0 is center. //! returns the pan of the sound. Takes a value between -1 and 1, 0 is center.
virtual ik_f32 getPan() = 0; virtual ik_f32 getPan() = 0;
//! returns if the sound has been started to play looped //! returns if the sound has been started to play looped
virtual bool isLooped() = 0; virtual bool isLooped() = 0;
//! changes the loop mode of the sound. //! changes the loop mode of the sound.
/** If the sound is playing looped and it is changed to not-looped, then it /** If the sound is playing looped and it is changed to not-looped, then it
will stop playing after the loop has finished. will stop playing after the loop has finished.
If it is not looped and changed to looped, the sound will start repeating to be If it is not looped and changed to looped, the sound will start repeating to be
played when it reaches its end. played when it reaches its end.
Invoking this method will not have an effect when the sound already has stopped. */ Invoking this method will not have an effect when the sound already has stopped. */
virtual void setIsLooped(bool looped) = 0; virtual void setIsLooped(bool looped) = 0;
//! returns if the sound has finished playing. //! returns if the sound has finished playing.
/** Don't mix this up with isPaused(). isFinished() returns if the sound has been /** Don't mix this up with isPaused(). isFinished() returns if the sound has been
finished playing. If it has, is maybe already have been removed from the playing list of the finished playing. If it has, is maybe already have been removed from the playing list of the
sound engine and calls to any other of the methods of ISound will not have any result. sound engine and calls to any other of the methods of ISound will not have any result.
If you call stop() to a playing sound will result that this function will return true If you call stop() to a playing sound will result that this function will return true
when invoked. */ when invoked. */
virtual bool isFinished() = 0; virtual bool isFinished() = 0;
//! Sets the minimal distance if this is a 3D sound. //! Sets the minimal distance if this is a 3D sound.
/** Changes the distance at which the 3D sound stops getting louder. This works /** Changes the distance at which the 3D sound stops getting louder. This works
like this: As a listener approaches a 3D sound source, the sound gets louder. like this: As a listener approaches a 3D sound source, the sound gets louder.
Past a certain point, it is not reasonable for the volume to continue to increase. Past a certain point, it is not reasonable for the volume to continue to increase.
Either the maximum (zero) has been reached, or the nature of the sound source Either the maximum (zero) has been reached, or the nature of the sound source
imposes a logical limit. This is the minimum distance for the sound source. imposes a logical limit. This is the minimum distance for the sound source.
Similarly, the maximum distance for a sound source is the distance beyond Similarly, the maximum distance for a sound source is the distance beyond
which the sound does not get any quieter. which the sound does not get any quieter.
The default minimum distance is 1, the default max distance is a huge number like 1000000000.0f. */ The default minimum distance is 1, the default max distance is a huge number like 1000000000.0f. */
virtual void setMinDistance(ik_f32 min) = 0; virtual void setMinDistance(ik_f32 min) = 0;
//! Returns the minimal distance if this is a 3D sound. //! Returns the minimal distance if this is a 3D sound.
/** See setMinDistance() for details. */ /** See setMinDistance() for details. */
virtual ik_f32 getMinDistance() = 0; virtual ik_f32 getMinDistance() = 0;
//! Sets the maximal distance if this is a 3D sound. //! Sets the maximal distance if this is a 3D sound.
/** Changing this value is usually not necessary. Use setMinDistance() instead. /** Changing this value is usually not necessary. Use setMinDistance() instead.
Don't change this value if you don't know what you are doing: This value causes the sound Don't change this value if you don't know what you are doing: This value causes the sound
to stop attenuating after it reaches the max distance. Most people think that this sets the to stop attenuating after it reaches the max distance. Most people think that this sets the
volume of the sound to 0 after this distance, but this is not true. Only change the volume of the sound to 0 after this distance, but this is not true. Only change the
minimal distance (using for example setMinDistance()) to influence this. minimal distance (using for example setMinDistance()) to influence this.
The maximum distance for a sound source is the distance beyond which the sound does not get any quieter. The maximum distance for a sound source is the distance beyond which the sound does not get any quieter.
The default minimum distance is 1, the default max distance is a huge number like 1000000000.0f. */ The default minimum distance is 1, the default max distance is a huge number like 1000000000.0f. */
virtual void setMaxDistance(ik_f32 max) = 0; virtual void setMaxDistance(ik_f32 max) = 0;
//! Returns the maximal distance if this is a 3D sound. //! Returns the maximal distance if this is a 3D sound.
/** See setMaxDistance() for details. */ /** See setMaxDistance() for details. */
virtual ik_f32 getMaxDistance() = 0; virtual ik_f32 getMaxDistance() = 0;
//! sets the position of the sound in 3d space //! sets the position of the sound in 3d space
virtual void setPosition(vec3df position) = 0; virtual void setPosition(vec3df position) = 0;
//! returns the position of the sound in 3d space //! returns the position of the sound in 3d space
virtual vec3df getPosition() = 0; virtual vec3df getPosition() = 0;
//! sets the position of the sound in 3d space, needed for Doppler effects. //! sets the position of the sound in 3d space, needed for Doppler effects.
/** To use doppler effects use ISound::setVelocity to set a sounds velocity, /** To use doppler effects use ISound::setVelocity to set a sounds velocity,
ISoundEngine::setListenerPosition() to set the listeners velocity and ISoundEngine::setListenerPosition() to set the listeners velocity and
ISoundEngine::setDopplerEffectParameters() to adjust two parameters influencing ISoundEngine::setDopplerEffectParameters() to adjust two parameters influencing
the doppler effects intensity. */ the doppler effects intensity. */
virtual void setVelocity(vec3df vel) = 0; virtual void setVelocity(vec3df vel) = 0;
//! returns the velocity of the sound in 3d space, needed for Doppler effects. //! returns the velocity of the sound in 3d space, needed for Doppler effects.
/** To use doppler effects use ISound::setVelocity to set a sounds velocity, /** To use doppler effects use ISound::setVelocity to set a sounds velocity,
ISoundEngine::setListenerPosition() to set the listeners velocity and ISoundEngine::setListenerPosition() to set the listeners velocity and
ISoundEngine::setDopplerEffectParameters() to adjust two parameters influencing ISoundEngine::setDopplerEffectParameters() to adjust two parameters influencing
the doppler effects intensity. */ the doppler effects intensity. */
virtual vec3df getVelocity() = 0; virtual vec3df getVelocity() = 0;
//! returns the current play position of the sound in milliseconds. //! returns the current play position of the sound in milliseconds.
/** \return Returns -1 if not implemented or possible for this sound for example /** \return Returns -1 if not implemented or possible for this sound for example
because it already has been stopped and freed internally or similar. */ because it already has been stopped and freed internally or similar. */
virtual ik_u32 getPlayPosition() = 0; virtual ik_u32 getPlayPosition() = 0;
//! sets the current play position of the sound in milliseconds. //! sets the current play position of the sound in milliseconds.
/** \param pos Position in milliseconds. Must be between 0 and the value returned /** \param pos Position in milliseconds. Must be between 0 and the value returned
by getPlayPosition(). by getPlayPosition().
\return Returns true successful. False is returned for example if the sound already finished \return Returns true successful. False is returned for example if the sound already finished
playing and is stopped or the audio source is not seekable, for example if it playing and is stopped or the audio source is not seekable, for example if it
is an internet stream or a a file format not supporting seeking (a .MOD file for example). is an internet stream or a a file format not supporting seeking (a .MOD file for example).
A file can be tested if it can bee seeking using ISoundSource::getIsSeekingSupported(). */ A file can be tested if it can bee seeking using ISoundSource::getIsSeekingSupported(). */
virtual bool setPlayPosition(ik_u32 pos) = 0; virtual bool setPlayPosition(ik_u32 pos) = 0;
//! Sets the playback speed (frequency) of the sound. //! Sets the playback speed (frequency) of the sound.
/** Plays the sound at a higher or lower speed, increasing or decreasing its /** Plays the sound at a higher or lower speed, increasing or decreasing its
frequency which makes it sound lower or higher. frequency which makes it sound lower or higher.
Note that this feature is not available on all sound output drivers (it is on the Note that this feature is not available on all sound output drivers (it is on the
DirectSound drivers at least), and it does not work together with the DirectSound drivers at least), and it does not work together with the
'enableSoundEffects' parameter of ISoundEngine::play2D and ISoundEngine::play3D when 'enableSoundEffects' parameter of ISoundEngine::play2D and ISoundEngine::play3D when
using DirectSound. using DirectSound.
\param speed Factor of the speed increase or decrease. 2 is twice as fast, \param speed Factor of the speed increase or decrease. 2 is twice as fast,
0.5 is only half as fast. The default is 1.0. 0.5 is only half as fast. The default is 1.0.
\return Returns true if sucessful, false if not. The current sound driver might not \return Returns true if sucessful, false if not. The current sound driver might not
support changing the playBack speed, or the sound was started with the support changing the playBack speed, or the sound was started with the
'enableSoundEffects' parameter. */ 'enableSoundEffects' parameter. */
virtual bool setPlaybackSpeed(ik_f32 speed = 1.0f) = 0; virtual bool setPlaybackSpeed(ik_f32 speed = 1.0f) = 0;
//! Returns the playback speed set by setPlaybackSpeed(). Default: 1.0f. //! Returns the playback speed set by setPlaybackSpeed(). Default: 1.0f.
/** See setPlaybackSpeed() for details */ /** See setPlaybackSpeed() for details */
virtual ik_f32 getPlaybackSpeed() = 0; virtual ik_f32 getPlaybackSpeed() = 0;
//! returns the play length of the sound in milliseconds. //! returns the play length of the sound in milliseconds.
/** Returns -1 if not known for this sound for example because its decoder /** Returns -1 if not known for this sound for example because its decoder
does not support length reporting or it is a file stream of unknown size. does not support length reporting or it is a file stream of unknown size.
Note: You can also use ISoundSource::getPlayLength() to get the length of Note: You can also use ISoundSource::getPlayLength() to get the length of
a sound without actually needing to play it. */ a sound without actually needing to play it. */
virtual ik_u32 getPlayLength() = 0; virtual ik_u32 getPlayLength() = 0;
//! Returns the sound effect control interface for this sound. //! Returns the sound effect control interface for this sound.
/** Sound effects such as Chorus, Distorsions, Echo, Reverb and similar can /** Sound effects such as Chorus, Distorsions, Echo, Reverb and similar can
be controlled using this. The interface pointer is only valid as long as the ISound pointer is valid. be controlled using this. The interface pointer is only valid as long as the ISound pointer is valid.
If the ISound pointer gets dropped (IVirtualRefCounted::drop()), the ISoundEffects If the ISound pointer gets dropped (IVirtualRefCounted::drop()), the ISoundEffects
may not be used any more. may not be used any more.
\return Returns a pointer to the sound effects interface if available. The sound \return Returns a pointer to the sound effects interface if available. The sound
has to be started via ISoundEngine::play2D() or ISoundEngine::play3D(), has to be started via ISoundEngine::play2D() or ISoundEngine::play3D(),
with the flag enableSoundEffects=true, otherwise 0 will be returned. Note that with the flag enableSoundEffects=true, otherwise 0 will be returned. Note that
if the output driver does not support sound effects, 0 will be returned as well.*/ if the output driver does not support sound effects, 0 will be returned as well.*/
virtual ISoundEffectControl* getSoundEffectControl() = 0; virtual ISoundEffectControl* getSoundEffectControl() = 0;
//! Sets the sound stop event receiver, an interface which gets called if a sound has finished playing. //! Sets the sound stop event receiver, an interface which gets called if a sound has finished playing.
/** This event is guaranteed to be called when the sound or sound stream is finished, /** This event is guaranteed to be called when the sound or sound stream is finished,
either because the sound reached its playback end, its sound source was removed, either because the sound reached its playback end, its sound source was removed,
ISoundEngine::stopAllSounds() has been called or the whole engine was deleted. ISoundEngine::stopAllSounds() has been called or the whole engine was deleted.
There is an example on how to use events in irrklang at @ref events . There is an example on how to use events in irrklang at @ref events .
\param receiver Interface to a user implementation of the sound receiver. This interface \param receiver Interface to a user implementation of the sound receiver. This interface
should be as long valid as the sound exists or another stop event receiver is set. should be as long valid as the sound exists or another stop event receiver is set.
Set this to null to set no sound stop event receiver. Set this to null to set no sound stop event receiver.
\param userData: A iser data pointer, can be null. */ \param userData: A iser data pointer, can be null. */
virtual void setSoundStopEventReceiver(ISoundStopEventReceiver* reciever, void* userData=0) = 0; virtual void setSoundStopEventReceiver(ISoundStopEventReceiver* reciever, void* userData=0) = 0;
}; };
} // end namespace irrklang } // end namespace irrklang
#endif #endif

View File

@ -1,41 +1,41 @@
// Copyright (C) 2002-2008 Nikolaus Gebhardt // Copyright (C) 2002-2009 Nikolaus Gebhardt
// This file is part of the "irrKlang" library. // This file is part of the "irrKlang" library.
// For conditions of distribution and use, see copyright notice in irrKlang.h // For conditions of distribution and use, see copyright notice in irrKlang.h
#ifndef __I_IRRKLANG_SOUND_DEVICE_LIST_H_INCLUDED__ #ifndef __I_IRRKLANG_SOUND_DEVICE_LIST_H_INCLUDED__
#define __I_IRRKLANG_SOUND_DEVICE_LIST_H_INCLUDED__ #define __I_IRRKLANG_SOUND_DEVICE_LIST_H_INCLUDED__
#include "ik_IRefCounted.h" #include "ik_IRefCounted.h"
namespace irrklang namespace irrklang
{ {
//! A list of sound devices for a sound driver. Use irrklang::createSoundDeviceList() to create this list. //! A list of sound devices for a sound driver. Use irrklang::createSoundDeviceList() to create this list.
/** The function createIrrKlangDevice() has a parameter 'deviceID' which takes the value returned by /** The function createIrrKlangDevice() has a parameter 'deviceID' which takes the value returned by
ISoundDeviceList::getDeviceID() and uses that device then. ISoundDeviceList::getDeviceID() and uses that device then.
The list of devices in ISoundDeviceList usually also includes the default device which is the first The list of devices in ISoundDeviceList usually also includes the default device which is the first
entry and has an empty deviceID string ("") and the description "default device". entry and has an empty deviceID string ("") and the description "default device".
There is some example code on how to use the ISoundDeviceList in @ref enumeratingDevices.*/ There is some example code on how to use the ISoundDeviceList in @ref enumeratingDevices.*/
class ISoundDeviceList : public IRefCounted class ISoundDeviceList : public IRefCounted
{ {
public: public:
//! Returns amount of enumerated devices in the list. //! Returns amount of enumerated devices in the list.
virtual ik_s32 getDeviceCount() = 0; virtual ik_s32 getDeviceCount() = 0;
//! Returns the ID of the device. Use this string to identify this device in createIrrKlangDevice(). //! Returns the ID of the device. Use this string to identify this device in createIrrKlangDevice().
/** \param index Index of the device, a value between 0 and ISoundDeviceList::getDeviceCount()-1. /** \param index Index of the device, a value between 0 and ISoundDeviceList::getDeviceCount()-1.
\return Returns a pointer to a string identifying the device. The string will only as long valid \return Returns a pointer to a string identifying the device. The string will only as long valid
as long as the ISoundDeviceList exists. */ as long as the ISoundDeviceList exists. */
virtual const char* getDeviceID(ik_s32 index) = 0; virtual const char* getDeviceID(ik_s32 index) = 0;
//! Returns description of the device. //! Returns description of the device.
/** \param index Index of the device, a value between 0 and ISoundDeviceList::getDeviceCount()-1. */ /** \param index Index of the device, a value between 0 and ISoundDeviceList::getDeviceCount()-1. */
virtual const char* getDeviceDescription(ik_s32 index) = 0; virtual const char* getDeviceDescription(ik_s32 index) = 0;
}; };
} // end namespace irrklang } // end namespace irrklang
#endif #endif

View File

@ -1,243 +1,243 @@
// Copyright (C) 2002-2008 Nikolaus Gebhardt // Copyright (C) 2002-2009 Nikolaus Gebhardt
// This file is part of the "irrKlang" library. // This file is part of the "irrKlang" library.
// For conditions of distribution and use, see copyright notice in irrKlang.h // For conditions of distribution and use, see copyright notice in irrKlang.h
#ifndef __I_IRRKLANG_SOUND_EFFECT_CONTROL_H_INCLUDED__ #ifndef __I_IRRKLANG_SOUND_EFFECT_CONTROL_H_INCLUDED__
#define __I_IRRKLANG_SOUND_EFFECT_CONTROL_H_INCLUDED__ #define __I_IRRKLANG_SOUND_EFFECT_CONTROL_H_INCLUDED__
#include "ik_IVirtualRefCounted.h" #include "ik_IVirtualRefCounted.h"
#include "ik_vec3d.h" #include "ik_vec3d.h"
namespace irrklang namespace irrklang
{ {
//! Interface to control the active sound effects (echo, reverb,...) of an ISound object, a playing sound. //! Interface to control the active sound effects (echo, reverb,...) of an ISound object, a playing sound.
/** Sound effects such as chorus, distorsions, echo, reverb and similar can /** Sound effects such as chorus, distorsions, echo, reverb and similar can
be controlled using this. An instance of this interface can be obtained via be controlled using this. An instance of this interface can be obtained via
ISound::getSoundEffectControl(). The sound containing this interface has to be started via ISound::getSoundEffectControl(). The sound containing this interface has to be started via
ISoundEngine::play2D() or ISoundEngine::play3D() with the flag enableSoundEffects=true, ISoundEngine::play2D() or ISoundEngine::play3D() with the flag enableSoundEffects=true,
otherwise no acccess to this interface will be available. otherwise no acccess to this interface will be available.
For the DirectSound driver, these are effects available since DirectSound8. For most For the DirectSound driver, these are effects available since DirectSound8. For most
effects, sounds should have a sample rate of 44 khz and should be at least effects, sounds should have a sample rate of 44 khz and should be at least
150 milli seconds long for optimal quality when using the DirectSound driver. 150 milli seconds long for optimal quality when using the DirectSound driver.
Note that the interface pointer is only valid as long as Note that the interface pointer is only valid as long as
the ISound pointer is valid. If the ISound pointer gets dropped (IVirtualRefCounted::drop()), the ISound pointer is valid. If the ISound pointer gets dropped (IVirtualRefCounted::drop()),
the ISoundEffects may not be used any more. */ the ISoundEffects may not be used any more. */
class ISoundEffectControl class ISoundEffectControl
{ {
public: public:
//! Disables all active sound effects //! Disables all active sound effects
virtual void disableAllEffects() = 0; virtual void disableAllEffects() = 0;
//! Enables the chorus sound effect or adjusts its values. //! Enables the chorus sound effect or adjusts its values.
/** Chorus is a voice-doubling effect created by echoing the /** Chorus is a voice-doubling effect created by echoing the
original sound with a slight delay and slightly modulating the delay of the echo. original sound with a slight delay and slightly modulating the delay of the echo.
If this sound effect is already enabled, calling this only modifies the parameters of the active effect. If this sound effect is already enabled, calling this only modifies the parameters of the active effect.
\param fWetDryMix Ratio of wet (processed) signal to dry (unprocessed) signal. Minimal Value:0, Maximal Value:100.0f; \param fWetDryMix Ratio of wet (processed) signal to dry (unprocessed) signal. Minimal Value:0, Maximal Value:100.0f;
\param fDepth Percentage by which the delay time is modulated by the low-frequency oscillator, in hundredths of a percentage point. Minimal Value:0, Maximal Value:100.0f; \param fDepth Percentage by which the delay time is modulated by the low-frequency oscillator, in hundredths of a percentage point. Minimal Value:0, Maximal Value:100.0f;
\param fFeedback Percentage of output signal to feed back into the effect's input. Minimal Value:-99, Maximal Value:99.0f; \param fFeedback Percentage of output signal to feed back into the effect's input. Minimal Value:-99, Maximal Value:99.0f;
\param fFrequency Frequency of the LFO. Minimal Value:0, Maximal Value:10.0f; \param fFrequency Frequency of the LFO. Minimal Value:0, Maximal Value:10.0f;
\param sinusWaveForm True for sinus wave form, false for triangle. \param sinusWaveForm True for sinus wave form, false for triangle.
\param fDelay Number of milliseconds the input is delayed before it is played back. Minimal Value:0, Maximal Value:20.0f; \param fDelay Number of milliseconds the input is delayed before it is played back. Minimal Value:0, Maximal Value:20.0f;
\param lPhase Phase differential between left and right LFOs. Possible values: \param lPhase Phase differential between left and right LFOs. Possible values:
-180, -90, 0, 90, 180 -180, -90, 0, 90, 180
\return Returns true if successful. */ \return Returns true if successful. */
virtual bool enableChorusSoundEffect(ik_f32 fWetDryMix = 50, virtual bool enableChorusSoundEffect(ik_f32 fWetDryMix = 50,
ik_f32 fDepth = 10, ik_f32 fDepth = 10,
ik_f32 fFeedback = 25, ik_f32 fFeedback = 25,
ik_f32 fFrequency = 1.1, ik_f32 fFrequency = 1.1,
bool sinusWaveForm = true, bool sinusWaveForm = true,
ik_f32 fDelay = 16, ik_f32 fDelay = 16,
ik_s32 lPhase = 90) = 0; ik_s32 lPhase = 90) = 0;
//! removes the sound effect from the sound //! removes the sound effect from the sound
virtual void disableChorusSoundEffect() = 0; virtual void disableChorusSoundEffect() = 0;
//! returns if the sound effect is active on the sound //! returns if the sound effect is active on the sound
virtual bool isChorusSoundEffectEnabled() = 0; virtual bool isChorusSoundEffectEnabled() = 0;
//! Enables the Compressor sound effect or adjusts its values. //! Enables the Compressor sound effect or adjusts its values.
/** Compressor is a reduction in the fluctuation of a signal above a certain amplitude. /** Compressor is a reduction in the fluctuation of a signal above a certain amplitude.
If this sound effect is already enabled, calling this only modifies the parameters of the active effect. If this sound effect is already enabled, calling this only modifies the parameters of the active effect.
\param fGain Output gain of signal after Compressor. Minimal Value:-60, Maximal Value:60.0f; \param fGain Output gain of signal after Compressor. Minimal Value:-60, Maximal Value:60.0f;
\param fAttack Time before Compressor reaches its full value. Minimal Value:0.01, Maximal Value:500.0f; \param fAttack Time before Compressor reaches its full value. Minimal Value:0.01, Maximal Value:500.0f;
\param fRelease Speed at which Compressor is stopped after input drops below fThreshold. Minimal Value:50, Maximal Value:3000.0f; \param fRelease Speed at which Compressor is stopped after input drops below fThreshold. Minimal Value:50, Maximal Value:3000.0f;
\param fThreshold Point at which Compressor begins, in decibels. Minimal Value:-60, Maximal Value:0.0f; \param fThreshold Point at which Compressor begins, in decibels. Minimal Value:-60, Maximal Value:0.0f;
\param fRatio Compressor ratio. Minimal Value:1, Maximal Value:100.0f; \param fRatio Compressor ratio. Minimal Value:1, Maximal Value:100.0f;
\param fPredelay Time after lThreshold is reached before attack phase is started, in milliseconds. Minimal Value:0, Maximal Value:4.0f; \param fPredelay Time after lThreshold is reached before attack phase is started, in milliseconds. Minimal Value:0, Maximal Value:4.0f;
\return Returns true if successful. */ \return Returns true if successful. */
virtual bool enableCompressorSoundEffect( ik_f32 fGain = 0, virtual bool enableCompressorSoundEffect( ik_f32 fGain = 0,
ik_f32 fAttack = 10, ik_f32 fAttack = 10,
ik_f32 fRelease = 200, ik_f32 fRelease = 200,
ik_f32 fThreshold = -20, ik_f32 fThreshold = -20,
ik_f32 fRatio = 3, ik_f32 fRatio = 3,
ik_f32 fPredelay = 4) = 0; ik_f32 fPredelay = 4) = 0;
//! removes the sound effect from the sound //! removes the sound effect from the sound
virtual void disableCompressorSoundEffect() = 0; virtual void disableCompressorSoundEffect() = 0;
//! returns if the sound effect is active on the sound //! returns if the sound effect is active on the sound
virtual bool isCompressorSoundEffectEnabled() = 0; virtual bool isCompressorSoundEffectEnabled() = 0;
//! Enables the Distortion sound effect or adjusts its values. //! Enables the Distortion sound effect or adjusts its values.
/** Distortion is achieved by adding harmonics to the signal in such a way that, /** Distortion is achieved by adding harmonics to the signal in such a way that,
If this sound effect is already enabled, calling this only modifies the parameters of the active effect. If this sound effect is already enabled, calling this only modifies the parameters of the active effect.
as the level increases, the top of the waveform becomes squared off or clipped. as the level increases, the top of the waveform becomes squared off or clipped.
\param fGain Amount of signal change after distortion. Minimal Value:-60, Maximal Value:0; \param fGain Amount of signal change after distortion. Minimal Value:-60, Maximal Value:0;
\param fEdge Percentage of distortion intensity. Minimal Value:0, Maximal Value:100; \param fEdge Percentage of distortion intensity. Minimal Value:0, Maximal Value:100;
\param fPostEQCenterFrequency Center frequency of harmonic content addition. Minimal Value:100, Maximal Value:8000; \param fPostEQCenterFrequency Center frequency of harmonic content addition. Minimal Value:100, Maximal Value:8000;
\param fPostEQBandwidth Width of frequency band that determines range of harmonic content addition. Minimal Value:100, Maximal Value:8000; \param fPostEQBandwidth Width of frequency band that determines range of harmonic content addition. Minimal Value:100, Maximal Value:8000;
\param fPreLowpassCutoff Filter cutoff for high-frequency harmonics attenuation. Minimal Value:100, Maximal Value:8000; \param fPreLowpassCutoff Filter cutoff for high-frequency harmonics attenuation. Minimal Value:100, Maximal Value:8000;
\return Returns true if successful. */ \return Returns true if successful. */
virtual bool enableDistortionSoundEffect(ik_f32 fGain = -18, virtual bool enableDistortionSoundEffect(ik_f32 fGain = -18,
ik_f32 fEdge = 15, ik_f32 fEdge = 15,
ik_f32 fPostEQCenterFrequency = 2400, ik_f32 fPostEQCenterFrequency = 2400,
ik_f32 fPostEQBandwidth = 2400, ik_f32 fPostEQBandwidth = 2400,
ik_f32 fPreLowpassCutoff = 8000) = 0; ik_f32 fPreLowpassCutoff = 8000) = 0;
//! removes the sound effect from the sound //! removes the sound effect from the sound
virtual void disableDistortionSoundEffect() = 0; virtual void disableDistortionSoundEffect() = 0;
//! returns if the sound effect is active on the sound //! returns if the sound effect is active on the sound
virtual bool isDistortionSoundEffectEnabled() = 0; virtual bool isDistortionSoundEffectEnabled() = 0;
//! Enables the Echo sound effect or adjusts its values. //! Enables the Echo sound effect or adjusts its values.
/** An echo effect causes an entire sound to be repeated after a fixed delay. /** An echo effect causes an entire sound to be repeated after a fixed delay.
If this sound effect is already enabled, calling this only modifies the parameters of the active effect. If this sound effect is already enabled, calling this only modifies the parameters of the active effect.
\param fWetDryMix Ratio of wet (processed) signal to dry (unprocessed) signal. Minimal Value:0, Maximal Value:100.0f; \param fWetDryMix Ratio of wet (processed) signal to dry (unprocessed) signal. Minimal Value:0, Maximal Value:100.0f;
\param fFeedback Percentage of output fed back into input. Minimal Value:0, Maximal Value:100.0f; \param fFeedback Percentage of output fed back into input. Minimal Value:0, Maximal Value:100.0f;
\param fLeftDelay Delay for left channel, in milliseconds. Minimal Value:1, Maximal Value:2000.0f; \param fLeftDelay Delay for left channel, in milliseconds. Minimal Value:1, Maximal Value:2000.0f;
\param fRightDelay Delay for right channel, in milliseconds. Minimal Value:1, Maximal Value:2000.0f; \param fRightDelay Delay for right channel, in milliseconds. Minimal Value:1, Maximal Value:2000.0f;
\param lPanDelay Value that specifies whether to swap left and right delays with each successive echo. Minimal Value:0, Maximal Value:1; \param lPanDelay Value that specifies whether to swap left and right delays with each successive echo. Minimal Value:0, Maximal Value:1;
\return Returns true if successful. */ \return Returns true if successful. */
virtual bool enableEchoSoundEffect(ik_f32 fWetDryMix = 50, virtual bool enableEchoSoundEffect(ik_f32 fWetDryMix = 50,
ik_f32 fFeedback = 50, ik_f32 fFeedback = 50,
ik_f32 fLeftDelay = 500, ik_f32 fLeftDelay = 500,
ik_f32 fRightDelay = 500, ik_f32 fRightDelay = 500,
ik_s32 lPanDelay = 0) = 0; ik_s32 lPanDelay = 0) = 0;
//! removes the sound effect from the sound //! removes the sound effect from the sound
virtual void disableEchoSoundEffect() = 0; virtual void disableEchoSoundEffect() = 0;
//! returns if the sound effect is active on the sound //! returns if the sound effect is active on the sound
virtual bool isEchoSoundEffectEnabled() = 0; virtual bool isEchoSoundEffectEnabled() = 0;
//! Enables the Flanger sound effect or adjusts its values. //! Enables the Flanger sound effect or adjusts its values.
/** Flange is an echo effect in which the delay between the original /** Flange is an echo effect in which the delay between the original
signal and its echo is very short and varies over time. The result is signal and its echo is very short and varies over time. The result is
sometimes referred to as a sweeping sound. The term flange originated sometimes referred to as a sweeping sound. The term flange originated
with the practice of grabbing the flanges of a tape reel to change the speed. with the practice of grabbing the flanges of a tape reel to change the speed.
If this sound effect is already enabled, calling this only modifies the parameters of the active effect. If this sound effect is already enabled, calling this only modifies the parameters of the active effect.
\param fWetDryMix Ratio of wet (processed) signal to dry (unprocessed) signal. Minimal Value:0, Maximal Value:100.0f; \param fWetDryMix Ratio of wet (processed) signal to dry (unprocessed) signal. Minimal Value:0, Maximal Value:100.0f;
\param fDepth Percentage by which the delay time is modulated by the low-frequency oscillator, in hundredths of a percentage point. Minimal Value:0, Maximal Value:100.0f; \param fDepth Percentage by which the delay time is modulated by the low-frequency oscillator, in hundredths of a percentage point. Minimal Value:0, Maximal Value:100.0f;
\param fFeedback Percentage of output signal to feed back into the effect's input. Minimal Value:-99, Maximal Value:99.0f; \param fFeedback Percentage of output signal to feed back into the effect's input. Minimal Value:-99, Maximal Value:99.0f;
\param fFrequency Frequency of the LFO. Minimal Value:0, Maximal Value:10.0f; \param fFrequency Frequency of the LFO. Minimal Value:0, Maximal Value:10.0f;
\param triangleWaveForm True for triangle wave form, false for square. \param triangleWaveForm True for triangle wave form, false for square.
\param fDelay Number of milliseconds the input is delayed before it is played back. Minimal Value:0, Maximal Value:20.0f; \param fDelay Number of milliseconds the input is delayed before it is played back. Minimal Value:0, Maximal Value:20.0f;
\param lPhase Phase differential between left and right LFOs. Possible values: \param lPhase Phase differential between left and right LFOs. Possible values:
-180, -90, 0, 90, 180 -180, -90, 0, 90, 180
\return Returns true if successful. */ \return Returns true if successful. */
virtual bool enableFlangerSoundEffect(ik_f32 fWetDryMix = 50, virtual bool enableFlangerSoundEffect(ik_f32 fWetDryMix = 50,
ik_f32 fDepth = 100, ik_f32 fDepth = 100,
ik_f32 fFeedback = -50, ik_f32 fFeedback = -50,
ik_f32 fFrequency = 0.25f, ik_f32 fFrequency = 0.25f,
bool triangleWaveForm = true, bool triangleWaveForm = true,
ik_f32 fDelay = 2, ik_f32 fDelay = 2,
ik_s32 lPhase = 0) = 0; ik_s32 lPhase = 0) = 0;
//! removes the sound effect from the sound //! removes the sound effect from the sound
virtual void disableFlangerSoundEffect() = 0; virtual void disableFlangerSoundEffect() = 0;
//! returns if the sound effect is active on the sound //! returns if the sound effect is active on the sound
virtual bool isFlangerSoundEffectEnabled() = 0; virtual bool isFlangerSoundEffectEnabled() = 0;
//! Enables the Gargle sound effect or adjusts its values. //! Enables the Gargle sound effect or adjusts its values.
/** The gargle effect modulates the amplitude of the signal. /** The gargle effect modulates the amplitude of the signal.
If this sound effect is already enabled, calling this only modifies the parameters of the active effect. If this sound effect is already enabled, calling this only modifies the parameters of the active effect.
\param rateHz Rate of modulation, in Hertz. Minimal Value:1, Maximal Value:1000 \param rateHz Rate of modulation, in Hertz. Minimal Value:1, Maximal Value:1000
\param sinusWaveForm True for sinus wave form, false for triangle. \param sinusWaveForm True for sinus wave form, false for triangle.
\return Returns true if successful. */ \return Returns true if successful. */
virtual bool enableGargleSoundEffect(ik_s32 rateHz = 20, bool sinusWaveForm = true) = 0; virtual bool enableGargleSoundEffect(ik_s32 rateHz = 20, bool sinusWaveForm = true) = 0;
//! removes the sound effect from the sound //! removes the sound effect from the sound
virtual void disableGargleSoundEffect() = 0; virtual void disableGargleSoundEffect() = 0;
//! returns if the sound effect is active on the sound //! returns if the sound effect is active on the sound
virtual bool isGargleSoundEffectEnabled() = 0; virtual bool isGargleSoundEffectEnabled() = 0;
//! Enables the Interactive 3D Level 2 reverb sound effect or adjusts its values. //! Enables the Interactive 3D Level 2 reverb sound effect or adjusts its values.
/** An implementation of the listener properties in the I3DL2 specification. Source properties are not supported. /** An implementation of the listener properties in the I3DL2 specification. Source properties are not supported.
If this sound effect is already enabled, calling this only modifies the parameters of the active effect. If this sound effect is already enabled, calling this only modifies the parameters of the active effect.
\param lRoom Attenuation of the room effect, in millibels (mB). Interval: [-10000, 0] Default: -1000 mB \param lRoom Attenuation of the room effect, in millibels (mB). Interval: [-10000, 0] Default: -1000 mB
\param lRoomHF Attenuation of the room high-frequency effect. Interval: [-10000, 0] default: 0 mB \param lRoomHF Attenuation of the room high-frequency effect. Interval: [-10000, 0] default: 0 mB
\param flRoomRolloffFactor Rolloff factor for the reflected signals. Interval: [0.0, 10.0] default: 0.0 \param flRoomRolloffFactor Rolloff factor for the reflected signals. Interval: [0.0, 10.0] default: 0.0
\param flDecayTime Decay time, in seconds. Interval: [0.1, 20.0] default: 1.49s \param flDecayTime Decay time, in seconds. Interval: [0.1, 20.0] default: 1.49s
\param flDecayHFRatio Ratio of the decay time at high frequencies to the decay time at low frequencies. Interval: [0.1, 2.0] default: 0.83 \param flDecayHFRatio Ratio of the decay time at high frequencies to the decay time at low frequencies. Interval: [0.1, 2.0] default: 0.83
\param lReflections Attenuation of early reflections relative to lRoom. Interval: [-10000, 1000] default: -2602 mB \param lReflections Attenuation of early reflections relative to lRoom. Interval: [-10000, 1000] default: -2602 mB
\param flReflectionsDelay Delay time of the first reflection relative to the direct path in seconds. Interval: [0.0, 0.3] default: 0.007 s \param flReflectionsDelay Delay time of the first reflection relative to the direct path in seconds. Interval: [0.0, 0.3] default: 0.007 s
\param lReverb Attenuation of late reverberation relative to lRoom, in mB. Interval: [-10000, 2000] default: 200 mB \param lReverb Attenuation of late reverberation relative to lRoom, in mB. Interval: [-10000, 2000] default: 200 mB
\param flReverbDelay Time limit between the early reflections and the late reverberation relative to the time of the first reflection. Interval: [0.0, 0.1] default: 0.011 s \param flReverbDelay Time limit between the early reflections and the late reverberation relative to the time of the first reflection. Interval: [0.0, 0.1] default: 0.011 s
\param flDiffusion Echo density in the late reverberation decay in percent. Interval: [0.0, 100.0] default: 100.0 % \param flDiffusion Echo density in the late reverberation decay in percent. Interval: [0.0, 100.0] default: 100.0 %
\param flDensity Modal density in the late reverberation decay, in percent. Interval: [0.0, 100.0] default: 100.0 % \param flDensity Modal density in the late reverberation decay, in percent. Interval: [0.0, 100.0] default: 100.0 %
\param flHFReference Reference high frequency, in hertz. Interval: [20.0, 20000.0] default: 5000.0 Hz \param flHFReference Reference high frequency, in hertz. Interval: [20.0, 20000.0] default: 5000.0 Hz
\return Returns true if successful. */ \return Returns true if successful. */
virtual bool enableI3DL2ReverbSoundEffect(ik_s32 lRoom = -1000, virtual bool enableI3DL2ReverbSoundEffect(ik_s32 lRoom = -1000,
ik_s32 lRoomHF = -100, ik_s32 lRoomHF = -100,
ik_f32 flRoomRolloffFactor = 0, ik_f32 flRoomRolloffFactor = 0,
ik_f32 flDecayTime = 1.49f, ik_f32 flDecayTime = 1.49f,
ik_f32 flDecayHFRatio = 0.83f, ik_f32 flDecayHFRatio = 0.83f,
ik_s32 lReflections = -2602, ik_s32 lReflections = -2602,
ik_f32 flReflectionsDelay = 0.007f, ik_f32 flReflectionsDelay = 0.007f,
ik_s32 lReverb = 200, ik_s32 lReverb = 200,
ik_f32 flReverbDelay = 0.011f, ik_f32 flReverbDelay = 0.011f,
ik_f32 flDiffusion = 100.0f, ik_f32 flDiffusion = 100.0f,
ik_f32 flDensity = 100.0f, ik_f32 flDensity = 100.0f,
ik_f32 flHFReference = 5000.0f ) = 0; ik_f32 flHFReference = 5000.0f ) = 0;
//! removes the sound effect from the sound //! removes the sound effect from the sound
virtual void disableI3DL2ReverbSoundEffect() = 0; virtual void disableI3DL2ReverbSoundEffect() = 0;
//! returns if the sound effect is active on the sound //! returns if the sound effect is active on the sound
virtual bool isI3DL2ReverbSoundEffectEnabled() = 0; virtual bool isI3DL2ReverbSoundEffectEnabled() = 0;
//! Enables the ParamEq sound effect or adjusts its values. //! Enables the ParamEq sound effect or adjusts its values.
/** Parametric equalizer amplifies or attenuates signals of a given frequency. /** Parametric equalizer amplifies or attenuates signals of a given frequency.
If this sound effect is already enabled, calling this only modifies the parameters of the active effect. If this sound effect is already enabled, calling this only modifies the parameters of the active effect.
\param fCenter Center frequency, in hertz, The default value is 8000. Minimal Value:80, Maximal Value:16000.0f \param fCenter Center frequency, in hertz, The default value is 8000. Minimal Value:80, Maximal Value:16000.0f
\param fBandwidth Bandwidth, in semitones, The default value is 12. Minimal Value:1.0f, Maximal Value:36.0f \param fBandwidth Bandwidth, in semitones, The default value is 12. Minimal Value:1.0f, Maximal Value:36.0f
\param fGain Gain, default value is 0. Minimal Value:-15.0f, Maximal Value:15.0f \param fGain Gain, default value is 0. Minimal Value:-15.0f, Maximal Value:15.0f
\return Returns true if successful. */ \return Returns true if successful. */
virtual bool enableParamEqSoundEffect(ik_f32 fCenter = 8000, virtual bool enableParamEqSoundEffect(ik_f32 fCenter = 8000,
ik_f32 fBandwidth = 12, ik_f32 fBandwidth = 12,
ik_f32 fGain = 0) = 0; ik_f32 fGain = 0) = 0;
//! removes the sound effect from the sound //! removes the sound effect from the sound
virtual void disableParamEqSoundEffect() = 0; virtual void disableParamEqSoundEffect() = 0;
//! returns if the sound effect is active on the sound //! returns if the sound effect is active on the sound
virtual bool isParamEqSoundEffectEnabled() = 0; virtual bool isParamEqSoundEffectEnabled() = 0;
//! Enables the Waves Reverb sound effect or adjusts its values. //! Enables the Waves Reverb sound effect or adjusts its values.
/** \param fInGain Input gain of signal, in decibels (dB). Min/Max: [-96.0,0.0] Default: 0.0 dB. /** \param fInGain Input gain of signal, in decibels (dB). Min/Max: [-96.0,0.0] Default: 0.0 dB.
If this sound effect is already enabled, calling this only modifies the parameters of the active effect. If this sound effect is already enabled, calling this only modifies the parameters of the active effect.
\param fReverbMix Reverb mix, in dB. Min/Max: [-96.0,0.0] Default: 0.0 dB \param fReverbMix Reverb mix, in dB. Min/Max: [-96.0,0.0] Default: 0.0 dB
\param fReverbTime Reverb time, in milliseconds. Min/Max: [0.001,3000.0] Default: 1000.0 ms \param fReverbTime Reverb time, in milliseconds. Min/Max: [0.001,3000.0] Default: 1000.0 ms
\param fHighFreqRTRatio High-frequency reverb time ratio. Min/Max: [0.001,0.999] Default: 0.001 \param fHighFreqRTRatio High-frequency reverb time ratio. Min/Max: [0.001,0.999] Default: 0.001
\return Returns true if successful. */ \return Returns true if successful. */
virtual bool enableWavesReverbSoundEffect(ik_f32 fInGain = 0, virtual bool enableWavesReverbSoundEffect(ik_f32 fInGain = 0,
ik_f32 fReverbMix = 0, ik_f32 fReverbMix = 0,
ik_f32 fReverbTime = 1000, ik_f32 fReverbTime = 1000,
ik_f32 fHighFreqRTRatio = 0.001f) = 0; ik_f32 fHighFreqRTRatio = 0.001f) = 0;
//! removes the sound effect from the sound //! removes the sound effect from the sound
virtual void disableWavesReverbSoundEffect() = 0; virtual void disableWavesReverbSoundEffect() = 0;
//! returns if the sound effect is active on the sound //! returns if the sound effect is active on the sound
virtual bool isWavesReverbSoundEffectEnabled() = 0; virtual bool isWavesReverbSoundEffectEnabled() = 0;
}; };
} // end namespace irrklang } // end namespace irrklang
#endif #endif

View File

@ -1,395 +1,431 @@
// Copyright (C) 2002-2008 Nikolaus Gebhardt // Copyright (C) 2002-2009 Nikolaus Gebhardt
// This file is part of the "irrKlang" library. // This file is part of the "irrKlang" library.
// For conditions of distribution and use, see copyright notice in irrKlang.h // For conditions of distribution and use, see copyright notice in irrKlang.h
#ifndef __I_IRRKLANG_SOUND_ENGINE_H_INCLUDED__ #ifndef __I_IRRKLANG_SOUND_ENGINE_H_INCLUDED__
#define __I_IRRKLANG_SOUND_ENGINE_H_INCLUDED__ #define __I_IRRKLANG_SOUND_ENGINE_H_INCLUDED__
#include "ik_IRefCounted.h" #include "ik_IRefCounted.h"
#include "ik_vec3d.h" #include "ik_vec3d.h"
#include "ik_ISoundSource.h" #include "ik_ISoundSource.h"
#include "ik_ISound.h" #include "ik_ISound.h"
#include "ik_EStreamModes.h" #include "ik_EStreamModes.h"
#include "ik_IFileFactory.h" #include "ik_IFileFactory.h"
#include "ik_ISoundMixedOutputReceiver.h"
namespace irrklang
{ namespace irrklang
class IAudioStreamLoader; {
class IAudioStreamLoader;
//! Interface to the sound engine, for playing 3d and 2d sound and music. struct SInternalAudioInterface;
/** This is the main interface of irrKlang. You usually would create this using
the createIrrKlangDevice() function. //! Interface to the sound engine, for playing 3d and 2d sound and music.
*/ /** This is the main interface of irrKlang. You usually would create this using
class ISoundEngine : public virtual irrklang::IRefCounted the createIrrKlangDevice() function.
{ */
public: class ISoundEngine : public virtual irrklang::IRefCounted
{
//! returns the name of the sound driver, like 'ALSA' for the alsa device public:
/** Possible returned strings are "NULL", "ALSA", "CoreAudio", "winMM",
"DirectSound" and "DirectSound8". */ //! returns the name of the sound driver, like 'ALSA' for the alsa device
virtual const char* getDriverName() = 0; /** Possible returned strings are "NULL", "ALSA", "CoreAudio", "winMM",
"DirectSound" and "DirectSound8". */
//! loads a sound source (if not loaded already) from a file and plays it. virtual const char* getDriverName() = 0;
/** \param sourceFileName Filename of sound, like "sounds/test.wav" or "foobar.ogg".
\param playLooped plays the sound in loop mode. If set to 'false', the sound is played once, then stopped and deleted from the internal playing list. Calls to //! loads a sound source (if not loaded already) from a file and plays it.
ISound have no effect after such a non looped sound has been stopped automaticly. /** \param sourceFileName Filename of sound, like "sounds/test.wav" or "foobar.ogg".
\param startPaused starts the sound paused. This implies that track=true. Use this if you want to modify some of the playing \param playLooped plays the sound in loop mode. If set to 'false', the sound is played once, then stopped and deleted from the internal playing list. Calls to
parameters before the sound actually plays. Usually you would set this parameter to true, then use the ISound interface to ISound have no effect after such a non looped sound has been stopped automaticly.
modify some of the sound parameters and then call ISound::setPaused(false); \param startPaused starts the sound paused. This implies that track=true. Use this if you want to modify some of the playing
Note: You need to call ISound::drop() when setting this parameter to true and you don't need the ISound parameters before the sound actually plays. Usually you would set this parameter to true, then use the ISound interface to
object anymore. See 'return' for details. modify some of the sound parameters and then call ISound::setPaused(false);
\param track Makes it possible to track the sound. Causes the method to return an ISound interface. See 'return' for details. Note: You need to call ISound::drop() when setting this parameter to true and you don't need the ISound
\param streamMode Specifies if the file should be streamed or loaded completely into memory for playing. object anymore. See 'return' for details.
ESM_AUTO_DETECT sets this to autodetection. Note: if the sound has been loaded or played before into the \param track Makes it possible to track the sound. Causes the method to return an ISound interface. See 'return' for details.
engine, this parameter has no effect. \param streamMode Specifies if the file should be streamed or loaded completely into memory for playing.
\param enableSoundEffects Makes it possible to use sound effects such as chorus, distorsions, echo, ESM_AUTO_DETECT sets this to autodetection. Note: if the sound has been loaded or played before into the
reverb and similar for this sound. Sound effects can then be controlled via ISound::getSoundEffectControl(). engine, this parameter has no effect.
Only enable if necessary. \param enableSoundEffects Makes it possible to use sound effects such as chorus, distorsions, echo,
\return Only returns a pointer to an ISound if the parameters 'track', 'startPaused' or reverb and similar for this sound. Sound effects can then be controlled via ISound::getSoundEffectControl().
'enableSoundEffects' have been set to true. Note: if this method returns an ISound as result, Only enable if necessary.
you HAVE to call ISound::drop() after you don't need the ISound interface anymore. Otherwise this \return Only returns a pointer to an ISound if the parameters 'track', 'startPaused' or
will cause memory waste. This method also may return 0 altough 'track', 'startPaused' or 'enableSoundEffects' have been set to true. Note: if this method returns an ISound as result,
'enableSoundEffects' have been set to true, if the sound could not be played.*/ you HAVE to call ISound::drop() after you don't need the ISound interface anymore. Otherwise this
virtual ISound* play2D(const char* soundFileName, will cause memory waste. This method also may return 0 altough 'track', 'startPaused' or
bool playLooped = false, 'enableSoundEffects' have been set to true, if the sound could not be played.*/
bool startPaused = false, virtual ISound* play2D(const char* soundFileName,
bool track = false, bool playLooped = false,
E_STREAM_MODE streamMode = ESM_AUTO_DETECT, bool startPaused = false,
bool enableSoundEffects = false) = 0; bool track = false,
E_STREAM_MODE streamMode = ESM_AUTO_DETECT,
//! Plays a sound source as 2D sound with its default settings stored in ISoundSource. bool enableSoundEffects = false) = 0;
/** An ISoundSource object will be created internally when playing a sound the first time,
or can be added with getSoundSource(). //! Plays a sound source as 2D sound with its default settings stored in ISoundSource.
\param source The sound source, specifiying sound file source and default settings for this file. /** An ISoundSource object will be created internally when playing a sound the first time,
Use the other ISoundEngine::play2D() overloads if you want to specify a filename string instead of this. or can be added with getSoundSource().
\param playLooped plays the sound in loop mode. If set to 'false', the sound is played once, then stopped and deleted from the internal playing list. Calls to \param source The sound source, specifiying sound file source and default settings for this file.
ISound have no effect after such a non looped sound has been stopped automaticly. Use the other ISoundEngine::play2D() overloads if you want to specify a filename string instead of this.
\param startPaused starts the sound paused. This implies that track=true. Use this if you want to modify some of the playing \param playLooped plays the sound in loop mode. If set to 'false', the sound is played once, then stopped and deleted from the internal playing list. Calls to
parameters before the sound actually plays. Usually you would set this parameter to true, then use the ISound interface to ISound have no effect after such a non looped sound has been stopped automaticly.
modify some of the sound parameters and then call ISound::setPaused(false); \param startPaused starts the sound paused. This implies that track=true. Use this if you want to modify some of the playing
Note: You need to call ISound::drop() when setting this parameter to true and you don't need the ISound parameters before the sound actually plays. Usually you would set this parameter to true, then use the ISound interface to
object anymore. See 'return' for details. modify some of the sound parameters and then call ISound::setPaused(false);
\param track Makes it possible to track the sound. Causes the method to return an ISound interface. See 'return' for details. Note: You need to call ISound::drop() when setting this parameter to true and you don't need the ISound
\param enableSoundEffects Makes it possible to use sound effects such as chorus, distorsions, echo, object anymore. See 'return' for details.
reverb and similar for this sound. Sound effects can then be controlled via ISound::getSoundEffectControl(). \param track Makes it possible to track the sound. Causes the method to return an ISound interface. See 'return' for details.
Only enable if necessary. \param enableSoundEffects Makes it possible to use sound effects such as chorus, distorsions, echo,
\return Only returns a pointer to an ISound if the parameters 'track', 'startPaused' or reverb and similar for this sound. Sound effects can then be controlled via ISound::getSoundEffectControl().
'enableSoundEffects' have been set to true. Note: if this method returns an ISound as result, Only enable if necessary.
you HAVE to call ISound::drop() after you don't need the ISound interface anymore. Otherwise this \return Only returns a pointer to an ISound if the parameters 'track', 'startPaused' or
will cause memory waste. This method also may return 0 altough 'track', 'startPaused' or 'enableSoundEffects' have been set to true. Note: if this method returns an ISound as result,
'enableSoundEffects' have been set to true, if the sound could not be played.*/ you HAVE to call ISound::drop() after you don't need the ISound interface anymore. Otherwise this
virtual ISound* play2D(ISoundSource* source, will cause memory waste. This method also may return 0 altough 'track', 'startPaused' or
bool playLooped = false, 'enableSoundEffects' have been set to true, if the sound could not be played.*/
bool startPaused = false, virtual ISound* play2D(ISoundSource* source,
bool track = false, bool playLooped = false,
bool enableSoundEffects = false) = 0; bool startPaused = false,
bool track = false,
//! Loads a sound source (if not loaded already) from a file and plays it as 3D sound. bool enableSoundEffects = false) = 0;
/** There is some example code on how to work with 3D sound at @ref sound3d.
\param sourceFileName Filename of sound, like "sounds/test.wav" or "foobar.ogg". //! Loads a sound source (if not loaded already) from a file and plays it as 3D sound.
\param pos Position of the 3D sound. /** There is some example code on how to work with 3D sound at @ref sound3d.
\param playLooped plays the sound in loop mode. If set to 'false', the sound is played once, then stopped and deleted from the internal playing list. Calls to \param sourceFileName Filename of sound, like "sounds/test.wav" or "foobar.ogg".
ISound have no effect after such a non looped sound has been stopped automaticly. \param pos Position of the 3D sound.
\param startPaused starts the sound paused. This implies that track=true. Use this if you want to modify some of the playing \param playLooped plays the sound in loop mode. If set to 'false', the sound is played once, then stopped and deleted from the internal playing list. Calls to
parameters before the sound actually plays. Usually you would set this parameter to true, then use the ISound interface to ISound have no effect after such a non looped sound has been stopped automaticly.
modify some of the sound parameters and then call ISound::setPaused(false); \param startPaused starts the sound paused. This implies that track=true. Use this if you want to modify some of the playing
Note: You need to call ISound::drop() when setting this parameter to true and you don't need the ISound parameters before the sound actually plays. Usually you would set this parameter to true, then use the ISound interface to
object anymore. See 'return' for details. modify some of the sound parameters and then call ISound::setPaused(false);
\param track Makes it possible to track the sound. Causes the method to return an ISound interface. See 'return' for details. Note: You need to call ISound::drop() when setting this parameter to true and you don't need the ISound
\param streamMode Specifies if the file should be streamed or loaded completely into memory for playing. object anymore. See 'return' for details.
ESM_AUTO_DETECT sets this to autodetection. Note: if the sound has been loaded or played before into the \param track Makes it possible to track the sound. Causes the method to return an ISound interface. See 'return' for details.
engine, this parameter has no effect. \param streamMode Specifies if the file should be streamed or loaded completely into memory for playing.
\param enableSoundEffects Makes it possible to use sound effects such as chorus, distorsions, echo, ESM_AUTO_DETECT sets this to autodetection. Note: if the sound has been loaded or played before into the
reverb and similar for this sound. Sound effects can then be controlled via ISound::getSoundEffectControl(). engine, this parameter has no effect.
Only enable if necessary. \param enableSoundEffects Makes it possible to use sound effects such as chorus, distorsions, echo,
\return Only returns a pointer to an ISound if the parameters 'track', 'startPaused' or reverb and similar for this sound. Sound effects can then be controlled via ISound::getSoundEffectControl().
'enableSoundEffects' have been set to true. Note: if this method returns an ISound as result, Only enable if necessary.
you HAVE to call ISound::drop() after you don't need the ISound interface anymore. Otherwise this \return Only returns a pointer to an ISound if the parameters 'track', 'startPaused' or
will cause memory waste. This method also may return 0 altough 'track', 'startPaused' or 'enableSoundEffects' have been set to true. Note: if this method returns an ISound as result,
'enableSoundEffects' have been set to true, if the sound could not be played.*/ you HAVE to call ISound::drop() after you don't need the ISound interface anymore. Otherwise this
virtual ISound* play3D(const char* soundFileName, vec3df pos, will cause memory waste. This method also may return 0 altough 'track', 'startPaused' or
bool playLooped = false, 'enableSoundEffects' have been set to true, if the sound could not be played.*/
bool startPaused = false, virtual ISound* play3D(const char* soundFileName, vec3df pos,
bool track = false, bool playLooped = false,
E_STREAM_MODE streamMode = ESM_AUTO_DETECT, bool startPaused = false,
bool enableSoundEffects = false) = 0; bool track = false,
E_STREAM_MODE streamMode = ESM_AUTO_DETECT,
//! Plays a sound source as 3D sound with its default settings stored in ISoundSource. bool enableSoundEffects = false) = 0;
/** An ISoundSource object will be created internally when playing a sound the first time,
or can be added with getSoundSource(). There is some example code on how to work with 3D sound @ref sound3d. //! Plays a sound source as 3D sound with its default settings stored in ISoundSource.
\param source The sound source, specifiying sound file source and default settings for this file. /** An ISoundSource object will be created internally when playing a sound the first time,
Use the other ISoundEngine::play2D() overloads if you want to specify a filename string instead of this. or can be added with getSoundSource(). There is some example code on how to work with 3D sound @ref sound3d.
\param pos Position of the 3D sound. \param source The sound source, specifiying sound file source and default settings for this file.
\param playLooped plays the sound in loop mode. If set to 'false', the sound is played once, then stopped and deleted from the internal playing list. Calls to Use the other ISoundEngine::play2D() overloads if you want to specify a filename string instead of this.
ISound have no effect after such a non looped sound has been stopped automaticly. \param pos Position of the 3D sound.
\param startPaused starts the sound paused. This implies that track=true. Use this if you want to modify some of the playing \param playLooped plays the sound in loop mode. If set to 'false', the sound is played once, then stopped and deleted from the internal playing list. Calls to
parameters before the sound actually plays. Usually you would set this parameter to true, then use the ISound interface to ISound have no effect after such a non looped sound has been stopped automaticly.
modify some of the sound parameters and then call ISound::setPaused(false); \param startPaused starts the sound paused. This implies that track=true. Use this if you want to modify some of the playing
Note: You need to call ISound::drop() when setting this parameter to true and you don't need the ISound parameters before the sound actually plays. Usually you would set this parameter to true, then use the ISound interface to
object anymore. See 'return' for details. modify some of the sound parameters and then call ISound::setPaused(false);
\param track Makes it possible to track the sound. Causes the method to return an ISound interface. See 'return' for details. Note: You need to call ISound::drop() when setting this parameter to true and you don't need the ISound
\param enableSoundEffects Makes it possible to use sound effects such as chorus, distorsions, echo, object anymore. See 'return' for details.
reverb and similar for this sound. Sound effects can then be controlled via ISound::getSoundEffectControl(). \param track Makes it possible to track the sound. Causes the method to return an ISound interface. See 'return' for details.
Only enable if necessary. \param enableSoundEffects Makes it possible to use sound effects such as chorus, distorsions, echo,
\return Only returns a pointer to an ISound if the parameters 'track', 'startPaused' or reverb and similar for this sound. Sound effects can then be controlled via ISound::getSoundEffectControl().
'enableSoundEffects' have been set to true. Note: if this method returns an ISound as result, Only enable if necessary.
you HAVE to call ISound::drop() after you don't need the ISound interface anymore. Otherwise this \return Only returns a pointer to an ISound if the parameters 'track', 'startPaused' or
will cause memory waste. This method also may return 0 altough 'track', 'startPaused' or 'enableSoundEffects' have been set to true. Note: if this method returns an ISound as result,
'enableSoundEffects' have been set to true, if the sound could not be played.*/ you HAVE to call ISound::drop() after you don't need the ISound interface anymore. Otherwise this
virtual ISound* play3D(ISoundSource* source, vec3df pos, will cause memory waste. This method also may return 0 altough 'track', 'startPaused' or
bool playLooped = false, 'enableSoundEffects' have been set to true, if the sound could not be played.*/
bool startPaused = false, virtual ISound* play3D(ISoundSource* source, vec3df pos,
bool track = false, bool playLooped = false,
bool enableSoundEffects = false) = 0; bool startPaused = false,
bool track = false,
//! Stops all currently playing sounds. bool enableSoundEffects = false) = 0;
virtual void stopAllSounds() = 0;
//! Stops all currently playing sounds.
//! Pauses or unpauses all currently playing sounds. virtual void stopAllSounds() = 0;
virtual void setAllSoundsPaused( bool bPaused = true ) = 0;
//! Pauses or unpauses all currently playing sounds.
//! Gets a sound source by sound name. Adds the sound source as file into the sound engine if not loaded already. virtual void setAllSoundsPaused( bool bPaused = true ) = 0;
/** Please note: For performance reasons most ISoundEngine implementations will
not try to load the sound when calling this method, but only when play() is called //! Gets a sound source by sound name. Adds the sound source as file into the sound engine if not loaded already.
with this sound source as parameter. /** Please note: For performance reasons most ISoundEngine implementations will
\param addIfNotFound if 'true' adds the sound source to the list and returns the interface to it not try to load the sound when calling this method, but only when play() is called
if it cannot be found in the sound source list. If 'false', returns 0 if the sound with this sound source as parameter.
source is not in the list and does not modify the list. Default value: true. \param addIfNotFound if 'true' adds the sound source to the list and returns the interface to it
\return Returns the sound source or 0 if not available. if it cannot be found in the sound source list. If 'false', returns 0 if the sound
Note: Don't call drop() to this pointer, it will be managed by irrKlang and source is not in the list and does not modify the list. Default value: true.
exist as long as you don't delete irrKlang or call removeSoundSource(). However, \return Returns the sound source or 0 if not available.
you are free to call grab() if you want and drop() it then later of course. */ Note: Don't call drop() to this pointer, it will be managed by irrKlang and
virtual ISoundSource* getSoundSource(const ik_c8* soundName, bool addIfNotFound=true) = 0; exist as long as you don't delete irrKlang or call removeSoundSource(). However,
you are free to call grab() if you want and drop() it then later of course. */
//! Returns a sound source by index. virtual ISoundSource* getSoundSource(const ik_c8* soundName, bool addIfNotFound=true) = 0;
/** \param idx: Index of the loaded sound source, must by smaller than getSoundSourceCount().
\return Returns the sound source or 0 if not available. //! Returns a sound source by index.
Note: Don't call drop() to this pointer, it will be managed by irrKlang and /** \param idx: Index of the loaded sound source, must by smaller than getSoundSourceCount().
exist as long as you don't delete irrKlang or call removeSoundSource(). However, \return Returns the sound source or 0 if not available.
you are free to call grab() if you want and drop() it then later of course. */ Note: Don't call drop() to this pointer, it will be managed by irrKlang and
virtual ISoundSource* getSoundSource(ik_s32 index) = 0; exist as long as you don't delete irrKlang or call removeSoundSource(). However,
you are free to call grab() if you want and drop() it then later of course. */
//! Returns amount of loaded sound sources. virtual ISoundSource* getSoundSource(ik_s32 index) = 0;
virtual ik_s32 getSoundSourceCount() = 0;
//! Returns amount of loaded sound sources.
//! Adds sound source into the sound engine as file. virtual ik_s32 getSoundSourceCount() = 0;
/** \param fileName Name of the sound file (e.g. "sounds/something.mp3"). You can also use this
name when calling play3D() or play2D(). //! Adds sound source into the sound engine as file.
\param mode Streaming mode for this sound source /** \param fileName Name of the sound file (e.g. "sounds/something.mp3"). You can also use this
\param preload If this flag is set to false (which is default) the sound engine will name when calling play3D() or play2D().
not try to load the sound file when calling this method, but only when play() is called \param mode Streaming mode for this sound source
with this sound source as parameter. Otherwise the sound will be preloaded. \param preload If this flag is set to false (which is default) the sound engine will
\return Returns the pointer to the added sound source or 0 if not sucessful because for not try to load the sound file when calling this method, but only when play() is called
example a sound already existed with that name. If not successful, the reason will be printed with this sound source as parameter. Otherwise the sound will be preloaded.
into the log. Note: Don't call drop() to this pointer, it will be managed by irrKlang and \return Returns the pointer to the added sound source or 0 if not sucessful because for
exist as long as you don't delete irrKlang or call removeSoundSource(). However, example a sound already existed with that name. If not successful, the reason will be printed
you are free to call grab() if you want and drop() it then later of course. */ into the log. Note: Don't call drop() to this pointer, it will be managed by irrKlang and
virtual ISoundSource* addSoundSourceFromFile(const ik_c8* fileName, E_STREAM_MODE mode=ESM_AUTO_DETECT, exist as long as you don't delete irrKlang or call removeSoundSource(). However,
bool preload=false) = 0; you are free to call grab() if you want and drop() it then later of course. */
virtual ISoundSource* addSoundSourceFromFile(const ik_c8* fileName, E_STREAM_MODE mode=ESM_AUTO_DETECT,
//! Adds a sound source into the sound engine as memory source. bool preload=false) = 0;
/** Note: This method only accepts a file (.wav, .ogg, etc) which is totally loaded into memory.
If you want to add a sound source from decoded plain PCM data in memory, use addSoundSourceFromPCMData() instead. //! Adds a sound source into the sound engine as memory source.
\param memory Pointer to the memory to be treated as loaded sound file. /** Note: This method only accepts a file (.wav, .ogg, etc) which is totally loaded into memory.
\param sizeInBytes Size of the memory chunk, in bytes. If you want to add a sound source from decoded plain PCM data in memory, use addSoundSourceFromPCMData() instead.
\param soundName Name of the virtual sound file (e.g. "sounds/something.mp3"). You can also use this \param memory Pointer to the memory to be treated as loaded sound file.
name when calling play3D() or play2D(). Hint: If you include the extension of the original file \param sizeInBytes Size of the memory chunk, in bytes.
like .ogg, .mp3 or .wav at the end of the filename, irrKlang will be able to decide better what \param soundName Name of the virtual sound file (e.g. "sounds/something.mp3"). You can also use this
file format it is and might be able to start playback faster. name when calling play3D() or play2D(). Hint: If you include the extension of the original file
\param copyMemory If set to true which is default, the memory block is copied like .ogg, .mp3 or .wav at the end of the filename, irrKlang will be able to decide better what
and stored in the engine, after calling addSoundSourceFromMemory() the memory pointer can be deleted file format it is and might be able to start playback faster.
savely. If set to true, the memory is not copied and the user takes the responsibility that \param copyMemory If set to true which is default, the memory block is copied
the memory block pointed to remains there as long as the sound engine or at least this sound and stored in the engine, after calling addSoundSourceFromMemory() the memory pointer can be deleted
source exists. savely. If set to false, the memory is not copied and the user takes the responsibility that
\return Returns the pointer to the added sound source or 0 if not sucessful because for the memory block pointed to remains there as long as the sound engine or at least this sound
example a sound already existed with that name. If not successful, the reason will be printed source exists.
into the log. */ \return Returns the pointer to the added sound source or 0 if not sucessful because for
virtual ISoundSource* addSoundSourceFromMemory(void* memory, ik_s32 sizeInBytes, const ik_c8* soundName, example a sound already existed with that name. If not successful, the reason will be printed
bool copyMemory=true) = 0; into the log. */
virtual ISoundSource* addSoundSourceFromMemory(void* memory, ik_s32 sizeInBytes, const ik_c8* soundName,
bool copyMemory=true) = 0;
//! Adds a sound source into the sound engine from plain PCM data in memory.
/** \param memory Pointer to the memory to be treated as loaded sound file.
\param sizeInBytes Size of the memory chunk, in bytes. //! Adds a sound source into the sound engine from plain PCM data in memory.
\param soundName Name of the virtual sound file (e.g. "sounds/something.mp3"). You can also use this /** \param memory Pointer to the memory to be treated as loaded sound file.
name when calling play3D() or play2D(). \param sizeInBytes Size of the memory chunk, in bytes.
\param copyMemory If set to true which is default, the memory block is copied \param soundName Name of the virtual sound file (e.g. "sounds/something.mp3"). You can also use this
and stored in the engine, after calling addSoundSourceFromPCMData() the memory pointer can be deleted name when calling play3D() or play2D().
savely. If set to true, the memory is not copied and the user takes the responsibility that \param copyMemory If set to true which is default, the memory block is copied
the memory block pointed to remains there as long as the sound engine or at least this sound and stored in the engine, after calling addSoundSourceFromPCMData() the memory pointer can be deleted
source exists. savely. If set to true, the memory is not copied and the user takes the responsibility that
\return Returns the pointer to the added sound source or 0 if not sucessful because for the memory block pointed to remains there as long as the sound engine or at least this sound
example a sound already existed with that name. If not successful, the reason will be printed source exists.
into the log. */ \return Returns the pointer to the added sound source or 0 if not sucessful because for
virtual ISoundSource* addSoundSourceFromPCMData(void* memory, ik_s32 sizeInBytes, example a sound already existed with that name. If not successful, the reason will be printed
const ik_c8* soundName, SAudioStreamFormat format, into the log. */
bool copyMemory=true) = 0; virtual ISoundSource* addSoundSourceFromPCMData(void* memory, ik_s32 sizeInBytes,
const ik_c8* soundName, SAudioStreamFormat format,
//! Adds a sound source as alias for an existing sound source, but with a different name or optional different default settings. bool copyMemory=true) = 0;
/** This is useful if you want to play multiple sounds but each sound isn't necessarily one single file.
Also useful if you want to or play the same sound using different names, volumes or min and max 3D distances. //! Adds a sound source as alias for an existing sound source, but with a different name or optional different default settings.
\param baseSource The sound source where this sound source should be based on. This sound /** This is useful if you want to play multiple sounds but each sound isn't necessarily one single file.
source will use the baseSource as base to access the file and similar, but it will have its Also useful if you want to or play the same sound using different names, volumes or min and max 3D distances.
own name and its own default settings. \param baseSource The sound source where this sound source should be based on. This sound
\param soundName Name of the new sound source to be added. source will use the baseSource as base to access the file and similar, but it will have its
\return Returns the pointer to the added sound source or 0 if not sucessful because for own name and its own default settings.
example a sound already existed with that name. If not successful, the reason will be printed \param soundName Name of the new sound source to be added.
into the log.*/ \return Returns the pointer to the added sound source or 0 if not sucessful because for
virtual ISoundSource* addSoundSourceAlias(ISoundSource* baseSource, const ik_c8* soundName) = 0; example a sound already existed with that name. If not successful, the reason will be printed
into the log.*/
//! Removes a sound source from the engine, freeing the memory it occupies. virtual ISoundSource* addSoundSourceAlias(ISoundSource* baseSource, const ik_c8* soundName) = 0;
/** This will also cause all currently playing sounds of this source to be stopped.
Also note that if the source has been removed successfully, the value returned //! Removes a sound source from the engine, freeing the memory it occupies.
by getSoundSourceCount() will have been decreased by one. /** This will also cause all currently playing sounds of this source to be stopped.
Removing sound sources is only necessary if you know you won't use a lot of non-streamed Also note that if the source has been removed successfully, the value returned
sounds again. Sound sources of streamed sounds do not cost a lot of memory.*/ by getSoundSourceCount() will have been decreased by one.
virtual void removeSoundSource(ISoundSource* source) = 0; Removing sound sources is only necessary if you know you won't use a lot of non-streamed
sounds again. Sound sources of streamed sounds do not cost a lot of memory.*/
//! Removes a sound source from the engine, freeing the memory it occupies. virtual void removeSoundSource(ISoundSource* source) = 0;
/** This will also cause all currently playing sounds of this source to be stopped.
Also note that if the source has been removed successfully, the value returned //! Removes a sound source from the engine, freeing the memory it occupies.
by getSoundSourceCount() will have been decreased by one. /** This will also cause all currently playing sounds of this source to be stopped.
Removing sound sources is only necessary if you know you won't use a lot of non-streamed Also note that if the source has been removed successfully, the value returned
sounds again. Sound sources of streamed sounds do not cost a lot of memory. */ by getSoundSourceCount() will have been decreased by one.
virtual void removeSoundSource(const ik_c8* name) = 0; Removing sound sources is only necessary if you know you won't use a lot of non-streamed
sounds again. Sound sources of streamed sounds do not cost a lot of memory. */
//! Removes all sound sources from the engine virtual void removeSoundSource(const ik_c8* name) = 0;
/** This will also cause all sounds to be stopped.
Removing sound sources is only necessary if you know you won't use a lot of non-streamed //! Removes all sound sources from the engine
sounds again. Sound sources of streamed sounds do not cost a lot of memory. */ /** This will also cause all sounds to be stopped.
virtual void removeAllSoundSources() = 0; Removing sound sources is only necessary if you know you won't use a lot of non-streamed
sounds again. Sound sources of streamed sounds do not cost a lot of memory. */
//! Sets master sound volume. This value is multiplied with all sounds played. virtual void removeAllSoundSources() = 0;
/** \param volume 0 (silent) to 1.0f (full volume) */
virtual void setSoundVolume(ik_f32 volume) = 0; //! Sets master sound volume. This value is multiplied with all sounds played.
/** \param volume 0 (silent) to 1.0f (full volume) */
//! Returns master sound volume. virtual void setSoundVolume(ik_f32 volume) = 0;
/* A value between 0.0 and 1.0. Default is 1.0. Can be changed using setSoundVolume(). */
virtual ik_f32 getSoundVolume() = 0; //! Returns master sound volume.
/* A value between 0.0 and 1.0. Default is 1.0. Can be changed using setSoundVolume(). */
//! Sets the current listener 3d position. virtual ik_f32 getSoundVolume() = 0;
/** When playing sounds in 3D, updating the position of the listener every frame should be
done using this function. //! Sets the current listener 3d position.
\param pos Position of the camera or listener. /** When playing sounds in 3D, updating the position of the listener every frame should be
\param lookdir Direction vector where the camera or listener is looking into. If you have a done using this function.
camera position and a target 3d point where it is looking at, this would be cam->getTarget() - cam->getAbsolutePosition(). \param pos Position of the camera or listener.
\param velPerSecond The velocity per second describes the speed of the listener and \param lookdir Direction vector where the camera or listener is looking into. If you have a
is only needed for doppler effects. camera position and a target 3d point where it is looking at, this would be cam->getTarget() - cam->getAbsolutePosition().
\param upvector Vector pointing 'up', so the engine can decide where is left and right. \param velPerSecond The velocity per second describes the speed of the listener and
This vector is usually (0,1,0).*/ is only needed for doppler effects.
virtual void setListenerPosition(const vec3df& pos, \param upvector Vector pointing 'up', so the engine can decide where is left and right.
const vec3df& lookdir, This vector is usually (0,1,0).*/
const vec3df& velPerSecond = vec3df(0,0,0), virtual void setListenerPosition(const vec3df& pos,
const vec3df& upVector = vec3df(0,1,0)) = 0; const vec3df& lookdir,
const vec3df& velPerSecond = vec3df(0,0,0),
//! Updates the audio engine. This should be called several times per frame if irrKlang was started in single thread mode. const vec3df& upVector = vec3df(0,1,0)) = 0;
/** This updates the 3d positions of the sounds as well as their volumes, effects,
streams and other stuff. Call this several times per frame (the more the better) if you //! Updates the audio engine. This should be called several times per frame if irrKlang was started in single thread mode.
specified irrKlang to run single threaded. Otherwise it is not necessary to use this method. /** This updates the 3d positions of the sounds as well as their volumes, effects,
This method is being called by the scene manager automaticly if you are using one, so streams and other stuff. Call this several times per frame (the more the better) if you
you might want to ignore this. */ specified irrKlang to run single threaded. Otherwise it is not necessary to use this method.
virtual void update() = 0; This method is being called by the scene manager automaticly if you are using one, so
you might want to ignore this. */
//! Returns if a sound with the specified name is currently playing. virtual void update() = 0;
virtual bool isCurrentlyPlaying(const char* soundName) = 0;
//! Returns if a sound with the specified name is currently playing.
//! Returns if a sound with the specified source is currently playing. virtual bool isCurrentlyPlaying(const char* soundName) = 0;
virtual bool isCurrentlyPlaying(ISoundSource* source) = 0;
//! Returns if a sound with the specified source is currently playing.
//! Registers a new audio stream loader in the sound engine. virtual bool isCurrentlyPlaying(ISoundSource* source) = 0;
/** Use this to enhance the audio engine to support other or new file formats.
To do this, implement your own IAudioStreamLoader interface and register it //! Registers a new audio stream loader in the sound engine.
with this method */ /** Use this to enhance the audio engine to support other or new file formats.
virtual void registerAudioStreamLoader(IAudioStreamLoader* loader) = 0; To do this, implement your own IAudioStreamLoader interface and register it
with this method */
//! Returns if irrKlang is running in the same thread as the application or is using multithreading. virtual void registerAudioStreamLoader(IAudioStreamLoader* loader) = 0;
/** This basicly returns the flag set by the user when creating the sound engine.*/
virtual bool isMultiThreaded() const = 0; //! Returns if irrKlang is running in the same thread as the application or is using multithreading.
/** This basicly returns the flag set by the user when creating the sound engine.*/
//! Adds a file factory to the sound engine, making it possible to override file access of the sound engine. virtual bool isMultiThreaded() const = 0;
/** Derive your own class from IFileFactory, overwrite the createFileReader()
method and return your own implemented IFileReader to overwrite file access of irrKlang. */ //! Adds a file factory to the sound engine, making it possible to override file access of the sound engine.
virtual void addFileFactory(IFileFactory* fileFactory) = 0; /** Derive your own class from IFileFactory, overwrite the createFileReader()
method and return your own implemented IFileReader to overwrite file access of irrKlang. */
//! Sets the default minimal distance for 3D sounds. virtual void addFileFactory(IFileFactory* fileFactory) = 0;
/** This value influences how loud a sound is heard based on its distance.
See ISound::setMinDistance() for details about what the min distance is. //! Sets the default minimal distance for 3D sounds.
It is also possible to influence this default value for every sound file /** This value influences how loud a sound is heard based on its distance.
using ISoundSource::setDefaultMinDistance(). See ISound::setMinDistance() for details about what the min distance is.
This method only influences the initial distance value of sounds. For changing the It is also possible to influence this default value for every sound file
distance after the sound has been started to play, use ISound::setMinDistance() and ISound::setMaxDistance(). using ISoundSource::setDefaultMinDistance().
\param minDistance Default minimal distance for 3d sounds. The default value is 1.0f.*/ This method only influences the initial distance value of sounds. For changing the
virtual void setDefault3DSoundMinDistance(ik_f32 minDistance) = 0; distance after the sound has been started to play, use ISound::setMinDistance() and ISound::setMaxDistance().
\param minDistance Default minimal distance for 3d sounds. The default value is 1.0f.*/
//! Returns the default minimal distance for 3D sounds. virtual void setDefault3DSoundMinDistance(ik_f32 minDistance) = 0;
/** This value influences how loud a sound is heard based on its distance.
You can change it using setDefault3DSoundMinDistance(). //! Returns the default minimal distance for 3D sounds.
See ISound::setMinDistance() for details about what the min distance is. /** This value influences how loud a sound is heard based on its distance.
It is also possible to influence this default value for every sound file You can change it using setDefault3DSoundMinDistance().
using ISoundSource::setDefaultMinDistance(). See ISound::setMinDistance() for details about what the min distance is.
\return Default minimal distance for 3d sounds. The default value is 1.0f. */ It is also possible to influence this default value for every sound file
virtual ik_f32 getDefault3DSoundMinDistance() = 0; using ISoundSource::setDefaultMinDistance().
\return Default minimal distance for 3d sounds. The default value is 1.0f. */
//! Sets the default maximal distance for 3D sounds. virtual ik_f32 getDefault3DSoundMinDistance() = 0;
/** Changing this value is usually not necessary. Use setDefault3DSoundMinDistance() instead.
Don't change this value if you don't know what you are doing: This value causes the sound //! Sets the default maximal distance for 3D sounds.
to stop attenuating after it reaches the max distance. Most people think that this sets the /** Changing this value is usually not necessary. Use setDefault3DSoundMinDistance() instead.
volume of the sound to 0 after this distance, but this is not true. Only change the Don't change this value if you don't know what you are doing: This value causes the sound
minimal distance (using for example setDefault3DSoundMinDistance()) to influence this. to stop attenuating after it reaches the max distance. Most people think that this sets the
See ISound::setMaxDistance() for details about what the max distance is. volume of the sound to 0 after this distance, but this is not true. Only change the
It is also possible to influence this default value for every sound file minimal distance (using for example setDefault3DSoundMinDistance()) to influence this.
using ISoundSource::setDefaultMaxDistance(). See ISound::setMaxDistance() for details about what the max distance is.
This method only influences the initial distance value of sounds. For changing the It is also possible to influence this default value for every sound file
distance after the sound has been started to play, use ISound::setMinDistance() and ISound::setMaxDistance(). using ISoundSource::setDefaultMaxDistance().
\param maxDistance Default maximal distance for 3d sounds. The default value is 1000000000.0f. */ This method only influences the initial distance value of sounds. For changing the
virtual void setDefault3DSoundMaxDistance(ik_f32 maxDistance) = 0; distance after the sound has been started to play, use ISound::setMinDistance() and ISound::setMaxDistance().
\param maxDistance Default maximal distance for 3d sounds. The default value is 1000000000.0f. */
//! Returns the default maximal distance for 3D sounds. virtual void setDefault3DSoundMaxDistance(ik_f32 maxDistance) = 0;
/** This value influences how loud a sound is heard based on its distance.
You can change it using setDefault3DSoundmaxDistance(), but //! Returns the default maximal distance for 3D sounds.
changing this value is usually not necessary. This value causes the sound /** This value influences how loud a sound is heard based on its distance.
to stop attenuating after it reaches the max distance. Most people think that this sets the You can change it using setDefault3DSoundmaxDistance(), but
volume of the sound to 0 after this distance, but this is not true. Only change the changing this value is usually not necessary. This value causes the sound
minimal distance (using for example setDefault3DSoundMinDistance()) to influence this. to stop attenuating after it reaches the max distance. Most people think that this sets the
See ISound::setMaxDistance() for details about what the max distance is. volume of the sound to 0 after this distance, but this is not true. Only change the
It is also possible to influence this default value for every sound file minimal distance (using for example setDefault3DSoundMinDistance()) to influence this.
using ISoundSource::setDefaultMaxDistance(). See ISound::setMaxDistance() for details about what the max distance is.
\return Default maximal distance for 3d sounds. The default value is 1000000000.0f. */ It is also possible to influence this default value for every sound file
virtual ik_f32 getDefault3DSoundMaxDistance() = 0; using ISoundSource::setDefaultMaxDistance().
\return Default maximal distance for 3d sounds. The default value is 1000000000.0f. */
//! Sets a rolloff factor which influences the amount of attenuation that is applied to 3D sounds. virtual ik_f32 getDefault3DSoundMaxDistance() = 0;
/** The rolloff factor can range from 0.0 to 10.0, where 0 is no rolloff. 1.0 is the default
rolloff factor set, the value which we also experience in the real world. A value of 2 would mean //! Sets a rolloff factor which influences the amount of attenuation that is applied to 3D sounds.
twice the real-world rolloff. */ /** The rolloff factor can range from 0.0 to 10.0, where 0 is no rolloff. 1.0 is the default
virtual void setRolloffFactor(ik_f32 rolloff) = 0; rolloff factor set, the value which we also experience in the real world. A value of 2 would mean
twice the real-world rolloff. */
//! Sets parameters affecting the doppler effect. virtual void setRolloffFactor(ik_f32 rolloff) = 0;
/** \param dopplerFactor is a value between 0 and 10 which multiplies the doppler
effect. Default value is 1.0, which is the real world doppler effect, and 10.0f //! Sets parameters affecting the doppler effect.
would be ten times the real world doppler effect. /** \param dopplerFactor is a value between 0 and 10 which multiplies the doppler
\param distanceFactor is the number of meters in a vector unit. The default value effect. Default value is 1.0, which is the real world doppler effect, and 10.0f
is 1.0. Doppler effects are calculated in meters per second, with this parameter, would be ten times the real world doppler effect.
this can be changed, all velocities and positions are influenced by this. If \param distanceFactor is the number of meters in a vector unit. The default value
the measurement should be in foot instead of meters, set this value to 0.3048f is 1.0. Doppler effects are calculated in meters per second, with this parameter,
for example.*/ this can be changed, all velocities and positions are influenced by this. If
virtual void setDopplerEffectParameters(ik_f32 dopplerFactor=1.0f, ik_f32 distanceFactor=1.0f) = 0; the measurement should be in foot instead of meters, set this value to 0.3048f
for example.*/
//! Loads irrKlang plugins from a custom path. virtual void setDopplerEffectParameters(ik_f32 dopplerFactor=1.0f, ik_f32 distanceFactor=1.0f) = 0;
/** Plugins usually are .dll, .so or .dylib
files named for example ikpMP3.dll (= short for irrKlangPluginMP3) which //! Loads irrKlang plugins from a custom path.
make it possible to play back mp3 files. Plugins are being /** Plugins usually are .dll, .so or .dylib
loaded from the current working directory at startup of the sound engine files named for example ikpMP3.dll (= short for irrKlangPluginMP3) which
if the parameter ESEO_LOAD_PLUGINS is set (which it is by default), but make it possible to play back mp3 files. Plugins are being
using this method, it is possible to load plugins from a custom path in addition. loaded from the current working directory at startup of the sound engine
\param path Path to the plugin directory, like "C:\games\somegamegame\irrklangplugins". if the parameter ESEO_LOAD_PLUGINS is set (which it is by default), but
\return returns true if sucessful or fals if not, for example because the path could using this method, it is possible to load plugins from a custom path in addition.
not be found. */ \param path Path to the plugin directory, like "C:\games\somegamegame\irrklangplugins".
virtual bool loadPlugins(const ik_c8* path) = 0; \return returns true if sucessful or fals if not, for example because the path could
}; not be found. */
virtual bool loadPlugins(const ik_c8* path) = 0;
} // end namespace irrklang //! Returns a pointer to internal sound engine pointers, like the DirectSound interface.
/** Use this with caution. This is only exposed to make it possible for other libraries
such as Video playback packages to extend or use the sound driver irrklang uses. */
#endif virtual const SInternalAudioInterface& getInternalAudioInterface() = 0;
//! Sets the OutputMixedDataReceiver, so you can receive the pure mixed output audio data while it is being played.
/** This can be used to store the sound output as .wav file or for creating a Oscillograph or similar.
This works only with software based audio drivers, that is ESOD_WIN_MM, ESOD_ALSA, and ESOD_CORE_AUDIO.
Returns true if sucessful and fals if the current audio driver doesn't support this feature. Set this to null
again once you don't need it anymore. */
virtual bool setMixedDataOutputReceiver(ISoundMixedOutputReceiver* receiver) = 0;
};
//! structure for returning pointers to the internal audio interface.
/** Use ISoundEngine::getInternalAudioInterface() to get this. */
struct SInternalAudioInterface
{
//! IDirectSound interface, this is not null when using the ESOD_DIRECT_SOUND audio driver
void* pIDirectSound;
//! IDirectSound8 interface, this is not null when using the ESOD_DIRECT_SOUND8 audio driver
void* pIDirectSound8;
//! HWaveout interface, this is not null when using the ESOD_WIN_MM audio driver
void* pWinMM_HWaveOut;
//! ALSA PCM Handle interface, this is not null when using the ESOD_ALSA audio driver
void* pALSA_SND_PCM;
//! AudioDeviceID handle, this is not null when using the ESOD_CORE_AUDIO audio driver
ik_u32 pCoreAudioDeciceID;
};
} // end namespace irrklang
#endif

View File

@ -1,4 +1,4 @@
// Copyright (C) 2002-2008 Nikolaus Gebhardt // Copyright (C) 2002-2009 Nikolaus Gebhardt
// This file is part of the "irrKlang" library. // This file is part of the "irrKlang" library.
// For conditions of distribution and use, see copyright notice in irrKlang.h // For conditions of distribution and use, see copyright notice in irrKlang.h
@ -146,7 +146,7 @@ namespace irrklang
//! Returns the threshold size where irrKlang decides to force streaming a file independent of the user specified setting. //! Returns the threshold size where irrKlang decides to force streaming a file independent of the user specified setting.
/** The value is specified in uncompressed bytes and its default value is /** The value is specified in uncompressed bytes and its default value is
about one Megabyte. See setForcedStreamingThreshold() for details. */ about one Megabyte. See setForcedStreamingThreshold() for details. */
virtual ik_s32 getForcedStreamingForceThreshold() = 0; virtual ik_s32 getForcedStreamingThreshold() = 0;
//! Returns a pointer to the loaded and decoded sample data. //! Returns a pointer to the loaded and decoded sample data.
/** \return Returns a pointer to the sample data. The data is provided in decoded PCM data. The /** \return Returns a pointer to the sample data. The data is provided in decoded PCM data. The

View File

@ -1,72 +1,72 @@
// Copyright (C) 2002-2008 Nikolaus Gebhardt // Copyright (C) 2002-2009 Nikolaus Gebhardt
// This file is part of the "irrKlang" library. // This file is part of the "irrKlang" library.
// For conditions of distribution and use, see copyright notice in irrKlang.h // For conditions of distribution and use, see copyright notice in irrKlang.h
#ifndef __I_IRRKLANG_SOUND_STOP_EVENT_RECEIVER_H_INCLUDED__ #ifndef __I_IRRKLANG_SOUND_STOP_EVENT_RECEIVER_H_INCLUDED__
#define __I_IRRKLANG_SOUND_STOP_EVENT_RECEIVER_H_INCLUDED__ #define __I_IRRKLANG_SOUND_STOP_EVENT_RECEIVER_H_INCLUDED__
#include "ik_IRefCounted.h" #include "ik_IRefCounted.h"
#include "ik_SAudioStreamFormat.h" #include "ik_SAudioStreamFormat.h"
namespace irrklang namespace irrklang
{ {
//! An enumeration listing all reasons for a fired sound stop event //! An enumeration listing all reasons for a fired sound stop event
enum E_STOP_EVENT_CAUSE enum E_STOP_EVENT_CAUSE
{ {
//! The sound stop event was fired because the sound finished playing //! The sound stop event was fired because the sound finished playing
ESEC_SOUND_FINISHED_PLAYING = 0, ESEC_SOUND_FINISHED_PLAYING = 0,
//! The sound stop event was fired because the sound was stopped by the user, calling ISound::stop(). //! The sound stop event was fired because the sound was stopped by the user, calling ISound::stop().
ESEC_SOUND_STOPPED_BY_USER, ESEC_SOUND_STOPPED_BY_USER,
//! The sound stop event was fired because the source of the sound was removed, for example //! The sound stop event was fired because the source of the sound was removed, for example
//! because irrKlang was shut down or the user called ISoundEngine::removeSoundSource(). //! because irrKlang was shut down or the user called ISoundEngine::removeSoundSource().
ESEC_SOUND_STOPPED_BY_SOURCE_REMOVAL, ESEC_SOUND_STOPPED_BY_SOURCE_REMOVAL,
//! This enumeration literal is never used, it only forces the compiler to //! This enumeration literal is never used, it only forces the compiler to
//! compile these enumeration values to 32 bit. //! compile these enumeration values to 32 bit.
ESEC_FORCE_32_BIT = 0x7fffffff ESEC_FORCE_32_BIT = 0x7fffffff
}; };
//! Interface to be implemented by the user, which recieves sound stop events. //! Interface to be implemented by the user, which recieves sound stop events.
/** The interface has only one method to be implemented by the user: OnSoundStopped(). /** The interface has only one method to be implemented by the user: OnSoundStopped().
Implement this interface and set it via ISound::setSoundStopEventReceiver(). Implement this interface and set it via ISound::setSoundStopEventReceiver().
The sound stop event is guaranteed to be called when a sound or sound stream is finished, The sound stop event is guaranteed to be called when a sound or sound stream is finished,
either because the sound reached its playback end, its sound source was removed, either because the sound reached its playback end, its sound source was removed,
ISoundEngine::stopAllSounds() has been called or the whole engine was deleted. */ ISoundEngine::stopAllSounds() has been called or the whole engine was deleted. */
class ISoundStopEventReceiver class ISoundStopEventReceiver
{ {
public: public:
//! destructor //! destructor
virtual ~ISoundStopEventReceiver() {}; virtual ~ISoundStopEventReceiver() {};
//! Called when a sound has stopped playing. //! Called when a sound has stopped playing.
/** This is the only method to be implemented by the user. /** This is the only method to be implemented by the user.
The sound stop event is guaranteed to be called when a sound or sound stream is finished, The sound stop event is guaranteed to be called when a sound or sound stream is finished,
either because the sound reached its playback end, its sound source was removed, either because the sound reached its playback end, its sound source was removed,
ISoundEngine::stopAllSounds() has been called or the whole engine was deleted. ISoundEngine::stopAllSounds() has been called or the whole engine was deleted.
Please note: Sound events will occur in a different thread when the engine runs in Please note: Sound events will occur in a different thread when the engine runs in
multi threaded mode (default). In single threaded mode, the event will happen while multi threaded mode (default). In single threaded mode, the event will happen while
the user thread is calling ISoundEngine::update(). the user thread is calling ISoundEngine::update().
\param sound: Sound which has been stopped. \param sound: Sound which has been stopped.
\param reason: The reason why the sound stop event was fired. Usually, this will be ESEC_SOUND_FINISHED_PLAYING. \param reason: The reason why the sound stop event was fired. Usually, this will be ESEC_SOUND_FINISHED_PLAYING.
When the sound was aborded by calling ISound::stop() or ISoundEngine::stopAllSounds();, this would be When the sound was aborded by calling ISound::stop() or ISoundEngine::stopAllSounds();, this would be
ESEC_SOUND_STOPPED_BY_USER. If irrKlang was deleted or the sound source was removed, the value is ESEC_SOUND_STOPPED_BY_USER. If irrKlang was deleted or the sound source was removed, the value is
ESEC_SOUND_STOPPED_BY_SOURCE_REMOVAL. ESEC_SOUND_STOPPED_BY_SOURCE_REMOVAL.
\param userData: userData pointer set by the user when registering the interface \param userData: userData pointer set by the user when registering the interface
via ISound::setSoundStopEventReceiver(). */ via ISound::setSoundStopEventReceiver(). */
virtual void OnSoundStopped(ISound* sound, E_STOP_EVENT_CAUSE reason, void* userData) = 0; virtual void OnSoundStopped(ISound* sound, E_STOP_EVENT_CAUSE reason, void* userData) = 0;
}; };
} // end namespace irrklang } // end namespace irrklang
#endif #endif

View File

@ -1,48 +1,48 @@
// Copyright (C) 2002-2008 Nikolaus Gebhardt // Copyright (C) 2002-2009 Nikolaus Gebhardt
// This file is part of the "irrKlang" library. // This file is part of the "irrKlang" library.
// For conditions of distribution and use, see copyright notice in irrKlang.h // For conditions of distribution and use, see copyright notice in irrKlang.h
#ifndef __I_IRRKLANG_VIRTUAL_UNKNOWN_H_INCLUDED__ #ifndef __I_IRRKLANG_VIRTUAL_UNKNOWN_H_INCLUDED__
#define __I_IRRKLANG_VIRTUAL_UNKNOWN_H_INCLUDED__ #define __I_IRRKLANG_VIRTUAL_UNKNOWN_H_INCLUDED__
#include "ik_irrKlangTypes.h" #include "ik_irrKlangTypes.h"
namespace irrklang namespace irrklang
{ {
//! Reference counting base class for objects in the Irrlicht Engine similar to IRefCounted. //! Reference counting base class for objects in the Irrlicht Engine similar to IRefCounted.
/** See IRefCounted for the basics of this class. /** See IRefCounted for the basics of this class.
The difference to IRefCounted is that the class has to implement reference counting The difference to IRefCounted is that the class has to implement reference counting
for itself. for itself.
*/ */
class IVirtualRefCounted class IVirtualRefCounted
{ {
public: public:
//! Destructor. //! Destructor.
virtual ~IVirtualRefCounted() virtual ~IVirtualRefCounted()
{ {
} }
//! Grabs the object. Increments the reference counter by one. //! Grabs the object. Increments the reference counter by one.
/** To be implemented by the derived class. If you don't want to /** To be implemented by the derived class. If you don't want to
implement this, use the class IRefCounted instead. See IRefCounted::grab() for details implement this, use the class IRefCounted instead. See IRefCounted::grab() for details
of this method. */ of this method. */
virtual void grab() = 0; virtual void grab() = 0;
//! Drops the object. Decrements the reference counter by one. //! Drops the object. Decrements the reference counter by one.
/** To be implemented by the derived class. If you don't want to /** To be implemented by the derived class. If you don't want to
implement this, use the class IRefCounted instead. See IRefCounted::grab() for details implement this, use the class IRefCounted instead. See IRefCounted::grab() for details
of this method. */ of this method. */
virtual bool drop() = 0; virtual bool drop() = 0;
}; };
} // end namespace irrklang } // end namespace irrklang
#endif #endif

View File

@ -1,71 +1,71 @@
// Copyright (C) 2002-2008 Nikolaus Gebhardt // Copyright (C) 2002-2009 Nikolaus Gebhardt
// This file is part of the "irrKlang" library. // This file is part of the "irrKlang" library.
// For conditions of distribution and use, see copyright notice in irrKlang.h // For conditions of distribution and use, see copyright notice in irrKlang.h
#ifndef __S_IRRKLANG_AUDIO_STREAM_FORMAT_H_INCLUDED__ #ifndef __S_IRRKLANG_AUDIO_STREAM_FORMAT_H_INCLUDED__
#define __S_IRRKLANG_AUDIO_STREAM_FORMAT_H_INCLUDED__ #define __S_IRRKLANG_AUDIO_STREAM_FORMAT_H_INCLUDED__
#include "ik_IRefCounted.h" #include "ik_IRefCounted.h"
namespace irrklang namespace irrklang
{ {
//! audio sample data format enumeration for supported formats //! audio sample data format enumeration for supported formats
enum ESampleFormat enum ESampleFormat
{ {
//! one unsigned byte (0;255) //! one unsigned byte (0;255)
ESF_U8, ESF_U8,
//! 16 bit, signed (-32k;32k) //! 16 bit, signed (-32k;32k)
ESF_S16 ESF_S16
}; };
//! structure describing an audio stream format with helper functions //! structure describing an audio stream format with helper functions
struct SAudioStreamFormat struct SAudioStreamFormat
{ {
//! channels, 1 for mono, 2 for stereo //! channels, 1 for mono, 2 for stereo
ik_s32 ChannelCount; ik_s32 ChannelCount;
//! amount of frames in the sample data or stream. //! amount of frames in the sample data or stream.
/** If the stream has an unknown lenght, this is -1 */ /** If the stream has an unknown lenght, this is -1 */
ik_s32 FrameCount; ik_s32 FrameCount;
//! samples per second //! samples per second
ik_s32 SampleRate; ik_s32 SampleRate;
//! format of the sample data //! format of the sample data
ESampleFormat SampleFormat; ESampleFormat SampleFormat;
//! returns the size of a sample of the data described by the stream data in bytes //! returns the size of a sample of the data described by the stream data in bytes
inline ik_s32 getSampleSize() const inline ik_s32 getSampleSize() const
{ {
return (SampleFormat == ESF_U8) ? 1 : 2; return (SampleFormat == ESF_U8) ? 1 : 2;
} }
//! returns the frame size of the stream data in bytes //! returns the frame size of the stream data in bytes
inline ik_s32 getFrameSize() const inline ik_s32 getFrameSize() const
{ {
return ChannelCount * getSampleSize(); return ChannelCount * getSampleSize();
} }
//! returns the size of the sample data in bytes //! returns the size of the sample data in bytes
/* Returns an invalid negative value when the stream has an unknown lenght */ /* Returns an invalid negative value when the stream has an unknown lenght */
inline ik_s32 getSampleDataSize() const inline ik_s32 getSampleDataSize() const
{ {
return getFrameSize() * FrameCount; return getFrameSize() * FrameCount;
} }
//! returns amount of bytes per second //! returns amount of bytes per second
inline ik_s32 getBytesPerSecond() const inline ik_s32 getBytesPerSecond() const
{ {
return getFrameSize() * SampleRate; return getFrameSize() * SampleRate;
} }
}; };
} // end namespace irrklang } // end namespace irrklang
#endif #endif

View File

@ -1,78 +1,78 @@
// Copyright (C) 2002-2008 Nikolaus Gebhardt // Copyright (C) 2002-2009 Nikolaus Gebhardt
// This file is part of the "irrKlang" library. // This file is part of the "irrKlang" library.
// For conditions of distribution and use, see copyright notice in irrKlang.h // For conditions of distribution and use, see copyright notice in irrKlang.h
#ifndef __IRRKLANG_TYPES_H_INCLUDED__ #ifndef __IRRKLANG_TYPES_H_INCLUDED__
#define __IRRKLANG_TYPES_H_INCLUDED__ #define __IRRKLANG_TYPES_H_INCLUDED__
namespace irrklang namespace irrklang
{ {
//! 8 bit unsigned variable. //! 8 bit unsigned variable.
/** This is a typedef for unsigned char, it ensures portability of the engine. */ /** This is a typedef for unsigned char, it ensures portability of the engine. */
typedef unsigned char ik_u8; typedef unsigned char ik_u8;
//! 8 bit signed variable. //! 8 bit signed variable.
/** This is a typedef for signed char, it ensures portability of the engine. */ /** This is a typedef for signed char, it ensures portability of the engine. */
typedef signed char ik_s8; typedef signed char ik_s8;
//! 8 bit character variable. //! 8 bit character variable.
/** This is a typedef for char, it ensures portability of the engine. */ /** This is a typedef for char, it ensures portability of the engine. */
typedef char ik_c8; typedef char ik_c8;
//! 16 bit unsigned variable. //! 16 bit unsigned variable.
/** This is a typedef for unsigned short, it ensures portability of the engine. */ /** This is a typedef for unsigned short, it ensures portability of the engine. */
typedef unsigned short ik_u16; typedef unsigned short ik_u16;
//! 16 bit signed variable. //! 16 bit signed variable.
/** This is a typedef for signed short, it ensures portability of the engine. */ /** This is a typedef for signed short, it ensures portability of the engine. */
typedef signed short ik_s16; typedef signed short ik_s16;
//! 32 bit unsigned variable. //! 32 bit unsigned variable.
/** This is a typedef for unsigned int, it ensures portability of the engine. */ /** This is a typedef for unsigned int, it ensures portability of the engine. */
typedef unsigned int ik_u32; typedef unsigned int ik_u32;
//! 32 bit signed variable. //! 32 bit signed variable.
/** This is a typedef for signed int, it ensures portability of the engine. */ /** This is a typedef for signed int, it ensures portability of the engine. */
typedef signed int ik_s32; typedef signed int ik_s32;
//! 32 bit floating point variable. //! 32 bit floating point variable.
/** This is a typedef for float, it ensures portability of the engine. */ /** This is a typedef for float, it ensures portability of the engine. */
typedef float ik_f32; typedef float ik_f32;
//! 64 bit floating point variable. //! 64 bit floating point variable.
/** This is a typedef for double, it ensures portability of the engine. */ /** This is a typedef for double, it ensures portability of the engine. */
typedef double ik_f64; typedef double ik_f64;
// some constants // some constants
const ik_f32 IK_ROUNDING_ERROR_32 = 0.000001f; const ik_f32 IK_ROUNDING_ERROR_32 = 0.000001f;
const ik_f64 IK_PI64 = 3.1415926535897932384626433832795028841971693993751; const ik_f64 IK_PI64 = 3.1415926535897932384626433832795028841971693993751;
const ik_f32 IK_PI32 = 3.14159265359f; const ik_f32 IK_PI32 = 3.14159265359f;
const ik_f32 IK_RADTODEG = 180.0f / IK_PI32; const ik_f32 IK_RADTODEG = 180.0f / IK_PI32;
const ik_f32 IK_DEGTORAD = IK_PI32 / 180.0f; const ik_f32 IK_DEGTORAD = IK_PI32 / 180.0f;
const ik_f64 IK_RADTODEG64 = 180.0 / IK_PI64; const ik_f64 IK_RADTODEG64 = 180.0 / IK_PI64;
const ik_f64 IK_DEGTORAD64 = IK_PI64 / 180.0; const ik_f64 IK_DEGTORAD64 = IK_PI64 / 180.0;
//! returns if a float equals the other one, taking floating //! returns if a float equals the other one, taking floating
//! point rounding errors into account //! point rounding errors into account
inline bool equalsfloat(const ik_f32 a, const ik_f32 b, const ik_f32 tolerance = IK_ROUNDING_ERROR_32) inline bool equalsfloat(const ik_f32 a, const ik_f32 b, const ik_f32 tolerance = IK_ROUNDING_ERROR_32)
{ {
return (a + tolerance > b) && (a - tolerance < b); return (a + tolerance > b) && (a - tolerance < b);
} }
} // end namespace } // end namespace
#endif // __IRR_TYPES_H_INCLUDED__ #endif // __IRR_TYPES_H_INCLUDED__

View File

@ -1,261 +1,261 @@
// Copyright (C) 2002-2008 Nikolaus Gebhardt // Copyright (C) 2002-2009 Nikolaus Gebhardt
// This file is part of the "irrKlang" library. // This file is part of the "irrKlang" library.
// For conditions of distribution and use, see copyright notice in irrKlang.h // For conditions of distribution and use, see copyright notice in irrKlang.h
#ifndef __IRR_IRRKLANG_VEC_3D_H_INCLUDED__ #ifndef __IRR_IRRKLANG_VEC_3D_H_INCLUDED__
#define __IRR_IRRKLANG_VEC_3D_H_INCLUDED__ #define __IRR_IRRKLANG_VEC_3D_H_INCLUDED__
#include <math.h> #include <math.h>
#include "ik_irrKlangTypes.h" #include "ik_irrKlangTypes.h"
namespace irrklang namespace irrklang
{ {
//! a 3d vector template class for representing vectors and points in 3d //! a 3d vector template class for representing vectors and points in 3d
template <class T> template <class T>
class vec3d class vec3d
{ {
public: public:
vec3d(): X(0), Y(0), Z(0) {}; vec3d(): X(0), Y(0), Z(0) {};
vec3d(T nx, T ny, T nz) : X(nx), Y(ny), Z(nz) {}; vec3d(T nx, T ny, T nz) : X(nx), Y(ny), Z(nz) {};
vec3d(const vec3d<T>& other) :X(other.X), Y(other.Y), Z(other.Z) {}; vec3d(const vec3d<T>& other) :X(other.X), Y(other.Y), Z(other.Z) {};
//! constructor creating an irrklang vec3d from an irrlicht vector. //! constructor creating an irrklang vec3d from an irrlicht vector.
#ifdef __IRR_POINT_3D_H_INCLUDED__ #ifdef __IRR_POINT_3D_H_INCLUDED__
template<class B> template<class B>
vec3d(const B& other) :X(other.X), Y(other.Y), Z(other.Z) {}; vec3d(const B& other) :X(other.X), Y(other.Y), Z(other.Z) {};
#endif // __IRR_POINT_3D_H_INCLUDED__ #endif // __IRR_POINT_3D_H_INCLUDED__
// operators // operators
vec3d<T> operator-() const { return vec3d<T>(-X, -Y, -Z); } vec3d<T> operator-() const { return vec3d<T>(-X, -Y, -Z); }
vec3d<T>& operator=(const vec3d<T>& other) { X = other.X; Y = other.Y; Z = other.Z; return *this; } vec3d<T>& operator=(const vec3d<T>& other) { X = other.X; Y = other.Y; Z = other.Z; return *this; }
vec3d<T> operator+(const vec3d<T>& other) const { return vec3d<T>(X + other.X, Y + other.Y, Z + other.Z); } vec3d<T> operator+(const vec3d<T>& other) const { return vec3d<T>(X + other.X, Y + other.Y, Z + other.Z); }
vec3d<T>& operator+=(const vec3d<T>& other) { X+=other.X; Y+=other.Y; Z+=other.Z; return *this; } vec3d<T>& operator+=(const vec3d<T>& other) { X+=other.X; Y+=other.Y; Z+=other.Z; return *this; }
vec3d<T> operator-(const vec3d<T>& other) const { return vec3d<T>(X - other.X, Y - other.Y, Z - other.Z); } vec3d<T> operator-(const vec3d<T>& other) const { return vec3d<T>(X - other.X, Y - other.Y, Z - other.Z); }
vec3d<T>& operator-=(const vec3d<T>& other) { X-=other.X; Y-=other.Y; Z-=other.Z; return *this; } vec3d<T>& operator-=(const vec3d<T>& other) { X-=other.X; Y-=other.Y; Z-=other.Z; return *this; }
vec3d<T> operator*(const vec3d<T>& other) const { return vec3d<T>(X * other.X, Y * other.Y, Z * other.Z); } vec3d<T> operator*(const vec3d<T>& other) const { return vec3d<T>(X * other.X, Y * other.Y, Z * other.Z); }
vec3d<T>& operator*=(const vec3d<T>& other) { X*=other.X; Y*=other.Y; Z*=other.Z; return *this; } vec3d<T>& operator*=(const vec3d<T>& other) { X*=other.X; Y*=other.Y; Z*=other.Z; return *this; }
vec3d<T> operator*(const T v) const { return vec3d<T>(X * v, Y * v, Z * v); } vec3d<T> operator*(const T v) const { return vec3d<T>(X * v, Y * v, Z * v); }
vec3d<T>& operator*=(const T v) { X*=v; Y*=v; Z*=v; return *this; } vec3d<T>& operator*=(const T v) { X*=v; Y*=v; Z*=v; return *this; }
vec3d<T> operator/(const vec3d<T>& other) const { return vec3d<T>(X / other.X, Y / other.Y, Z / other.Z); } vec3d<T> operator/(const vec3d<T>& other) const { return vec3d<T>(X / other.X, Y / other.Y, Z / other.Z); }
vec3d<T>& operator/=(const vec3d<T>& other) { X/=other.X; Y/=other.Y; Z/=other.Z; return *this; } vec3d<T>& operator/=(const vec3d<T>& other) { X/=other.X; Y/=other.Y; Z/=other.Z; return *this; }
vec3d<T> operator/(const T v) const { T i=(T)1.0/v; return vec3d<T>(X * i, Y * i, Z * i); } vec3d<T> operator/(const T v) const { T i=(T)1.0/v; return vec3d<T>(X * i, Y * i, Z * i); }
vec3d<T>& operator/=(const T v) { T i=(T)1.0/v; X*=i; Y*=i; Z*=i; return *this; } vec3d<T>& operator/=(const T v) { T i=(T)1.0/v; X*=i; Y*=i; Z*=i; return *this; }
bool operator<=(const vec3d<T>&other) const { return X<=other.X && Y<=other.Y && Z<=other.Z;}; bool operator<=(const vec3d<T>&other) const { return X<=other.X && Y<=other.Y && Z<=other.Z;};
bool operator>=(const vec3d<T>&other) const { return X>=other.X && Y>=other.Y && Z>=other.Z;}; bool operator>=(const vec3d<T>&other) const { return X>=other.X && Y>=other.Y && Z>=other.Z;};
bool operator==(const vec3d<T>& other) const { return other.X==X && other.Y==Y && other.Z==Z; } bool operator==(const vec3d<T>& other) const { return other.X==X && other.Y==Y && other.Z==Z; }
bool operator!=(const vec3d<T>& other) const { return other.X!=X || other.Y!=Y || other.Z!=Z; } bool operator!=(const vec3d<T>& other) const { return other.X!=X || other.Y!=Y || other.Z!=Z; }
// functions // functions
//! returns if this vector equalsfloat the other one, taking floating point rounding errors into account //! returns if this vector equalsfloat the other one, taking floating point rounding errors into account
bool equals(const vec3d<T>& other) bool equals(const vec3d<T>& other)
{ {
return equalsfloat(X, other.X) && return equalsfloat(X, other.X) &&
equalsfloat(Y, other.Y) && equalsfloat(Y, other.Y) &&
equalsfloat(Z, other.Z); equalsfloat(Z, other.Z);
} }
void set(const T nx, const T ny, const T nz) {X=nx; Y=ny; Z=nz; } void set(const T nx, const T ny, const T nz) {X=nx; Y=ny; Z=nz; }
void set(const vec3d<T>& p) { X=p.X; Y=p.Y; Z=p.Z;} void set(const vec3d<T>& p) { X=p.X; Y=p.Y; Z=p.Z;}
//! Returns length of the vector. //! Returns length of the vector.
ik_f64 getLength() const { return sqrt(X*X + Y*Y + Z*Z); } ik_f64 getLength() const { return sqrt(X*X + Y*Y + Z*Z); }
//! Returns squared length of the vector. //! Returns squared length of the vector.
/** This is useful because it is much faster then /** This is useful because it is much faster then
getLength(). */ getLength(). */
ik_f64 getLengthSQ() const { return X*X + Y*Y + Z*Z; } ik_f64 getLengthSQ() const { return X*X + Y*Y + Z*Z; }
//! Returns the dot product with another vector. //! Returns the dot product with another vector.
T dotProduct(const vec3d<T>& other) const T dotProduct(const vec3d<T>& other) const
{ {
return X*other.X + Y*other.Y + Z*other.Z; return X*other.X + Y*other.Y + Z*other.Z;
} }
//! Returns distance from an other point. //! Returns distance from an other point.
/** Here, the vector is interpreted as point in 3 dimensional space. */ /** Here, the vector is interpreted as point in 3 dimensional space. */
ik_f64 getDistanceFrom(const vec3d<T>& other) const ik_f64 getDistanceFrom(const vec3d<T>& other) const
{ {
ik_f64 vx = X - other.X; ik_f64 vy = Y - other.Y; ik_f64 vz = Z - other.Z; ik_f64 vx = X - other.X; ik_f64 vy = Y - other.Y; ik_f64 vz = Z - other.Z;
return sqrt(vx*vx + vy*vy + vz*vz); return sqrt(vx*vx + vy*vy + vz*vz);
} }
//! Returns squared distance from an other point. //! Returns squared distance from an other point.
/** Here, the vector is interpreted as point in 3 dimensional space. */ /** Here, the vector is interpreted as point in 3 dimensional space. */
ik_f32 getDistanceFromSQ(const vec3d<T>& other) const ik_f32 getDistanceFromSQ(const vec3d<T>& other) const
{ {
ik_f32 vx = X - other.X; ik_f32 vy = Y - other.Y; ik_f32 vz = Z - other.Z; ik_f32 vx = X - other.X; ik_f32 vy = Y - other.Y; ik_f32 vz = Z - other.Z;
return (vx*vx + vy*vy + vz*vz); return (vx*vx + vy*vy + vz*vz);
} }
//! Calculates the cross product with another vector //! Calculates the cross product with another vector
vec3d<T> crossProduct(const vec3d<T>& p) const vec3d<T> crossProduct(const vec3d<T>& p) const
{ {
return vec3d<T>(Y * p.Z - Z * p.Y, Z * p.X - X * p.Z, X * p.Y - Y * p.X); return vec3d<T>(Y * p.Z - Z * p.Y, Z * p.X - X * p.Z, X * p.Y - Y * p.X);
} }
//! Returns if this vector interpreted as a point is on a line between two other points. //! Returns if this vector interpreted as a point is on a line between two other points.
/** It is assumed that the point is on the line. */ /** It is assumed that the point is on the line. */
bool isBetweenPoints(const vec3d<T>& begin, const vec3d<T>& end) const bool isBetweenPoints(const vec3d<T>& begin, const vec3d<T>& end) const
{ {
ik_f32 f = (ik_f32)(end - begin).getLengthSQ(); ik_f32 f = (ik_f32)(end - begin).getLengthSQ();
return (ik_f32)getDistanceFromSQ(begin) < f && return (ik_f32)getDistanceFromSQ(begin) < f &&
(ik_f32)getDistanceFromSQ(end) < f; (ik_f32)getDistanceFromSQ(end) < f;
} }
//! Normalizes the vector. //! Normalizes the vector.
vec3d<T>& normalize() vec3d<T>& normalize()
{ {
T l = (T)getLength(); T l = (T)getLength();
if (l == 0) if (l == 0)
return *this; return *this;
l = (T)1.0 / l; l = (T)1.0 / l;
X *= l; X *= l;
Y *= l; Y *= l;
Z *= l; Z *= l;
return *this; return *this;
} }
//! Sets the lenght of the vector to a new value //! Sets the lenght of the vector to a new value
void setLength(T newlength) void setLength(T newlength)
{ {
normalize(); normalize();
*this *= newlength; *this *= newlength;
} }
//! Inverts the vector. //! Inverts the vector.
void invert() void invert()
{ {
X *= -1.0f; X *= -1.0f;
Y *= -1.0f; Y *= -1.0f;
Z *= -1.0f; Z *= -1.0f;
} }
//! Rotates the vector by a specified number of degrees around the Y //! Rotates the vector by a specified number of degrees around the Y
//! axis and the specified center. //! axis and the specified center.
//! \param degrees: Number of degrees to rotate around the Y axis. //! \param degrees: Number of degrees to rotate around the Y axis.
//! \param center: The center of the rotation. //! \param center: The center of the rotation.
void rotateXZBy(ik_f64 degrees, const vec3d<T>& center) void rotateXZBy(ik_f64 degrees, const vec3d<T>& center)
{ {
degrees *= IK_DEGTORAD64; degrees *= IK_DEGTORAD64;
T cs = (T)cos(degrees); T cs = (T)cos(degrees);
T sn = (T)sin(degrees); T sn = (T)sin(degrees);
X -= center.X; X -= center.X;
Z -= center.Z; Z -= center.Z;
set(X*cs - Z*sn, Y, X*sn + Z*cs); set(X*cs - Z*sn, Y, X*sn + Z*cs);
X += center.X; X += center.X;
Z += center.Z; Z += center.Z;
} }
//! Rotates the vector by a specified number of degrees around the Z //! Rotates the vector by a specified number of degrees around the Z
//! axis and the specified center. //! axis and the specified center.
//! \param degrees: Number of degrees to rotate around the Z axis. //! \param degrees: Number of degrees to rotate around the Z axis.
//! \param center: The center of the rotation. //! \param center: The center of the rotation.
void rotateXYBy(ik_f64 degrees, const vec3d<T>& center) void rotateXYBy(ik_f64 degrees, const vec3d<T>& center)
{ {
degrees *= IK_DEGTORAD64; degrees *= IK_DEGTORAD64;
T cs = (T)cos(degrees); T cs = (T)cos(degrees);
T sn = (T)sin(degrees); T sn = (T)sin(degrees);
X -= center.X; X -= center.X;
Y -= center.Y; Y -= center.Y;
set(X*cs - Y*sn, X*sn + Y*cs, Z); set(X*cs - Y*sn, X*sn + Y*cs, Z);
X += center.X; X += center.X;
Y += center.Y; Y += center.Y;
} }
//! Rotates the vector by a specified number of degrees around the X //! Rotates the vector by a specified number of degrees around the X
//! axis and the specified center. //! axis and the specified center.
//! \param degrees: Number of degrees to rotate around the X axis. //! \param degrees: Number of degrees to rotate around the X axis.
//! \param center: The center of the rotation. //! \param center: The center of the rotation.
void rotateYZBy(ik_f64 degrees, const vec3d<T>& center) void rotateYZBy(ik_f64 degrees, const vec3d<T>& center)
{ {
degrees *= IK_DEGTORAD64; degrees *= IK_DEGTORAD64;
T cs = (T)cos(degrees); T cs = (T)cos(degrees);
T sn = (T)sin(degrees); T sn = (T)sin(degrees);
Z -= center.Z; Z -= center.Z;
Y -= center.Y; Y -= center.Y;
set(X, Y*cs - Z*sn, Y*sn + Z*cs); set(X, Y*cs - Z*sn, Y*sn + Z*cs);
Z += center.Z; Z += center.Z;
Y += center.Y; Y += center.Y;
} }
//! Returns interpolated vector. //! Returns interpolated vector.
/** \param other: other vector to interpolate between /** \param other: other vector to interpolate between
\param d: value between 0.0f and 1.0f. */ \param d: value between 0.0f and 1.0f. */
vec3d<T> getInterpolated(const vec3d<T>& other, ik_f32 d) const vec3d<T> getInterpolated(const vec3d<T>& other, ik_f32 d) const
{ {
ik_f32 inv = 1.0f - d; ik_f32 inv = 1.0f - d;
return vec3d<T>(other.X*inv + X*d, return vec3d<T>(other.X*inv + X*d,
other.Y*inv + Y*d, other.Y*inv + Y*d,
other.Z*inv + Z*d); other.Z*inv + Z*d);
} }
//! Gets the Y and Z rotations of a vector. //! Gets the Y and Z rotations of a vector.
/** Thanks to Arras on the Irrlicht forums to add this method. /** Thanks to Arras on the Irrlicht forums to add this method.
\return A vector representing the rotation in degrees of \return A vector representing the rotation in degrees of
this vector. The Z component of the vector will always be 0. */ this vector. The Z component of the vector will always be 0. */
vec3d<T> getHorizontalAngle() vec3d<T> getHorizontalAngle()
{ {
vec3d<T> angle; vec3d<T> angle;
angle.Y = (T)atan2(X, Z); angle.Y = (T)atan2(X, Z);
angle.Y *= (ik_f32)IK_RADTODEG; angle.Y *= (ik_f32)IK_RADTODEG;
if (angle.Y < 0.0f) angle.Y += 360.0f; if (angle.Y < 0.0f) angle.Y += 360.0f;
if (angle.Y >= 360.0f) angle.Y -= 360.0f; if (angle.Y >= 360.0f) angle.Y -= 360.0f;
ik_f32 z1 = (T)sqrt(X*X + Z*Z); ik_f32 z1 = (T)sqrt(X*X + Z*Z);
angle.X = (T)atan2(z1, Y); angle.X = (T)atan2(z1, Y);
angle.X *= (ik_f32)IK_RADTODEG; angle.X *= (ik_f32)IK_RADTODEG;
angle.X -= 90.0f; angle.X -= 90.0f;
if (angle.X < 0.0f) angle.X += 360.0f; if (angle.X < 0.0f) angle.X += 360.0f;
if (angle.X >= 360) angle.X -= 360.0f; if (angle.X >= 360) angle.X -= 360.0f;
return angle; return angle;
} }
//! Fills an array of 4 values with the vector data (usually floats). //! Fills an array of 4 values with the vector data (usually floats).
/** Useful for setting in shader constants for example. The fourth value /** Useful for setting in shader constants for example. The fourth value
will always be 0. */ will always be 0. */
void getAs4Values(T* array) void getAs4Values(T* array)
{ {
array[0] = X; array[0] = X;
array[1] = Y; array[1] = Y;
array[2] = Z; array[2] = Z;
array[3] = 0; array[3] = 0;
} }
// member variables // member variables
T X, Y, Z; T X, Y, Z;
}; };
//! Typedef for a ik_f32 3d vector, a vector using floats for X, Y and Z //! Typedef for a ik_f32 3d vector, a vector using floats for X, Y and Z
typedef vec3d<ik_f32> vec3df; typedef vec3d<ik_f32> vec3df;
//! Typedef for an integer 3d vector, a vector using ints for X, Y and Z //! Typedef for an integer 3d vector, a vector using ints for X, Y and Z
typedef vec3d<ik_s32> vec3di; typedef vec3d<ik_s32> vec3di;
template<class S, class T> vec3d<T> operator*(const S scalar, const vec3d<T>& vector) { return vector*scalar; } template<class S, class T> vec3d<T> operator*(const S scalar, const vec3d<T>& vector) { return vector*scalar; }
} // end namespace irrklang } // end namespace irrklang
#endif #endif

File diff suppressed because it is too large Load Diff