2 Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
4 This file is part of Lugaru.
6 Lugaru is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 Lugaru is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
20 #include "Quaternions.h"
22 #include "openal_wrapper.h"
24 struct OPENAL_SAMPLE *samp[sounds_count];
26 int footstepsound, footstepsound2, footstepsound3, footstepsound4;
30 static const char *sound_data[sounds_count] = {
31 #define DECLARE_SOUND(id, filename) filename,
36 // FIXME: dimensionality is not a property of the sound sample.
37 // This should be decided at the time of playback
38 static int snd_mode(int snd)
42 case consolefailsound:
43 case consolesuccesssound:
54 for (int i = 0; i < sounds_count; i++) {
56 snprintf(buf, 64, ":Data:Sounds:%s", sound_data[i]);
57 samp[i] = OPENAL_Sample_Load(OPENAL_FREE,
62 footstepsound = footstepsn1;
63 footstepsound2 = footstepsn2;
64 footstepsound3 = footstepst1;
65 footstepsound4 = footstepst2;
67 // OPENAL_Sample_SetMode(samp[whooshsound], OPENAL_LOOP_NORMAL);
68 for (int i = stream_firesound; i <= stream_menutheme; i++)
69 OPENAL_Stream_SetMode(samp[i], OPENAL_LOOP_NORMAL);
73 emit_sound_at(int soundid, const XYZ &pos, float vol)
75 PlaySoundEx (soundid, samp[soundid], NULL, true);
76 OPENAL_3D_SetAttributes_ (channels[soundid], pos, NULL);
77 OPENAL_SetVolume (channels[soundid], vol);
78 OPENAL_SetPaused (channels[soundid], false);
82 emit_sound_np(int soundid, float vol)
84 PlaySoundEx (soundid, samp[soundid], NULL, true);
85 OPENAL_SetVolume (channels[soundid], vol);
86 OPENAL_SetPaused (channels[soundid], false);
90 emit_stream_at(int soundid, const XYZ &pos, float vol)
92 PlayStreamEx (soundid, samp[soundid], NULL, true);
93 OPENAL_3D_SetAttributes_ (channels[soundid], pos, NULL);
94 OPENAL_SetVolume (channels[soundid], vol);
95 OPENAL_SetPaused (channels[soundid], false);
99 emit_stream_np(int soundid, float vol)
101 PlayStreamEx (soundid, samp[soundid], NULL, true);
102 OPENAL_SetVolume (channels[soundid], vol);
103 OPENAL_SetPaused (channels[soundid], false);
107 resume_stream(int soundid)
109 OPENAL_SetPaused (channels[soundid], false);
113 pause_sound(int soundid)
115 OPENAL_SetPaused (channels[soundid], true);