From 8b9152dde981499618ae6549f58ec8397325d843 Mon Sep 17 00:00:00 2001 From: Guy Perfect Date: Fri, 1 Nov 2024 18:29:13 -0500 Subject: [PATCH] Fix S*RAM, Sim.setVolume --- core/vsu.c | 2 +- web/Core.js | 3 ++- web/VB.js | 6 ++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/core/vsu.c b/core/vsu.c index 5cf2e83..cf4c866 100644 --- a/core/vsu.c +++ b/core/vsu.c @@ -295,7 +295,7 @@ static void vsuWriteLRV(VB *sim, int index, uint8_t value) { /* Write a value to S*RAM */ static void vsuWriteRAM(VB *sim, int index, uint8_t value) { - sim->vsu.channels[index].wave.wave = value & 15; + sim->vsu.channels[index].wave.wave = value & 7; } /* Write a value to S5SWP */ diff --git a/web/Core.js b/web/Core.js index 5bedb76..db28494 100644 --- a/web/Core.js +++ b/web/Core.js @@ -417,8 +417,9 @@ new class Core { for (let x = 0; x < buffer.length; x++) buffer[x] = Math.min(Math.max(-1, buffer[x]), +1); } else { + let sim = this.automatic.sims[0]; for (let x = 0; x < buffer.length; x++) - buffer[x] = this.automatic.sims[0].samples[x]; + buffer[x] = sim.samples[x] * sim.volume; } this.audio.postMessage(buffer.buffer, [ buffer.buffer ]); diff --git a/web/VB.js b/web/VB.js index f475755..2d6d3ae 100644 --- a/web/VB.js +++ b/web/VB.js @@ -495,8 +495,10 @@ class Sim extends HTMLElement { async setVolume(volume) { // Error checking - if (!Number.isFinite(volume) ||volume < 0 || volume > 1) - throw new RangeError("Volume must be a number from 0 to 1."); + if (!Number.isFinite(volume) ||volume < 0 || volume > 10) { + throw new RangeError( + "Volume must be a number from 0\u00d7 to 10\u00d7."); + } // Configure instance fields this.#volume = volume;