From 9de22d6389e6d549f3ce32c0a6325596f51cfdab Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Wed, 21 Aug 2019 19:38:56 -0400 Subject: [PATCH] recreate audio when resuming (https://goo.gl/7K7WLu) --- doc/notes.txt | 4 ++++ src/audio.ts | 14 ++++++++++---- src/platform/vcs.ts | 5 +++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/doc/notes.txt b/doc/notes.txt index 7fdfde0d..4b434136 100644 --- a/doc/notes.txt +++ b/doc/notes.txt @@ -137,6 +137,8 @@ TODO: - doesn't do clip right - doesn't do b/w tint - vcs + - sound doesn't start on Chrome (https://goo.gl/7K7WLu) + - make start after clicking in embed - vcs sound continues when paused - vcs: INPTx needs to be added to control state - vcs: break on # of lines changed (maybe using getRasterPosition?) @@ -178,6 +180,8 @@ TODO: - SMS - can't step back twice? - compiler bug in chase +- "shared" in URL doesn't work, leave in URL? (also importURL) +- vicdual: delay is faster WEB WORKER FORMAT diff --git a/src/audio.ts b/src/audio.ts index 655252a6..f9d5ae19 100644 --- a/src/audio.ts +++ b/src/audio.ts @@ -5,13 +5,19 @@ declare var MasterChannel, AudioLooper, PsgDeviceChannel; export class MasterAudio { master = new MasterChannel(); - looper = new AudioLooper(512); + looper; start() { - this.looper.setChannel(this.master); - this.looper.activate(); + if (!this.looper) { + this.looper = new AudioLooper(512); + this.looper.setChannel(this.master); + this.looper.activate(); + } } stop() { - this.looper.setChannel(null); + if (this.looper) { + this.looper.setChannel(null); + this.looper = null; + } } } diff --git a/src/platform/vcs.ts b/src/platform/vcs.ts index bd25ef62..3e9fb979 100644 --- a/src/platform/vcs.ts +++ b/src/platform/vcs.ts @@ -69,6 +69,8 @@ class VCSPlatform extends BasePlatform { var self = this; $("#javatari-div").show(); Javatari.start(); + // for Chrome autostart + Javatari.room.speaker.powerOff(); // intercept clockPulse function Javatari.room.console.oldClockPulse = Javatari.room.console.clockPulse; Javatari.room.console.clockPulse = function() { @@ -127,11 +129,10 @@ class VCSPlatform extends BasePlatform { } pause() { Javatari.room.console.pause(); - Javatari.room.speaker.mute(); } resume() { Javatari.room.console.go(); - Javatari.room.speaker.play(); + Javatari.room.speaker.powerOn(); } advance() { Javatari.room.console.clockPulse();