naev 0.11.5
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>
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
25/*
26 * Static configuration.
27 */
28#define SOUND_PILOT_RELATIVE 1
30/*
31 * Environmental features.
32 */
33typedef enum SoundEnv_e {
34 SOUND_ENV_NORMAL,
35 SOUND_ENV_NEBULA
36} SoundEnv_t;
38typedef struct alInfo_s {
39 ALCint freq;
40 ALCint nmono;
41 ALCint nstereo;
43 ALint efx;
44 ALint efx_major;
45 ALint efx_minor;
47 /* Effect types. */
48 ALint efx_reverb;
49 ALint efx_echo;
50} alInfo_t;
51extern alInfo_t al_info;
52
53extern ALuint sound_efx_directSlot;
55/*
56 * Vorbis stuff.
57 */
58extern ov_callbacks sound_al_ovcall;
59extern ov_callbacks sound_al_ovcall_noclose;
60
61/*
62 * sound subsystem
63 */
64int sound_init (void);
65void sound_exit (void);
66int sound_update( double dt );
67void sound_pause (void);
68void sound_resume (void);
69int sound_volume( const double vol );
70double sound_getVolume (void);
71double sound_getVolumeLog (void);
72void sound_stopAll (void);
73void sound_setSpeed( double s );
74
75/*
76 * source management
77 */
78int source_newRW( SDL_RWops *rw, const char *name, unsigned int flags );
79int source_new( const char* filename, unsigned int flags );
80
81/*
82 * sound sample management
83 */
84int sound_get( const char* name );
85double sound_getLength( int sound );
86
87/*
88 * voice management
89 */
90int sound_play( int sound );
91int sound_playPos( int sound, double px, double py, double vx, double vy );
92void sound_stop( int voice );
93int sound_updatePos( int voice, double px, double py, double vx, double vy );
94int sound_updateListener( double dir, double px, double py,
95 double vx, double vy );
96
97/*
98 * Group functions.
99 */
100int sound_reserve( int num );
101int sound_createGroup( int size );
102int sound_playGroup( int group, int sound, int once );
103void sound_stopGroup( int group );
104void sound_pauseGroup( int group );
105void sound_resumeGroup( int group );
106void sound_speedGroup( int group, int enable );
107void sound_volumeGroup( int group, double volume );
108void sound_pitchGroup( int group, double pitch );
109
110/*
111 * Environmental functions.
112 */
113void sound_setAbsorption( double value );
114int sound_env( SoundEnv_t env, double param );
115
116/* Lock for OpenAL operations. */
117int sound_al_buffer( ALuint *buf, SDL_RWops *rw, const char *name );
118extern SDL_mutex *sound_lock;
119#define soundLock() SDL_mutexP(sound_lock)
120#define soundUnlock() SDL_mutexV(sound_lock)
int sound_createGroup(int size)
Creates a sound group.
Definition sound.c:1329
double sound_getVolumeLog(void)
Gets the current sound volume (logarithmic).
Definition sound.c:1295
int sound_al_buffer(ALuint *buf, SDL_RWops *rw, const char *name)
Loads the sound.
Definition sound.c:2001
double sound_getLength(int sound)
Gets the length of the sound buffer.
Definition sound.c:775
void sound_pitchGroup(int group, double pitch)
Sets the pitch of a group.
Definition sound.c:1605
void sound_resume(void)
Resumes all the sounds.
Definition sound.c:1027
void sound_resumeGroup(int group)
Resumes all the sounds in a group.
Definition sound.c:1519
double sound_getVolume(void)
Gets the current sound volume (linear).
Definition sound.c:1282
void sound_speedGroup(int group, int enable)
Sets whether or not the speed affects a group.
Definition sound.c:1551
int source_newRW(SDL_RWops *rw, const char *name, unsigned int flags)
Loads a new sound source from a RWops.
Definition sound.c:1786
int sound_disabled
Definition sound.c:133
int sound_updateListener(double dir, double px, double py, double vx, double vy)
Updates the sound listener.
Definition sound.c:1109
SDL_mutex * sound_lock
Definition sound.c:167
int sound_playPos(int sound, double px, double py, double vx, double vy)
Plays a sound based on position.
Definition sound.c:827
int sound_playGroup(int group, int sound, int once)
Plays a sound in a group.
Definition sound.c:1401
void sound_exit(void)
Cleans up after the sound subsytem.
Definition sound.c:665
void sound_stopGroup(int group)
Stops all the sounds in a group.
Definition sound.c:1477
int sound_update(double dt)
Updates the sounds removing obsolete ones and such.
Definition sound.c:908
void sound_stopAll(void)
Stops all the playing voices.
Definition sound.c:1044
int source_new(const char *filename, unsigned int flags)
Loads a new source from a file.
Definition sound.c:1810
ov_callbacks sound_al_ovcall_noclose
Definition sound.c:281
int sound_init(void)
Initializes the sound subsystem.
Definition sound.c:602
void sound_pause(void)
Pauses all the sounds.
Definition sound.c:1010
int sound_get(const char *name)
Gets the buffer to sound of name.
Definition sound.c:756
int sound_env(SoundEnv_t env_type, double param)
Sets up the sound environment.
Definition sound.c:1649
void sound_pauseGroup(int group)
Pauses all the sounds in a group.
Definition sound.c:1497
ALuint sound_efx_directSlot
Definition sound.c:194
alInfo_t al_info
Definition sound.c:178
void sound_stop(int voice)
Stops a voice from playing.
Definition sound.c:1074
ov_callbacks sound_al_ovcall
Definition sound.c:275
int sound_updatePos(int voice, double px, double py, double vx, double vy)
Updates the position of a voice.
Definition sound.c:884
int sound_play(int sound)
Plays the sound in the first available channel.
Definition sound.c:789
int sound_volume(const double vol)
Sets the volume.
Definition sound.c:1259
void sound_volumeGroup(int group, double volume)
Sets the volume of a group.
Definition sound.c:1575
void sound_setSpeed(double s)
Sets the speed to play the sound at.
Definition sound.c:1152
ALint efx
Definition sound.h:43
ALCint nmono
Definition sound.h:40
ALint efx_echo
Definition sound.h:49
ALCint nstereo
Definition sound.h:41
ALint output_limiter
Definition sound.h:42
ALint efx_reverb
Definition sound.h:48
ALint efx_auxSends
Definition sound.h:46
ALint efx_major
Definition sound.h:44
ALCint freq
Definition sound.h:39
ALint efx_minor
Definition sound.h:45