Dreambox C/C++ SDK v1.0.0
C/C++ SDK for creating Dreambox games
Loading...
Searching...
No Matches
db_sounddriver.h File Reference
#include <stdint.h>
#include "db_math.h"
#include "db_io.h"

Go to the source code of this file.

Data Structures

struct  sound_sample
 Represents a loaded sound sample. More...
 
struct  sound_emitter
 Struct containing the state of a sound emitter. More...
 

Macros

#define SOUND_ATTEN_NONE   0
 
#define SOUND_ATTEN_INV_DISTANCE   1
 
#define SOUND_ATTEN_LINEAR   2
 
#define SOUND_ATTEN_EXP_DISTANCE   3
 

Typedefs

typedef struct sound_emitter sound_emitter
 Struct containing the state of a sound emitter. More...
 

Functions

void sound_init ()
 Initialize the sound driver. More...
 
void sound_update ()
 Update sound playback. More...
 
sound_sample sound_loadWav (IOFILE *file)
 Load a sample from a .WAV file. More...
 
sound_sample sound_loadWavBytes (const uint8_t *data)
 Load a sample from a .WAV file blob. More...
 
void sound_playOneShot (uint8_t priority, sound_sample sample, uint8_t reverb, float volume, float pitch, float pan)
 Play a one-shot sample. More...
 
void sound_playOneShot3D (uint8_t priority, sound_sample sample, uint8_t reverb, float volume, float pitch, Vec3 position, uint8_t attenModel, float attenMinDistance, float attenMaxDistance, float attenRolloff)
 Play a one-shot sample in 3D. More...
 
sound_emittersound_play (uint8_t priority, sound_sample sample, uint8_t reverb, uint8_t loop, float volume, float pitch, float pan)
 Begin playing a sound, returning a pointer to the emitter. More...
 
sound_emittersound_play3D (uint8_t priority, sound_sample sample, uint8_t reverb, uint8_t loop, float volume, float pitch, Vec3 position, uint8_t attenModel, float attenMinDistance, float attenMaxDistance, float attenRolloff)
 Begin playing a 3D sound, returning a pointer to the emitter. More...
 
void sound_destroy (sound_emitter *voice)
 Destroy the sound emitter. More...
 
void sound_stop (sound_emitter *voice)
 Stop playing the sound emitter. More...
 
void sound_setPosition (sound_emitter *voice, Vec3 position)
 Update the position of the emitter. More...
 
void sound_setListener (Vec3 listenerPosition, Quaternion listenerOrientation)
 Set the position and orientation of the listener. More...
 

Macro Definition Documentation

◆ SOUND_ATTEN_EXP_DISTANCE

#define SOUND_ATTEN_EXP_DISTANCE   3

Definition at line 16 of file db_sounddriver.h.

◆ SOUND_ATTEN_INV_DISTANCE

#define SOUND_ATTEN_INV_DISTANCE   1

Definition at line 14 of file db_sounddriver.h.

◆ SOUND_ATTEN_LINEAR

#define SOUND_ATTEN_LINEAR   2

Definition at line 15 of file db_sounddriver.h.

◆ SOUND_ATTEN_NONE

#define SOUND_ATTEN_NONE   0

Definition at line 13 of file db_sounddriver.h.

Typedef Documentation

◆ sound_emitter

typedef struct sound_emitter sound_emitter

Struct containing the state of a sound emitter.

Function Documentation

◆ sound_destroy()

void sound_destroy ( sound_emitter voice)

Destroy the sound emitter.

Parameters
voiceThe emitter handle

◆ sound_init()

void sound_init ( )

Initialize the sound driver.

◆ sound_loadWav()

sound_sample sound_loadWav ( IOFILE file)

Load a sample from a .WAV file.

Parameters
fileHandle to the open WAV file
Returns
The loaded sample handle

◆ sound_loadWavBytes()

sound_sample sound_loadWavBytes ( const uint8_t *  data)

Load a sample from a .WAV file blob.

Parameters
dataPointer to the wav file bytes
Returns
The loaded sample handle

◆ sound_play()

sound_emitter * sound_play ( uint8_t  priority,
sound_sample  sample,
uint8_t  reverb,
uint8_t  loop,
float  volume,
float  pitch,
float  pan 
)

Begin playing a sound, returning a pointer to the emitter.

Parameters
priorityThe priority of the sound (0 is highest, 255 is lowest)
sampleThe sample to play
reverbWhether to apply reverb to the sound
loopWhether to loop the sample
volumeThe initial volume
pitchThe initial pitch
panThe initial pan
Returns
A pointer to the virtual voice

◆ sound_play3D()

sound_emitter * sound_play3D ( uint8_t  priority,
sound_sample  sample,
uint8_t  reverb,
uint8_t  loop,
float  volume,
float  pitch,
Vec3  position,
uint8_t  attenModel,
float  attenMinDistance,
float  attenMaxDistance,
float  attenRolloff 
)

Begin playing a 3D sound, returning a pointer to the emitter.

Parameters
priorityThe priority of the sound (0 is highest, 255 is lowest)
sampleThe sample to play
reverbWhether to apply reverb to the sound
loopWhether to loop the sample
volumeThe initial volume
pitchThe initial pitch
positionThe initial position of the emitter
attenModelThe attenuation model of the emitter
attenMinDistanceThe min distance of the emitter
attenMaxDistanceThe max distance of the emitter
attenRolloffThe rolloff factor of the emitter
Returns
A pointer to the virtual voice

◆ sound_playOneShot()

void sound_playOneShot ( uint8_t  priority,
sound_sample  sample,
uint8_t  reverb,
float  volume,
float  pitch,
float  pan 
)

Play a one-shot sample.

Parameters
priorityThe priority of the sound (0 is highest, 255 is lowest)
sampleThe sample to play
reverbWhether to apply reverb to the sound
volumeThe volume of the sound
pitchThe pitch of the sound
panThe pan of the sound

◆ sound_playOneShot3D()

void sound_playOneShot3D ( uint8_t  priority,
sound_sample  sample,
uint8_t  reverb,
float  volume,
float  pitch,
Vec3  position,
uint8_t  attenModel,
float  attenMinDistance,
float  attenMaxDistance,
float  attenRolloff 
)

Play a one-shot sample in 3D.

Parameters
priorityThe priority of the sound (0 is highest, 255 is lowest)
sampleThe sample to play
reverbWhether to apply reverb to the sound
volumeThe volume of the sound
pitchThe pitch of the sound
positionThe position of the sound
attenModelThe attenuation model of the sound
attenMinDistanceThe min distance of the sound
attenMaxDistanceThe max distance of the sound
attenRolloffThe rolloff factor of the sound

◆ sound_setListener()

void sound_setListener ( Vec3  listenerPosition,
Quaternion  listenerOrientation 
)

Set the position and orientation of the listener.

Parameters
listenerPositionThe position of the listener
listenerOrientationThe orientation of the listener

◆ sound_setPosition()

void sound_setPosition ( sound_emitter voice,
Vec3  position 
)

Update the position of the emitter.

Parameters
voiceThe emitter to update
positionThe new position

◆ sound_stop()

void sound_stop ( sound_emitter voice)

Stop playing the sound emitter.

Parameters
voiceA pointer to the emitter

◆ sound_update()

void sound_update ( )

Update sound playback.