25#ifndef _CSKYLICHT_AUDIO_H_
26#define _CSKYLICHT_AUDIO_H_
30#include "SkylichtAudioConfig.h"
31#include "Stream/IStreamFactory.h"
33#include "Decoder/IAudioDecoder.h"
34#include "Driver/ISoundDriver.h"
35#include "Thread/IMutex.h"
36#include "Thread/IThread.h"
38#include "CAudioEmitter.h"
39#include "CAudioReader.h"
83 class CAudioEngine :
public IThreadCallback
94 std::vector<IStreamFactory*> m_streamFactorys;
96 std::vector<CAudioEmitter*> m_emitters;
98 std::vector<CAudioReader*> m_readers;
100 std::map<std::string, IStream*> m_fileToStream;
120 virtual ~CAudioEngine();
170 m_driver->lockThread();
181 m_driver->unlockThread();
312 void setListener(
float posx,
float posy,
float posz,
float upx,
float upy,
float upz,
float frontx,
float fronty,
float frontz);
Audio emitter for playing and managing sound sources.
Definition CAudioEmitter.h:70
virtual void updateThread()
Background thread update loop.
CAudioReader * createAudioReader(const char *fileName)
Create an audio reader from a file.
void registerStreamFactory(IStreamFactory *streamFactory)
Register a custom stream factory.
void destroyReader(CAudioReader *reader)
Destroy an audio reader.
void lockThread()
Lock audio thread for safe state modification.
Definition CAudioEngine.h:165
IStream * createStreamFromMemory(unsigned char *buffer, int size, bool takeOwnerShip=false)
Create an audio stream from a memory buffer.
virtual void updateEmitter()
Update all active emitters. Called by updateThread or updateSkylichtAudio.
void unRegisterStreamFactory(IStreamFactory *streamFactory)
Unregister a stream factory.
IStream * createStreamFromFileAndCache(const char *fileName, bool cache)
Create an audio stream from a file with optional caching.
void setListener(float posx, float posy, float posz, float upx, float upy, float upz, float frontx, float fronty, float frontz)
Set the listener parameters for 3D sound.
const SListener & getListener()
Get current listener parameters.
Definition CAudioEngine.h:318
CAudioEmitter * createAudioEmitter(IStream *stream, IAudioDecoder::EDecoderType decode)
Create an audio emitter from a stream.
void destroyAllEmitter()
Destroy all audio emitters.
IStream * createStreamFromFile(const char *fileName)
Create an audio stream from a file.
void updateDriver()
Manually update the audio driver.
void init()
Initialize the audio engine, driver, and background thread.
static void shutdownEngine()
Shutdown and release the audio engine instance.
void shutdown()
Shutdown the audio engine and release all resources.
void destroyAllReader()
Destroy all audio readers.
void pauseEngine()
Suspend the audio engine and driver.
void stopAllSound()
Stop all active sounds.
CAudioEmitter * createAudioEmitter(const char *fileName, bool cache)
Create an audio emitter from a file.
CAudioEmitter * createRawAudioEmitter(IStream *stream)
Create an audio emitter for raw PCM data.
CAudioReader * createAudioReader(IStream *stream, IAudioDecoder::EDecoderType decode)
Create an audio reader for decoding audio data without playback.
void destroyEmitter(CAudioEmitter *emitter)
Destroy an audio emitter.
void resumeEngine()
Resume the audio engine and driver.
ISoundDriver * getSoundDriver()
Get the active sound driver.
Definition CAudioEngine.h:188
bool isPause()
Check if the audio engine is paused.
Definition CAudioEngine.h:327
static CAudioEngine * getSoundEngine()
Get the singleton instance of the audio engine.
IStream * createOnlineStream()
Create an empty online stream for streaming data over the network.
void unLockThread()
Unlock audio thread.
Definition CAudioEngine.h:176
void releaseAllStream()
Release all cached streams.
Audio reader for decoding audio data to raw PCM wave data. This class is intended for reading audio s...
Definition CAudioReader.h:46
Definition ISoundDriver.h:36
Interface for stream factories. Register a custom factory to CAudioEngine to support different data s...
Definition IStreamFactory.h:59
Interface for an audio data stream (File, Memory, etc.).
Definition IStream.h:107
void updateSkylichtAudio()
Update the audio driver. Should be called every frame if multithreading is disabled.
void initSkylichtAudio()
Initialize the Skylicht Audio system.
void releaseSkylichtAudio()
Release the Skylicht Audio system.
Handles all core audio functionality.
Definition AudioDebugLog.h:31
The foundation for thread and process handling.
Definition CNullMutex.h:32
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition AudioDebugLog.h:29
Definition ISoundSource.h:86