2 * Copyright (C) Volition, Inc. 1999. All rights reserved.
4 * All source code herein is the property of Volition, Inc. You may not sell
5 * or otherwise commercially exploit the source or things you created based on
18 #ifndef WAVE_FORMAT_PCM
19 #define WAVE_FORMAT_PCM 1
22 #ifndef WAVE_FORMAT_ADPCM
23 #define WAVE_FORMAT_ADPCM 2
26 typedef struct WAVE_chunk {
30 uint bytes_per_second;
32 ushort bits_per_sample;
37 WAVE_chunk() : code(0), num_channels(0), sample_rate(0), bytes_per_second(0),
38 block_align(0), bits_per_sample(0), extra_size(0), extra_data(NULL)
43 typedef struct sound_channel {
44 int sig; // uniquely identifies the sound playing on the channel
45 int snd_id; // identifies which kind of sound is playing
46 ALuint source_id; // OpenAL source id
47 int buf_idx; // currently bound buffer index (-1 if none)
48 int flags; // looping, voice_msg, 3d, ...
50 int priority; // implementation dependant priority
53 sound_channel() : sig(0), snd_id(0), source_id(0), buf_idx(-1), flags(0),
54 vol(1.0f), priority(0), last_position(0)
59 typedef struct sound_info {
60 int format; // WAVE_FORMAT_* defines
63 int avg_bytes_per_sec;
67 int duration; // time in ms for duration of sound
72 int oal_init(int use_eax);
77 int oal_get_channel(int sig);
78 int oal_get_number_channels();
80 int oal_get_buffer_size(int sid, int *size);
81 int oal_get_channel_size(int channel);
83 void oal_stop_buffer(int sid);
84 void oal_stop_channel(int channel);
85 void oal_stop_channel_all();
87 void oal_set_volume(int channel, float volume);
88 void oal_set_pan(int channel, float pan);
89 void oal_set_pitch(int channel, float pitch);
90 void oal_set_play_position(int channel, int position);
92 float oal_get_pitch(int channel);
93 int oal_get_play_position(int channel);
95 int oal_is_channel_playing(int channel);
97 void oal_chg_loop_status(int channel, int loop);
99 int oal_parse_wave(const char *filename, ubyte **dest, uint *dest_size, WAVE_chunk **header);
101 int oal_load_buffer(int *sid, int *final_size, WAVE_chunk *header, sound_info *si, int flags);
102 void oal_unload_buffer(int sid);
104 int oal_create_buffer(int frequency, int bits_per_sample, int nchannels, int nseconds);
105 int oal_lock_data(int sid, ubyte *data, int size);
107 sound_channel *oal_get_free_channel(float volume, int snd_id, int priority);
111 int oal_update_source(int channel, int min, int max, vector *pos, vector *vel);
112 int oal_update_listener(vector *pos, vector *vel, matrix *orient);
114 int oal_play(int sid, int snd_id, int priority, float volume, float pan, int flags);
115 int oal_play_3d( int sid, int snd_id, vector *pos, vector *vel, int min, int max, int looping, float max_volume, float estimated_vol, int priority);
117 bool oal_check_for_errors(const char *location);