Add potential for multiple cheeps

This commit is contained in:
Idrees Hassan
2026-03-11 18:47:38 -07:00
parent 7aa9996857
commit efddf12ba5
7 changed files with 210 additions and 180 deletions

BIN
dist/extension.zip vendored

Binary file not shown.

View File

@@ -1291,15 +1291,18 @@
audioContext; audioContext;
chirp() { chirp() {
const count = Math.floor(1 + Math.random() * 1.5);
for (let i = 0; i < count; i++) {
setTimeout(() => {
if (!this.audioContext) { if (!this.audioContext) {
this.audioContext = new AudioContext(); this.audioContext = new AudioContext();
} }
const TIMES = [0, 0.06, 0.10, 0.15]; const TIMES = [0, 0.06, 0.10, 0.15];
const FREQUENCIES = [2200, const FREQUENCIES = [2200,
3500 + Math.random() * 600, 3500 + Math.random() * 600 * count,
2100 + Math.random() * 200, 2100 + Math.random() * 200 * count,
1600 + Math.random() * 400]; 1600 + Math.random() * 400 * count];
const VOLUMES = [0.0001, 0.2, 0.2, 0.0001]; const VOLUMES = [0.0001, 0.2, 0.2, 0.0001];
const oscillator = this.audioContext.createOscillator(); const oscillator = this.audioContext.createOscillator();
@@ -1322,6 +1325,8 @@
oscillator.start(now); oscillator.start(now);
oscillator.stop(now + TIMES[TIMES.length - 1]); oscillator.stop(now + TIMES[TIMES.length - 1]);
}, i * 120);
}
} }
} }

11
dist/obsidian/main.js vendored
View File

@@ -1296,15 +1296,18 @@ module.exports = class PocketBird extends Plugin {
audioContext; audioContext;
chirp() { chirp() {
const count = Math.floor(1 + Math.random() * 1.5);
for (let i = 0; i < count; i++) {
setTimeout(() => {
if (!this.audioContext) { if (!this.audioContext) {
this.audioContext = new AudioContext(); this.audioContext = new AudioContext();
} }
const TIMES = [0, 0.06, 0.10, 0.15]; const TIMES = [0, 0.06, 0.10, 0.15];
const FREQUENCIES = [2200, const FREQUENCIES = [2200,
3500 + Math.random() * 600, 3500 + Math.random() * 600 * count,
2100 + Math.random() * 200, 2100 + Math.random() * 200 * count,
1600 + Math.random() * 400]; 1600 + Math.random() * 400 * count];
const VOLUMES = [0.0001, 0.2, 0.2, 0.0001]; const VOLUMES = [0.0001, 0.2, 0.2, 0.0001];
const oscillator = this.audioContext.createOscillator(); const oscillator = this.audioContext.createOscillator();
@@ -1327,6 +1330,8 @@ module.exports = class PocketBird extends Plugin {
oscillator.start(now); oscillator.start(now);
oscillator.stop(now + TIMES[TIMES.length - 1]); oscillator.stop(now + TIMES[TIMES.length - 1]);
}, i * 120);
}
} }
} }

View File

@@ -1305,15 +1305,18 @@
audioContext; audioContext;
chirp() { chirp() {
const count = Math.floor(1 + Math.random() * 1.5);
for (let i = 0; i < count; i++) {
setTimeout(() => {
if (!this.audioContext) { if (!this.audioContext) {
this.audioContext = new AudioContext(); this.audioContext = new AudioContext();
} }
const TIMES = [0, 0.06, 0.10, 0.15]; const TIMES = [0, 0.06, 0.10, 0.15];
const FREQUENCIES = [2200, const FREQUENCIES = [2200,
3500 + Math.random() * 600, 3500 + Math.random() * 600 * count,
2100 + Math.random() * 200, 2100 + Math.random() * 200 * count,
1600 + Math.random() * 400]; 1600 + Math.random() * 400 * count];
const VOLUMES = [0.0001, 0.2, 0.2, 0.0001]; const VOLUMES = [0.0001, 0.2, 0.2, 0.0001];
const oscillator = this.audioContext.createOscillator(); const oscillator = this.audioContext.createOscillator();
@@ -1336,6 +1339,8 @@
oscillator.start(now); oscillator.start(now);
oscillator.stop(now + TIMES[TIMES.length - 1]); oscillator.stop(now + TIMES[TIMES.length - 1]);
}, i * 120);
}
} }
} }

