@@ -22,7 +22,7 @@ | |||
#include <string.h> | |||
#include "audio_stream.h" | |||
#define AUDIO_STREAM_DEBUG | |||
// #define AUDIO_STREAM_DEBUG | |||
typedef struct { | |||
u8 enabled; |
@@ -35,11 +35,11 @@ mergeInto(LibraryManager.library, { | |||
zeta_update_palette: function(data_ptr) { | |||
return zetag_update_palette(data_ptr); | |||
}, | |||
speaker_on: function(freq) { | |||
speakerg_on(freq); | |||
speaker_on: function(cycles, freq) { | |||
speakerg_on(cycles, freq); | |||
}, | |||
speaker_off: function() { | |||
speakerg_off(); | |||
speaker_off: function(cycles) { | |||
speakerg_off(cycles); | |||
} | |||
}); | |||
@@ -44,7 +44,7 @@ export class OscillatorBasedAudio { | |||
this.noteDelay = 1; | |||
} | |||
on(time, freq) { | |||
on(time, cycles, freq) { | |||
if (audioCtx == undefined) | |||
return; | |||
@@ -73,7 +73,7 @@ export class OscillatorBasedAudio { | |||
this.timeSpeakerOn = time; | |||
} | |||
off(time) { | |||
off(time, cycles) { | |||
if (this.pc_speaker == undefined) | |||
return; | |||
@@ -179,14 +179,14 @@ export class BufferBasedAudio { | |||
} | |||
} | |||
on(time, freq) { | |||
on(time, cycles, freq) { | |||
if (audioCtx == undefined) return; | |||
this._initSpeaker(); | |||
this.emu._audio_stream_append_on(time, freq); | |||
this.emu._audio_stream_append_on(time, cycles, freq); | |||
} | |||
off(time) { | |||
off(time, cycles) { | |||
if (audioCtx == undefined) return; | |||
this.emu._audio_stream_append_off(time); | |||
this.emu._audio_stream_append_off(time, cycles); | |||
} | |||
} |
@@ -69,17 +69,17 @@ class Emulator { | |||
render.setPalette(data); | |||
} | |||
window.speakerg_on = function(freq) { | |||
window.speakerg_on = function(cycles, freq) { | |||
if (!document.hasFocus()) { | |||
speakerg_off(); | |||
return; | |||
} | |||
if (audio != undefined) audio.on(self.time_ms_cached, freq); | |||
if (audio != undefined) audio.on(self.time_ms_cached, cycles, freq); | |||
} | |||
window.speakerg_off = function() { | |||
if (audio != undefined) audio.off(self.time_ms_cached); | |||
window.speakerg_off = function(cycles) { | |||
if (audio != undefined) audio.off(self.time_ms_cached, cycles); | |||
} | |||
window.addEventListener("message", function(event) { |