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

Go to the source code of this file.

Macros

#define AUDIO_VOICEPARAM_VOLUME   0
 
#define AUDIO_VOICEPARAM_PITCH   1
 
#define AUDIO_VOICEPARAM_DETUNE   2
 
#define AUDIO_VOICEPARAM_PAN   3
 
#define AUDIO_VOICEPARAM_SAMPLEDATA   4
 
#define AUDIO_VOICEPARAM_SAMPLERATE   5
 
#define AUDIO_VOICEPARAM_LOOPENABLE   6
 
#define AUDIO_VOICEPARAM_LOOPSTART   7
 
#define AUDIO_VOICEPARAM_LOOPEND   8
 
#define AUDIO_VOICEPARAM_RVBENABLE   9
 
#define AUDIO_VOICEPARAM_FADEINLEN   10
 
#define AUDIO_VOICEPARAM_FADEOUTLEN   11
 
#define AUDIO_FMT_PCM_S8   0
 
#define AUDIO_FMT_PCM_S16   1
 

Functions

int32_t audio_alloc (const void *dataPtr, uint32_t dataLen, uint32_t audioFmt)
 Upload sample data to the audio system. More...
 
int32_t audio_allocCompressed (const void *dataPtr, uint32_t dataLen, uint32_t blockSize)
 Upload IMA ADPCM compressed sample data to the audio system. More...
 
void audio_free (int32_t handle)
 Free previously allocated sample data. More...
 
uint32_t audio_getUsage ()
 Get total audio memory usage. More...
 
uint8_t audio_getVoiceState (uint32_t slot)
 Get the state of the voice in the given slot. More...
 
void audio_queueSetParam_i (uint32_t slot, uint32_t param, int32_t value, double time)
 Schedule parameter change for voice in the given slot. More...
 
void audio_queueSetParam_f (uint32_t slot, uint32_t param, float value, double time)
 Schedule parameter change for voice in the given slot. More...
 
void audio_queueStartVoice (uint32_t slot, double time)
 Schedule voice in the given slot to start playing. More...
 
void audio_queueStopVoice (uint32_t slot, double time)
 Schedule voice in the given slot to stop playing. More...
 
double audio_getTime ()
 Get the current audio time. More...
 
void audio_setReverbParams (float roomSize, float damp, float width, float wet, float dry)
 Set the global reverb unit parameters for voices with reverb enabled. More...
 
uint8_t audio_initSynth (void *sf2Data, uint32_t sf2DataLen)
 Initialize the MIDI synthesis engine with a soundfont. More...
 
uint8_t audio_playMidi (void *smfData, uint32_t smfDataLen, uint8_t loop)
 Begin playing the given MIDI data via the synthesis engine. More...
 
void audio_setMidiVolume (float volume)
 Set volume of MIDI playback. More...
 
void audio_setMidiReverb (uint8_t enabled)
 Set whether MIDI synthesis engine routes through globl reverb unit. More...
 

Macro Definition Documentation

◆ AUDIO_FMT_PCM_S16

#define AUDIO_FMT_PCM_S16   1

Definition at line 24 of file db_audio.h.

◆ AUDIO_FMT_PCM_S8

#define AUDIO_FMT_PCM_S8   0

Definition at line 23 of file db_audio.h.

◆ AUDIO_VOICEPARAM_DETUNE

#define AUDIO_VOICEPARAM_DETUNE   2

Definition at line 12 of file db_audio.h.

◆ AUDIO_VOICEPARAM_FADEINLEN

#define AUDIO_VOICEPARAM_FADEINLEN   10

Definition at line 20 of file db_audio.h.

◆ AUDIO_VOICEPARAM_FADEOUTLEN

#define AUDIO_VOICEPARAM_FADEOUTLEN   11

Definition at line 21 of file db_audio.h.

◆ AUDIO_VOICEPARAM_LOOPENABLE

#define AUDIO_VOICEPARAM_LOOPENABLE   6

Definition at line 16 of file db_audio.h.

◆ AUDIO_VOICEPARAM_LOOPEND

#define AUDIO_VOICEPARAM_LOOPEND   8

Definition at line 18 of file db_audio.h.

◆ AUDIO_VOICEPARAM_LOOPSTART

#define AUDIO_VOICEPARAM_LOOPSTART   7

Definition at line 17 of file db_audio.h.

◆ AUDIO_VOICEPARAM_PAN

#define AUDIO_VOICEPARAM_PAN   3

Definition at line 13 of file db_audio.h.

◆ AUDIO_VOICEPARAM_PITCH

#define AUDIO_VOICEPARAM_PITCH   1

Definition at line 11 of file db_audio.h.

◆ AUDIO_VOICEPARAM_RVBENABLE

#define AUDIO_VOICEPARAM_RVBENABLE   9

Definition at line 19 of file db_audio.h.

◆ AUDIO_VOICEPARAM_SAMPLEDATA

#define AUDIO_VOICEPARAM_SAMPLEDATA   4

