naev 0.12.6
sound.h
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
4#pragma once
5
7#include "SDL_mutex.h"
8#include "SDL_rwops.h"
9#include "nopenal.h"
10#include <vorbis/vorbisfile.h>
12
13/*
14 * Some OpenAL extension defines.
15 */
16#ifndef ALC_OUTPUT_LIMITER_SOFT
17#define ALC_OUTPUT_LIMITER_SOFT 0x199A
18#endif /* ALC_OUTPUT_LIMITER_SOFT */
19
20extern int sound_disabled;
21
22#define SOUND_REFERENCE_DISTANCE 500.
23#define SOUND_MAX_DISTANCE 25e3
24
25/*
26 * Static configuration.
27 */
28#define SOUND_PILOT_RELATIVE \
29 1
31
32/*
33 * Environmental features.
34 */
35typedef enum SoundEnv_e {
36 SOUND_ENV_NORMAL,
37 SOUND_ENV_NEBULA
38} SoundEnv_t;
39
40typedef struct alInfo_s {
41 ALCint freq;
42 ALCint nmono;
43 ALCint nstereo;
45 ALint efx;
46 ALint efx_major;
47 ALint efx_minor;
49 /* Effect types. */
50 ALint efx_reverb;
51 ALint efx_echo;
52} alInfo_t;
53extern alInfo_t al_info;
54
55extern ALuint sound_efx_directSlot;
56
57/*
58 * Vorbis stuff.
59 */
60extern ov_callbacks sound_al_ovcall;
61extern ov_callbacks sound_al_ovcall_noclose;
62
63/*
64 * sound subsystem
65 */
66int sound_init( void );
67void sound_exit( void );
68int sound_update( double dt );
69void sound_pause( void );
70void sound_resume( void );
71int sound_volume( const double vol );
72double sound_getVolume( void );
73double sound_getVolumeLog( void );
74void sound_stopAll( void );
75void sound_setSpeed( double s );
76
77/*
78 * source management
79 */
80int source_newRW( SDL_RWops *rw, const char *name, unsigned int flags );
81int source_new( const char *filename, unsigned int flags );
82
83/*
84 * sound sample management
85 */
86int sound_get( const char *name );
87double sound_getLength( int sound );
88
89/*
90 * voice management
91 */
92int sound_play( int sound );
93int sound_playPos( int sound, double px, double py, double vx, double vy );
94void sound_stop( int voice );
95int sound_updatePos( int voice, double px, double py, double vx, double vy );
96int sound_updateListener( double dir, double px, double py, double vx,
97 double vy );
98
99/*
100 * Group functions.
101 */
102int sound_reserve( int num );
103int sound_createGroup( int size );
104int sound_playGroup( int group, int sound, int once );
105void sound_stopGroup( int group );
106void sound_pauseGroup( int group );
107void sound_resumeGroup( int group );
108void sound_speedGroup( int group, int enable );
109void sound_volumeGroup( int group, double volume );
110void sound_pitchGroup( int group, double pitch );
111
112/*
113 * Environmental functions.
114 */
115void sound_setAbsorption( double value );
116int sound_env( SoundEnv_t env, double param );
117
118/*
119 * Vorbis filtering.
120 */
121#define RG_PREAMP_DB 0.0
122typedef struct rg_filter_param_s {
123 float rg_scale_factor;
124 float rg_max_scale;
126void rg_filter( float **pcm, long channels, long samples, void *filter_param );
127
128/* Lock for OpenAL operations. */
129int sound_al_buffer( ALuint *buf, SDL_RWops *rw, const char *name );
130extern SDL_mutex
131 *sound_lock;
132#define soundLock() SDL_mutexP( sound_lock )
133#define soundUnlock() SDL_mutexV( sound_lock )
int sound_createGroup(int size)
Creates a sound group.
Definition sound.c:1338
double sound_getVolumeLog(void)
Gets the current sound volume (logarithmic).
Definition sound.c:1304
int sound_al_buffer(ALuint *buf, SDL_RWops *rw, const char *name)
Loads the sound.
Definition sound.c:2083
double sound_getLength(int sound)
Gets the length of the sound buffer.
Definition sound.c:780
void sound_pitchGroup(int group, double pitch)
Sets the pitch of a group.
Definition sound.c:1614
void sound_resume(void)
Resumes all the sounds.
Definition sound.c:1032
void rg_filter(float **pcm, long channels, long samples, void *filter_param)
This is the filter function for the decoded Ogg Vorbis stream.
Definition sound.c:1965
void sound_resumeGroup(int group)
Resumes all the sounds in a group.
Definition sound.c:1528
double sound_getVolume(void)
Gets the current sound volume (linear).
Definition sound.c:1291
void sound_speedGroup(int group, int enable)
Sets whether or not the speed affects a group.
Definition sound.c:1560
int source_newRW(SDL_RWops *rw, const char *name, unsigned int flags)
Loads a new sound source from a RWops.
Definition sound.c:1795
int sound_disabled
Definition sound.c:130
int sound_updateListener(double dir, double px, double py, double vx, double vy)
Updates the sound listener.
Definition sound.c:1115
SDL_mutex * sound_lock
Definition sound.c:164
int sound_playPos(int sound, double px, double py, double vx, double vy)
Plays a sound based on position.
Definition sound.c:832
int sound_playGroup(int group, int sound, int once)
Plays a sound in a group.
Definition sound.c:1410
void sound_exit(void)
Cleans up after the sound subsytem.
Definition sound.c:670
void sound_stopGroup(int group)
Stops all the sounds in a group.
Definition sound.c:1486
int sound_update(double dt)
Updates the sounds removing obsolete ones and such.
Definition sound.c:914
void sound_stopAll(void)
Stops all the playing voices.
Definition sound.c:1049
int source_new(const char *filename, unsigned int flags)
Loads a new source from a file.
Definition sound.c:1819
ov_callbacks sound_al_ovcall_noclose
Definition sound.c:279
int sound_init(void)
Initializes the sound subsystem.
Definition sound.c:609
void sound_pause(void)
Pauses all the sounds.
Definition sound.c:1015
int sound_get(const char *name)
Gets the buffer to sound of name.
Definition sound.c:761
int sound_env(SoundEnv_t env_type, double param)
Sets up the sound environment.
Definition sound.c:1658
void sound_pauseGroup(int group)
Pauses all the sounds in a group.
Definition sound.c:1506
ALuint sound_efx_directSlot
Definition sound.c:192
alInfo_t al_info
Definition sound.c:176
void sound_stop(int voice)
Stops a voice from playing.
Definition sound.c:1080
ov_callbacks sound_al_ovcall
Definition sound.c:274
int sound_updatePos(int voice, double px, double py, double vx, double vy)
Updates the position of a voice.
Definition sound.c:890
int sound_play(int sound)
Plays the sound in the first available channel.
Definition sound.c:794
int sound_volume(const double vol)
Sets the volume.
Definition sound.c:1268
void sound_volumeGroup(int group, double volume)
Sets the volume of a group.
Definition sound.c:1584
void sound_setSpeed(double s)
Sets the speed to play the sound at.
Definition sound.c:1158
ALint efx
Definition sound.h:45
ALCint nmono
Definition sound.h:42
ALint efx_echo
Definition sound.h:51
ALCint nstereo
Definition sound.h:43
ALint output_limiter
Definition sound.h:44
ALint efx_reverb
Definition sound.h:50
ALint efx_auxSends
Definition sound.h:48
ALint efx_major
Definition sound.h:46
ALCint freq
Definition sound.h:41
ALint efx_minor
Definition sound.h:47