mirror of
https://github.com/NohamR/Pocket-Bird.git
synced 2026-05-25 19:59:38 +00:00
Add potential for multiple cheeps
This commit is contained in:
BIN
dist/extension.zip
vendored
BIN
dist/extension.zip
vendored
Binary file not shown.
11
dist/extension/birb.js
vendored
11
dist/extension/birb.js
vendored
@@ -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
11
dist/obsidian/main.js
vendored
@@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
11
dist/userscript/birb.user.js
vendored
11
dist/userscript/birb.user.js
vendored
@@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
11
dist/web/birb.embed.js
vendored
11
dist/web/birb.embed.js
vendored
@@ -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
11
dist/web/birb.js
vendored
@@ -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
src/sound.js
11
src/sound.js
@@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user