Definition at line 14 of file db_audio.h.

◆ AUDIO_VOICEPARAM_SAMPLERATE

#define AUDIO_VOICEPARAM_SAMPLERATE   5

Definition at line 15 of file db_audio.h.

◆ AUDIO_VOICEPARAM_VOLUME

#define AUDIO_VOICEPARAM_VOLUME   0

Definition at line 10 of file db_audio.h.

Function Documentation

◆ audio_alloc()

int32_t audio_alloc ( const void *  dataPtr,
uint32_t  dataLen,
uint32_t  audioFmt 
)

Upload sample data to the audio system.

Parameters
dataPtrPointer to the audio data to upload
dataLenLength of the audio data buffer
audioFmtFormat of the data to upload (valid values are AUDIO_FMT_PCM_S8 or AUDIO_FMT_PCM_S16)
Returns
A handle to the allocated sample data, or -1 if allocation failed

◆ audio_allocCompressed()

int32_t audio_allocCompressed ( const void *  dataPtr,
uint32_t  dataLen,
uint32_t  blockSize 
)

Upload IMA ADPCM compressed sample data to the audio system.

Parameters
dataPtrPointer to the audio data to upload
dataLenLength of the audio data buffer
blockSizeLength of each block of data
Returns
A handle to the allocated sample data, or -1 if allocation failed

◆ audio_free()

void audio_free ( int32_t  handle)

Free previously allocated sample data.

Parameters
handleA handle previously returned from audio_alloc

◆ audio_getTime()

double audio_getTime ( )

Get the current audio time.

Returns
A time which can be used to schedule voice parameter changes

◆ audio_getUsage()

uint32_t audio_getUsage ( )

Get total audio memory usage.

Returns
Total audio memory usage in bytes

◆ audio_getVoiceState()

uint8_t audio_getVoiceState ( uint32_t  slot)

Get the state of the voice in the given slot.

Parameters
slotThe voice slot (0 to 31)
Returns
1 if the voice is currently playing, 0 otherwise

◆ audio_initSynth()

uint8_t audio_initSynth ( void *  sf2Data,
uint32_t  sf2DataLen 
)

Initialize the MIDI synthesis engine with a soundfont.

Parameters
sf2DataPointer to the SF2 data to load
sf2DataLenLength of the SF2 data blob
Returns
False if an error occurred, true otherwise

◆ audio_playMidi()

uint8_t audio_playMidi ( void *  smfData,
uint32_t  smfDataLen,
uint8_t  loop 
)

Begin playing the given MIDI data via the synthesis engine.

Parameters
smfDataPointer to the standard midi file data to load
smfDataLenLength of the standard midi file data blob
loopWhether to loop midi playback to either the beginning or a specified loop point (marked with CC#111)
Returns
False if an error occurred, true otherwise

◆ audio_queueSetParam_f()

void audio_queueSetParam_f ( uint32_t  slot,
uint32_t  param,
float  value,
double  time 
)

Schedule parameter change for voice in the given slot.

Parameters
slotThe voice slot (0 to 31)
paramThe parameter to change (one of the AUDIO_VOICEPARAM_* enumerations)
valueThe value to set the parameter to
timeThe time at which to change the parameter

◆ audio_queueSetParam_i()

void audio_queueSetParam_i ( uint32_t  slot,
uint32_t  param,
int32_t  value,
double  time 
)

Schedule parameter change for voice in the given slot.

Parameters
slotThe voice slot (0 to 31)
paramThe parameter to change (one of the AUDIO_VOICEPARAM_* enumerations)
valueThe value to set the parameter to
timeThe time at which to change the parameter

◆ audio_queueStartVoice()

void audio_queueStartVoice ( uint32_t  slot,
double  time 
)

Schedule voice in the given slot to start playing.

Parameters
slotThe voice slot (0 to 31)
timeThe time at which to start playing

◆ audio_queueStopVoice()

void audio_queueStopVoice ( uint32_t  slot,
double  time 
)

Schedule voice in the given slot to stop playing.

Parameters
slotThe voice slot (0 to 31)
timeThe time at which to stop playing

◆ audio_setMidiReverb()

void audio_setMidiReverb ( uint8_t  enabled)

Set whether MIDI synthesis engine routes through globl reverb unit.

Parameters
enabledtrue to enable reverb, false otherwise

◆ audio_setMidiVolume()

void audio_setMidiVolume ( float  volume)

Set volume of MIDI playback.

Parameters
volumeNew volume to set

◆ audio_setReverbParams()

void audio_setReverbParams ( float  roomSize,
float  damp,
float  width,
float  wet,
float  dry 
)

Set the global reverb unit parameters for voices with reverb enabled.

Parameters
roomSizeThe room size (values >1 may be unstable. default is 0.5)
dampDamping to apply (default is 0.5)
widthStereo width of the reverb (default is 1.0)
wetThe gain of the wet signal (default is 0.2)
dryThe gain of the dry signal (default is 0.8)