Dreambox C/C++ SDK v1.0.0
C/C++ SDK for creating Dreambox games
Loading...
Searching...
No Matches
db_sounddriver.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdint.h>
4
5#include "db_math.h"
6#include "db_io.h"
7
8#ifdef __cplusplus
9extern "C"
10{
11#endif
12
13#define SOUND_ATTEN_NONE 0
14#define SOUND_ATTEN_INV_DISTANCE 1
15#define SOUND_ATTEN_LINEAR 2
16#define SOUND_ATTEN_EXP_DISTANCE 3
17
19typedef struct
20{
21 int32_t handle;
22 uint32_t samplerate;
24
25struct sound_emitter;
26struct sound_voice;
27
29typedef struct sound_emitter
30{
31 uint8_t isValid;
32 uint8_t priority;
33 uint8_t loop;
34 uint8_t reverb;
35 uint8_t is3D;
36 uint8_t attenType;
41 float volume;
42 float pitch;
43 float pan;
45 uint32_t id;
46 struct sound_voice *voice;
50
53
56
61
65sound_sample sound_loadWavBytes(const uint8_t *data);
66
74void sound_playOneShot(uint8_t priority, sound_sample sample, uint8_t reverb, float volume, float pitch, float pan);
75
87void 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);
88
98sound_emitter *sound_play(uint8_t priority, sound_sample sample, uint8_t reverb, uint8_t loop, float volume, float pitch, float pan);
99
113sound_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);
114
118
122
127
131void sound_setListener(Vec3 listenerPosition, Quaternion listenerOrientation);
132
133#ifdef __cplusplus
134}
135#endif
void IOFILE
Opaque handle to an open file descriptor.
Definition: db_io.h:40
sound_sample sound_loadWav(IOFILE *file)
Load a sample from a .WAV file.
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.
void sound_setPosition(sound_emitter *voice, Vec3 position)
Update the position of the emitter.
void sound_destroy(sound_emitter *voice)
Destroy the sound emitter.
void sound_playOneShot(uint8_t priority, sound_sample sample, uint8_t reverb, float volume, float pitch, float pan)
Play a one-shot sample.
sound_sample sound_loadWavBytes(const uint8_t *data)
Load a sample from a .WAV file blob.
void sound_stop(sound_emitter *voice)
Stop playing the sound emitter.
void sound_update()
Update sound playback.
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.
void sound_init()
Initialize the sound driver.
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.
void sound_setListener(Vec3 listenerPosition, Quaternion listenerOrientation)
Set the position and orientation of the listener.
A quaternion.
Definition: db_math.h:52
A three-component vector.
Definition: db_math.h:35
Struct containing the state of a sound emitter.
uint8_t priority
uint8_t attenType
sound_sample sample
struct sound_voice * voice
struct sound_emitter * next
struct sound_emitter * prev
Represents a loaded sound sample.
uint32_t samplerate
int32_t handle