Fix S*RAM, Sim.setVolume

This commit is contained in:
Guy Perfect 2024-11-01 18:29:13 -05:00
parent 26a0357afa
commit 8b9152dde9
3 changed files with 7 additions and 4 deletions

View File

@ -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 */

View File

@ -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 ]);

View File

@ -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;