Files
azuracast-themes/backrooms/backrooms.js
T
2026-07-01 15:59:27 -07:00

54 lines
2.0 KiB
JavaScript

// Please dont remove this attribution its required by the license of this code.
// This code is licensed under the CPSL License.
//
// Original code by: @chillcog
// See https://git.chillcog.com/chillcog/azuracast-themes
// Copyright (c) 2024-2026 ChillCog
//
document.addEventListener("DOMContentLoaded", function () {
const scanline = document.createElement('div');
scanline.id = 'backrooms-scanlines';
Object.assign(scanline.style, {
position: 'fixed',
top: '0',
left: '0',
width: '100vw',
height: '100vh',
background: 'linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.15) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03))',
backgroundSize: '100% 4px, 6px 100%',
zIndex: '9999',
pointerEvents: 'none'
});
document.body.appendChild(scanline);
let audioCtx = null;
let humOsc = null;
let buzzOsc = null;
let gainNode = null;
function startFluorescentHum() {
if (audioCtx) return;
audioCtx = new (window.AudioContext || window.webkitAudioContext)();
gainNode = audioCtx.createGain();
gainNode.gain.setValueAtTime(0.015, audioCtx.currentTime);
gainNode.connect(audioCtx.destination);
humOsc = audioCtx.createOscillator();
humOsc.type = 'sine';
humOsc.frequency.setValueAtTime(60, audioCtx.currentTime);
humOsc.connect(gainNode);
humOsc.start();
buzzOsc = audioCtx.createOscillator();
buzzOsc.type = 'sawtooth';
buzzOsc.frequency.setValueAtTime(120, audioCtx.currentTime);
const filter = audioCtx.createBiquadFilter();
filter.type = 'lowpass';
filter.frequency.setValueAtTime(200, audioCtx.currentTime);
buzzOsc.connect(filter);
filter.connect(gainNode);
buzzOsc.start();
}
window.addEventListener('click', startFluorescentHum, { once: true });
window.addEventListener('touchstart', startFluorescentHum, { once: true });
});