View File

@@ -1291,15 +1291,18 @@
audioContext; audioContext;
chirp() { chirp() {
const count = Math.floor(1 + Math.random() * 1.5);
for (let i = 0; i < count; i++) {
setTimeout(() => {
if (!this.audioContext) { if (!this.audioContext) {
this.audioContext = new AudioContext(); this.audioContext = new AudioContext();
} }
const TIMES = [0, 0.06, 0.10, 0.15]; const TIMES = [0, 0.06, 0.10, 0.15];
const FREQUENCIES = [2200, const FREQUENCIES = [2200,
3500 + Math.random() * 600, 3500 + Math.random() * 600 * count,
2100 + Math.random() * 200, 2100 + Math.random() * 200 * count,
1600 + Math.random() * 400]; 1600 + Math.random() * 400 * count];
const VOLUMES = [0.0001, 0.2, 0.2, 0.0001]; const VOLUMES = [0.0001, 0.2, 0.2, 0.0001];
const oscillator = this.audioContext.createOscillator(); const oscillator = this.audioContext.createOscillator();
@@ -1322,6 +1325,8 @@
oscillator.start(now); oscillator.start(now);
oscillator.stop(now + TIMES[TIMES.length - 1]); oscillator.stop(now + TIMES[TIMES.length - 1]);
}, i * 120);
}
} }
} }

11
dist/web/birb.js vendored
View File

@@ -1291,15 +1291,18 @@
audioContext; audioContext;
chirp() { chirp() {
const count = Math.floor(1 + Math.random() * 1.5);
for (let i = 0; i < count; i++) {
setTimeout(() => {
if (!this.audioContext) { if (!this.audioContext) {
this.audioContext = new AudioContext(); this.audioContext = new AudioContext();
} }
const TIMES = [0, 0.06, 0.10, 0.15]; const TIMES = [0, 0.06, 0.10, 0.15];
const FREQUENCIES = [2200, const FREQUENCIES = [2200,
3500 + Math.random() * 600, 3500 + Math.random() * 600 * count,
2100 + Math.random() * 200, 2100 + Math.random() * 200 * count,
1600 + Math.random() * 400]; 1600 + Math.random() * 400 * count];
const VOLUMES = [0.0001, 0.2, 0.2, 0.0001]; const VOLUMES = [0.0001, 0.2, 0.2, 0.0001];
const oscillator = this.audioContext.createOscillator(); const oscillator = this.audioContext.createOscillator();
@@ -1322,6 +1325,8 @@
oscillator.start(now); oscillator.start(now);
oscillator.stop(now + TIMES[TIMES.length - 1]); oscillator.stop(now + TIMES[TIMES.length - 1]);
}, i * 120);
}
} }
} }

View File

@@ -8,15 +8,18 @@ export class Birdsong {
audioContext; audioContext;
chirp() { chirp() {
const count = Math.floor(1 + Math.random() * 1.5);
for (let i = 0; i < count; i++) {
setTimeout(() => {
if (!this.audioContext) { if (!this.audioContext) {
this.audioContext = new AudioContext(); this.audioContext = new AudioContext();
} }
const TIMES = [0, 0.06, 0.10, 0.15]; const TIMES = [0, 0.06, 0.10, 0.15];
const FREQUENCIES = [2200, const FREQUENCIES = [2200,
3500 + Math.random() * 600, 3500 + Math.random() * 600 * count,
2100 + Math.random() * 200, 2100 + Math.random() * 200 * count,
1600 + Math.random() * 400]; 1600 + Math.random() * 400 * count];
const VOLUMES = [0.0001, 0.2, 0.2, 0.0001]; const VOLUMES = [0.0001, 0.2, 0.2, 0.0001];
const oscillator = this.audioContext.createOscillator(); const oscillator = this.audioContext.createOscillator();
@@ -39,5 +42,7 @@ export class Birdsong {
oscillator.start(now); oscillator.start(now);
oscillator.stop(now + TIMES[TIMES.length - 1]); oscillator.stop(now + TIMES[TIMES.length - 1]);
}, i * 120);
}
} }
} }