prosperon/scripts/sound.js

46 lines
670 B
JavaScript
Raw Normal View History

var Music = {
play(path) {
Log.info("Playing " + path);
cmd(87,path);
},
stop() {
cmd(89);
},
pause() {
cmd(88);
},
set volume(x) {
},
};
var Sound = {
sounds: [], /* array of loaded sound files */
play(file) {
2023-10-09 13:03:12 -05:00
if (!IO.exists(file)) {
2023-10-11 17:22:41 -05:00
Log.error(`Cannot play sound ${file}: does not exist.`);
2023-10-09 13:03:12 -05:00
return;
}
this.id = cmd(14,file);
},
music(midi, sf) {
cmd(13, midi, sf);
},
musicstop() {
cmd(15);
},
/* Between 0 and 100 */
set volume(x) { cmd(19, x); },
killall() {
Music.stop();
this.musicstop();
/* TODO: Kill all sound effects that may still be running */
},
};