All files / src relaynoise.js

33.33% Statements 2/6
100% Branches 0/0
11.11% Functions 1/9
33.33% Lines 2/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37        39x       13x                                                        
// Cassette motor relay click sound (issue #296).
// Audio samples recorded from a real BBC Master cassette motor relay.
import { SamplePlayer } from "./sample-player.js";
 
const Volume = 0.4;
 
export class RelayNoise extends SamplePlayer {
    constructor(context, destination) {
        super(context, destination, Volume);
    }
 
    async initialise() {
        await this.loadSounds({
            motorOn: "sounds/tape/motor_on.mp3",
            motorOff: "sounds/tape/motor_off.mp3",
        });
    }
 
    motorOn() {
        this.oneShot(this.sounds.motorOn);
    }
 
    motorOff() {
        this.oneShot(this.sounds.motorOff);
    }
}
 
export class FakeRelayNoise {
    initialise() {
        return Promise.resolve();
    }
    motorOn() {}
    motorOff() {}
    mute() {}
    unmute() {}
}