5 * Created by Alyssa Milburn on Tue Jun 01 2004.
6 * Copyright (c) 2004 Alyssa Milburn. All rights reserved.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
25 #include "AudioBackend.h"
30 #include "Backend.h" // hack for now
32 bool agentOnCamera(Agent
*targ
, bool checkall
= false); // caosVM_camera.cpp
35 SNDE (command) filename (string)
38 Play an uncontrolled sound at the target agent's current position.
40 void caosVM::c_SNDE() {
42 VM_PARAM_STRING(filename
)
45 if (world
.camera
.getMetaRoom() != world
.map
.metaRoomAt(targ
->x
, targ
->y
) || !agentOnCamera(targ
)) return; // TODO: is it correct behaviour for only onscreen agents to play?
46 targ
->playAudio(filename
, false, false);
50 SNDE (command) filename (bareword)
52 %pragma variants c1 c2
55 Play an uncontrolled sound at the target agent's current position.
59 SNDV (command) filename (string)
62 %pragma implementation caosVM::c_SNDE
65 Play an uncontrolled sound at the target agent's current position.
69 SNDC (command) filename (string)
72 Start playing a controlled sound with the target agent, which will follow the agent as it moves.
74 void caosVM::c_SNDC() {
76 VM_PARAM_STRING(filename
)
79 if (world
.camera
.getMetaRoom() != world
.map
.metaRoomAt(targ
->x
, targ
->y
) || !agentOnCamera(targ
)) return; // TODO: is it correct behaviour for only onscreen agents to play?
80 targ
->playAudio(filename
, true, false);
84 SNDC (command) filename (bareword)
86 %pragma variants c1 c2
89 Start playing a controlled sound with the target agent, which will follow the agent as it moves.
93 SNDL (command) filename (string)
96 Start playing a looping controlled sound with the target agent, which will follow the agent as it moves.
98 void caosVM::c_SNDL() {
100 VM_PARAM_STRING(filename
)
103 targ
->playAudio(filename
, true, true);
107 SNDL (command) filename (bareword)
109 %pragma variants c1 c2
112 Start playing a looping controlled sound with the target agent, which will follow the agent as it moves.
116 MMSC (command) x (integer) y (integer) track_name (string)
119 void caosVM::c_MMSC() {
121 VM_PARAM_STRING(track_name
)
128 MMSC (string) x (integer) y (integer)
131 void caosVM::v_MMSC() {
136 result
.setString("");
140 RMSC (command) x (integer) y (integer) track_name (string)
143 void caosVM::c_RMSC() {
145 VM_PARAM_STRING(track_name
)
152 RMSC (string) x (integer) y (integer)
155 void caosVM::v_RMSC() {
160 result
.setString("");
166 %pragma variants c1 c2 cv c3 sm
169 void caosVM::c_FADE() {
174 targ
->sound
->fadeOut();
180 %pragma variants c1 c2 cv c3 sm
183 void caosVM::c_STPC() {
189 STRK (command) latency (integer) track (string)
192 Play the specified music track. It will play for at least latency seconds.
194 void caosVM::c_STRK() {
195 VM_PARAM_STRING(track
)
196 VM_PARAM_INTEGER(latency
)
202 VOLM (command) type (integer) volume (integer)
205 Changes the volume of the specified type of audio; 0 for sound effects, 1 for midi or 2 for dynamic music.
206 Volume is from -10000 (silent) to 0 (maximum).
208 void caosVM::c_VOLM() {
209 VM_PARAM_INTEGER(volume
)
210 VM_PARAM_INTEGER(type
)
216 VOLM (integer) type (integer)
219 Return the volumne of the specified type of audio; 0 for sound effects, 1 for midi or 2 for dynamic music.
220 Volume is from -10000 (silent) to 0 (maximum).
222 void caosVM::v_VOLM() {
223 VM_PARAM_INTEGER(type
)
225 result
.setInt(0); // TODO
229 MUTE (integer) andmask (integer) eormask (integer)
232 This returns/sets information about which types of in-game audio are muted.
233 Set andmask for the information you want returned, and eormask for the information you want changed.
234 1 is for normal sound, and 2 is for music (so 3 is for both combined).
236 void caosVM::v_MUTE() {
237 VM_PARAM_INTEGER(eormask
)
238 VM_PARAM_INTEGER(andmask
)
240 // TODO: we should maintain state despite having no audio engine, probably
241 // (UI scripting assumes changes were successful)
249 if (eormask
& 1) engine
.audio
->setMute(!engine
.audio
->isMuted());
252 if (andmask
& 1 && engine
.audio
->isMuted()) r
+= 1;
257 SEZZ (command) text (string)
260 void caosVM::c_SEZZ() {
261 VM_PARAM_STRING(text
)
269 VOIS (command) voice (string)
272 void caosVM::c_VOIS() {
273 VM_PARAM_STRING(voice
)
281 MIDI (command) midifile (string)
284 Plays the MIDI file specified, or stops playing if passed an empty string.
286 void caosVM::c_MIDI() {
287 VM_PARAM_STRING(midifile
)
293 PLDS (command) filename (bareword)
295 %pragma variants c1 c2
297 Preload the specified sound file if TARG is visible or just offscreen.
299 void caosVM::c_PLDS() {
300 VM_PARAM_STRING(filename
)
303 if (world
.camera
.getMetaRoom() != world
.map
.metaRoomAt(targ
->x
, targ
->y
)) return; // TODO: needs better check ;)