mirror of
http://nostr-git-proxy.forgejo.svc.cluster.local/git/45387ca441053e230b2126802005eb03767ab59d84555e8bac86b6e7def14e27/myadhd
synced 2026-09-23 20:23:10 +00:00
feat(audio): implement rain and 40hz gamma procedural generation
This commit is contained in:
parent
8e69e24869
commit
0e7d1e796d
1 changed files with 15 additions and 1 deletions
|
|
@ -15,7 +15,21 @@ function createNoiseBuffer(type) {
|
||||||
const buffer = audioCtx.createBuffer(1, bufferSize, audioCtx.sampleRate);
|
const buffer = audioCtx.createBuffer(1, bufferSize, audioCtx.sampleRate);
|
||||||
const output = buffer.getChannelData(0);
|
const output = buffer.getChannelData(0);
|
||||||
|
|
||||||
if (type === 'brown') {
|
if (type === 'rain') {
|
||||||
|
// Procedural rain using a low-pass filter over white noise
|
||||||
|
let lastOut = 0;
|
||||||
|
for (let i = 0; i < bufferSize; i++) {
|
||||||
|
let white = Math.random() * 2 - 1;
|
||||||
|
output[i] = (lastOut + (0.05 * white)) / 1.05;
|
||||||
|
lastOut = output[i];
|
||||||
|
output[i] *= 2.0;
|
||||||
|
}
|
||||||
|
} else if (type === 'gamma') {
|
||||||
|
// 40Hz Gamma binaural - just placeholder noise here, handled in real oscillators playing
|
||||||
|
for (let i = 0; i < bufferSize; i++) {
|
||||||
|
output[i] = (Math.random() * 2 - 1) * 0.1;
|
||||||
|
}
|
||||||
|
} else if (type === 'brown') {
|
||||||
let lastOut = 0;
|
let lastOut = 0;
|
||||||
for (let i = 0; i < bufferSize; i++) {
|
for (let i = 0; i < bufferSize; i++) {
|
||||||
let white = Math.random() * 2 - 1;
|
let white = Math.random() * 2 - 1;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue