mirror of
https://github.com/NohamR/Pocket-Bird.git
synced 2026-05-25 04:07:23 +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.
65
dist/extension/birb.js
vendored
65
dist/extension/birb.js
vendored
@@ -1291,37 +1291,42 @@
|
|||||||
audioContext;
|
audioContext;
|
||||||
|
|
||||||
chirp() {
|
chirp() {
|
||||||
if (!this.audioContext) {
|
const count = Math.floor(1 + Math.random() * 1.5);
|
||||||
this.audioContext = new AudioContext();
|
for (let i = 0; i < count; i++) {
|
||||||
|
setTimeout(() => {
|
||||||
|
if (!this.audioContext) {
|
||||||
|
this.audioContext = new AudioContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
const TIMES = [0, 0.06, 0.10, 0.15];
|
||||||
|
const FREQUENCIES = [2200,
|
||||||
|
3500 + Math.random() * 600 * count,
|
||||||
|
2100 + Math.random() * 200 * count,
|
||||||
|
1600 + Math.random() * 400 * count];
|
||||||
|
const VOLUMES = [0.0001, 0.2, 0.2, 0.0001];
|
||||||
|
|
||||||
|
const oscillator = this.audioContext.createOscillator();
|
||||||
|
oscillator.type = "sine";
|
||||||
|
const gain = this.audioContext.createGain();
|
||||||
|
oscillator.connect(gain);
|
||||||
|
gain.connect(this.audioContext.destination);
|
||||||
|
|
||||||
|
const now = this.audioContext.currentTime;
|
||||||
|
for (let i = 0; i < TIMES.length; i++) {
|
||||||
|
const time = TIMES[i] + now;
|
||||||
|
if (i === 0) {
|
||||||
|
oscillator.frequency.setValueAtTime(FREQUENCIES[i], time);
|
||||||
|
gain.gain.setValueAtTime(VOLUMES[i], time);
|
||||||
|
} else {
|
||||||
|
oscillator.frequency.exponentialRampToValueAtTime(FREQUENCIES[i], time);
|
||||||
|
gain.gain.exponentialRampToValueAtTime(VOLUMES[i], time);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
oscillator.start(now);
|
||||||
|
oscillator.stop(now + TIMES[TIMES.length - 1]);
|
||||||
|
}, i * 120);
|
||||||
}
|
}
|
||||||
|
|
||||||
const TIMES = [0, 0.06, 0.10, 0.15];
|
|
||||||
const FREQUENCIES = [2200,
|
|
||||||
3500 + Math.random() * 600,
|
|
||||||
2100 + Math.random() * 200,
|
|
||||||
1600 + Math.random() * 400];
|
|
||||||
const VOLUMES = [0.0001, 0.2, 0.2, 0.0001];
|
|
||||||
|
|
||||||
const oscillator = this.audioContext.createOscillator();
|
|
||||||
oscillator.type = "sine";
|
|
||||||
const gain = this.audioContext.createGain();
|
|
||||||
oscillator.connect(gain);
|
|
||||||
gain.connect(this.audioContext.destination);
|
|
||||||
|
|
||||||
const now = this.audioContext.currentTime;
|
|
||||||
for (let i = 0; i < TIMES.length; i++) {
|
|
||||||
const time = TIMES[i] + now;
|
|
||||||
if (i === 0) {
|
|
||||||
oscillator.frequency.setValueAtTime(FREQUENCIES[i], time);
|
|
||||||
gain.gain.setValueAtTime(VOLUMES[i], time);
|
|
||||||
} else {
|
|
||||||
oscillator.frequency.exponentialRampToValueAtTime(FREQUENCIES[i], time);
|
|
||||||
gain.gain.exponentialRampToValueAtTime(VOLUMES[i], time);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
oscillator.start(now);
|
|
||||||
oscillator.stop(now + TIMES[TIMES.length - 1]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
65
dist/obsidian/main.js
vendored
65
dist/obsidian/main.js
vendored
@@ -1296,37 +1296,42 @@ module.exports = class PocketBird extends Plugin {
|
|||||||
audioContext;
|
audioContext;
|
||||||
|
|
||||||
chirp() {
|
chirp() {
|
||||||
if (!this.audioContext) {
|
const count = Math.floor(1 + Math.random() * 1.5);
|
||||||
this.audioContext = new AudioContext();
|
for (let i = 0; i < count; i++) {
|
||||||
|
setTimeout(() => {
|
||||||
|
if (!this.audioContext) {
|
||||||
|
this.audioContext = new AudioContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
const TIMES = [0, 0.06, 0.10, 0.15];
|
||||||
|
const FREQUENCIES = [2200,
|
||||||
|
3500 + Math.random() * 600 * count,
|
||||||
|
2100 + Math.random() * 200 * count,
|
||||||
|
1600 + Math.random() * 400 * count];
|
||||||
|
const VOLUMES = [0.0001, 0.2, 0.2, 0.0001];
|
||||||
|
|
||||||
|
const oscillator = this.audioContext.createOscillator();
|
||||||
|
oscillator.type = "sine";
|
||||||
|
const gain = this.audioContext.createGain();
|
||||||
|
oscillator.connect(gain);
|
||||||
|
gain.connect(this.audioContext.destination);
|
||||||
|
|
||||||
|
const now = this.audioContext.currentTime;
|
||||||
|
for (let i = 0; i < TIMES.length; i++) {
|
||||||
|
const time = TIMES[i] + now;
|
||||||
|
if (i === 0) {
|
||||||
|
oscillator.frequency.setValueAtTime(FREQUENCIES[i], time);
|
||||||
|
gain.gain.setValueAtTime(VOLUMES[i], time);
|
||||||
|
} else {
|
||||||
|
oscillator.frequency.exponentialRampToValueAtTime(FREQUENCIES[i], time);
|
||||||
|
gain.gain.exponentialRampToValueAtTime(VOLUMES[i], time);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
oscillator.start(now);
|
||||||
|
oscillator.stop(now + TIMES[TIMES.length - 1]);
|
||||||
|
}, i * 120);
|
||||||
}
|
}
|
||||||
|
|
||||||
const TIMES = [0, 0.06, 0.10, 0.15];
|
|
||||||
const FREQUENCIES = [2200,
|
|
||||||
3500 + Math.random() * 600,
|
|
||||||
2100 + Math.random() * 200,
|
|
||||||
1600 + Math.random() * 400];
|
|
||||||
const VOLUMES = [0.0001, 0.2, 0.2, 0.0001];
|
|
||||||
|
|
||||||
const oscillator = this.audioContext.createOscillator();
|
|
||||||
oscillator.type = "sine";
|
|
||||||
const gain = this.audioContext.createGain();
|
|
||||||
oscillator.connect(gain);
|
|
||||||
gain.connect(this.audioContext.destination);
|
|
||||||
|
|
||||||
const now = this.audioContext.currentTime;
|
|
||||||
for (let i = 0; i < TIMES.length; i++) {
|
|
||||||
const time = TIMES[i] + now;
|
|
||||||
if (i === 0) {
|
|
||||||
oscillator.frequency.setValueAtTime(FREQUENCIES[i], time);
|
|
||||||
gain.gain.setValueAtTime(VOLUMES[i], time);
|
|
||||||
} else {
|
|
||||||
oscillator.frequency.exponentialRampToValueAtTime(FREQUENCIES[i], time);
|
|
||||||
gain.gain.exponentialRampToValueAtTime(VOLUMES[i], time);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
oscillator.start(now);
|
|
||||||
oscillator.stop(now + TIMES[TIMES.length - 1]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
65
dist/userscript/birb.user.js
vendored
65
dist/userscript/birb.user.js
vendored
@@ -1305,37 +1305,42 @@
|
|||||||
audioContext;
|
audioContext;
|
||||||
|
|
||||||
chirp() {
|
chirp() {
|
||||||
if (!this.audioContext) {
|
const count = Math.floor(1 + Math.random() * 1.5);
|
||||||
this.audioContext = new AudioContext();
|
for (let i = 0; i < count; i++) {
|
||||||
|
setTimeout(() => {
|
||||||
|
if (!this.audioContext) {
|
||||||
|
this.audioContext = new AudioContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
const TIMES = [0, 0.06, 0.10, 0.15];
|
||||||
|
const FREQUENCIES = [2200,
|
||||||
|
3500 + Math.random() * 600 * count,
|
||||||
|
2100 + Math.random() * 200 * count,
|
||||||
|
1600 + Math.random() * 400 * count];
|
||||||
|
const VOLUMES = [0.0001, 0.2, 0.2, 0.0001];
|
||||||
|
|
||||||
|
const oscillator = this.audioContext.createOscillator();
|
||||||
|
oscillator.type = "sine";
|
||||||
|
const gain = this.audioContext.createGain();
|
||||||
|
oscillator.connect(gain);
|
||||||
|
gain.connect(this.audioContext.destination);
|
||||||
|
|
||||||
|
const now = this.audioContext.currentTime;
|
||||||
|
for (let i = 0; i < TIMES.length; i++) {
|
||||||
|
const time = TIMES[i] + now;
|
||||||
|
if (i === 0) {
|
||||||
|
oscillator.frequency.setValueAtTime(FREQUENCIES[i], time);
|
||||||
|
gain.gain.setValueAtTime(VOLUMES[i], time);
|
||||||
|
} else {
|
||||||
|
oscillator.frequency.exponentialRampToValueAtTime(FREQUENCIES[i], time);
|
||||||
|
gain.gain.exponentialRampToValueAtTime(VOLUMES[i], time);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
oscillator.start(now);
|
||||||
|
oscillator.stop(now + TIMES[TIMES.length - 1]);
|
||||||
|
}, i * 120);
|
||||||
}
|
}
|
||||||
|
|
||||||
const TIMES = [0, 0.06, 0.10, 0.15];
|
|
||||||
const FREQUENCIES = [2200,
|
|
||||||
3500 + Math.random() * 600,
|
|
||||||
2100 + Math.random() * 200,
|
|
||||||
1600 + Math.random() * 400];
|
|
||||||
const VOLUMES = [0.0001, 0.2, 0.2, 0.0001];
|
|
||||||
|
|
||||||
const oscillator = this.audioContext.createOscillator();
|
|
||||||
oscillator.type = "sine";
|
|
||||||
const gain = this.audioContext.createGain();
|
|
||||||
oscillator.connect(gain);
|
|
||||||
gain.connect(this.audioContext.destination);
|
|
||||||
|
|
||||||
const now = this.audioContext.currentTime;
|
|
||||||
for (let i = 0; i < TIMES.length; i++) {
|
|
||||||
const time = TIMES[i] + now;
|
|
||||||
if (i === 0) {
|
|
||||||
oscillator.frequency.setValueAtTime(FREQUENCIES[i], time);
|
|
||||||
gain.gain.setValueAtTime(VOLUMES[i], time);
|
|
||||||
} else {
|
|
||||||
oscillator.frequency.exponentialRampToValueAtTime(FREQUENCIES[i], time);
|
|
||||||
gain.gain.exponentialRampToValueAtTime(VOLUMES[i], time);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
oscillator.start(now);
|
|
||||||
oscillator.stop(now + TIMES[TIMES.length - 1]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
65
dist/web/birb.embed.js
vendored
65
dist/web/birb.embed.js
vendored
@@ -1291,37 +1291,42 @@
|
|||||||
audioContext;
|
audioContext;
|
||||||
|
|
||||||
chirp() {
|
chirp() {
|
||||||
if (!this.audioContext) {
|
const count = Math.floor(1 + Math.random() * 1.5);
|
||||||
this.audioContext = new AudioContext();
|
for (let i = 0; i < count; i++) {
|
||||||
|
setTimeout(() => {
|
||||||
|
if (!this.audioContext) {
|
||||||
|
this.audioContext = new AudioContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
const TIMES = [0, 0.06, 0.10, 0.15];
|
||||||
|
const FREQUENCIES = [2200,
|
||||||
|
3500 + Math.random() * 600 * count,
|
||||||
|
2100 + Math.random() * 200 * count,
|
||||||
|
1600 + Math.random() * 400 * count];
|
||||||
|
const VOLUMES = [0.0001, 0.2, 0.2, 0.0001];
|
||||||
|
|
||||||
|
const oscillator = this.audioContext.createOscillator();
|
||||||
|
oscillator.type = "sine";
|
||||||
|
const gain = this.audioContext.createGain();
|
||||||
|
oscillator.connect(gain);
|
||||||
|
gain.connect(this.audioContext.destination);
|
||||||
|
|
||||||
|
const now = this.audioContext.currentTime;
|
||||||
|
for (let i = 0; i < TIMES.length; i++) {
|
||||||
|
const time = TIMES[i] + now;
|
||||||
|
if (i === 0) {
|
||||||
|
oscillator.frequency.setValueAtTime(FREQUENCIES[i], time);
|
||||||
|
gain.gain.setValueAtTime(VOLUMES[i], time);
|
||||||
|
} else {
|
||||||
|
oscillator.frequency.exponentialRampToValueAtTime(FREQUENCIES[i], time);
|
||||||
|
gain.gain.exponentialRampToValueAtTime(VOLUMES[i], time);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
oscillator.start(now);
|
||||||
|
oscillator.stop(now + TIMES[TIMES.length - 1]);
|
||||||
|
}, i * 120);
|
||||||
}
|
}
|
||||||
|
|
||||||
const TIMES = [0, 0.06, 0.10, 0.15];
|
|
||||||
const FREQUENCIES = [2200,
|
|
||||||
3500 + Math.random() * 600,
|
|
||||||
2100 + Math.random() * 200,
|
|
||||||
1600 + Math.random() * 400];
|
|
||||||
const VOLUMES = [0.0001, 0.2, 0.2, 0.0001];
|
|
||||||
|
|
||||||
const oscillator = this.audioContext.createOscillator();
|
|
||||||
oscillator.type = "sine";
|
|
||||||
const gain = this.audioContext.createGain();
|
|
||||||
oscillator.connect(gain);
|
|
||||||
gain.connect(this.audioContext.destination);
|
|
||||||
|
|
||||||
const now = this.audioContext.currentTime;
|
|
||||||
for (let i = 0; i < TIMES.length; i++) {
|
|
||||||
const time = TIMES[i] + now;
|
|
||||||
if (i === 0) {
|
|
||||||
oscillator.frequency.setValueAtTime(FREQUENCIES[i], time);
|
|
||||||
gain.gain.setValueAtTime(VOLUMES[i], time);
|
|
||||||
} else {
|
|
||||||
oscillator.frequency.exponentialRampToValueAtTime(FREQUENCIES[i], time);
|
|
||||||
gain.gain.exponentialRampToValueAtTime(VOLUMES[i], time);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
oscillator.start(now);
|
|
||||||
oscillator.stop(now + TIMES[TIMES.length - 1]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
65
dist/web/birb.js
vendored
65
dist/web/birb.js
vendored
@@ -1291,37 +1291,42 @@
|
|||||||
audioContext;
|
audioContext;
|
||||||
|
|
||||||
chirp() {
|
chirp() {
|
||||||
if (!this.audioContext) {
|
const count = Math.floor(1 + Math.random() * 1.5);
|
||||||
this.audioContext = new AudioContext();
|
for (let i = 0; i < count; i++) {
|
||||||
|
setTimeout(() => {
|
||||||
|
if (!this.audioContext) {
|
||||||
|
this.audioContext = new AudioContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
const TIMES = [0, 0.06, 0.10, 0.15];
|
||||||
|
const FREQUENCIES = [2200,
|
||||||
|
3500 + Math.random() * 600 * count,
|
||||||
|
2100 + Math.random() * 200 * count,
|
||||||
|
1600 + Math.random() * 400 * count];
|
||||||
|
const VOLUMES = [0.0001, 0.2, 0.2, 0.0001];
|
||||||
|
|
||||||
|
const oscillator = this.audioContext.createOscillator();
|
||||||
|
oscillator.type = "sine";
|
||||||
|
const gain = this.audioContext.createGain();
|
||||||
|
oscillator.connect(gain);
|
||||||
|
gain.connect(this.audioContext.destination);
|
||||||
|
|
||||||
|
const now = this.audioContext.currentTime;
|
||||||
|
for (let i = 0; i < TIMES.length; i++) {
|
||||||
|
const time = TIMES[i] + now;
|
||||||
|
if (i === 0) {
|
||||||
|
oscillator.frequency.setValueAtTime(FREQUENCIES[i], time);
|
||||||
|
gain.gain.setValueAtTime(VOLUMES[i], time);
|
||||||
|
} else {
|
||||||
|
oscillator.frequency.exponentialRampToValueAtTime(FREQUENCIES[i], time);
|
||||||
|
gain.gain.exponentialRampToValueAtTime(VOLUMES[i], time);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
oscillator.start(now);
|
||||||
|
oscillator.stop(now + TIMES[TIMES.length - 1]);
|
||||||
|
}, i * 120);
|
||||||
}
|
}
|
||||||
|
|
||||||
const TIMES = [0, 0.06, 0.10, 0.15];
|
|
||||||
const FREQUENCIES = [2200,
|
|
||||||
3500 + Math.random() * 600,
|
|
||||||
2100 + Math.random() * 200,
|
|
||||||
1600 + Math.random() * 400];
|
|
||||||
const VOLUMES = [0.0001, 0.2, 0.2, 0.0001];
|
|
||||||
|
|
||||||
const oscillator = this.audioContext.createOscillator();
|
|
||||||
oscillator.type = "sine";
|
|
||||||
const gain = this.audioContext.createGain();
|
|
||||||
oscillator.connect(gain);
|
|
||||||
gain.connect(this.audioContext.destination);
|
|
||||||
|
|
||||||
const now = this.audioContext.currentTime;
|
|
||||||
for (let i = 0; i < TIMES.length; i++) {
|
|
||||||
const time = TIMES[i] + now;
|
|
||||||
if (i === 0) {
|
|
||||||
oscillator.frequency.setValueAtTime(FREQUENCIES[i], time);
|
|
||||||
gain.gain.setValueAtTime(VOLUMES[i], time);
|
|
||||||
} else {
|
|
||||||
oscillator.frequency.exponentialRampToValueAtTime(FREQUENCIES[i], time);
|
|
||||||
gain.gain.exponentialRampToValueAtTime(VOLUMES[i], time);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
oscillator.start(now);
|
|
||||||
oscillator.stop(now + TIMES[TIMES.length - 1]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
65
src/sound.js
65
src/sound.js
@@ -8,36 +8,41 @@ export class Birdsong {
|
|||||||
audioContext;
|
audioContext;
|
||||||
|
|
||||||
chirp() {
|
chirp() {
|
||||||
if (!this.audioContext) {
|
const count = Math.floor(1 + Math.random() * 1.5);
|
||||||
this.audioContext = new AudioContext();
|
for (let i = 0; i < count; i++) {
|
||||||
|
setTimeout(() => {
|
||||||
|
if (!this.audioContext) {
|
||||||
|
this.audioContext = new AudioContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
const TIMES = [0, 0.06, 0.10, 0.15];
|
||||||
|
const FREQUENCIES = [2200,
|
||||||
|
3500 + Math.random() * 600 * count,
|
||||||
|
2100 + Math.random() * 200 * count,
|
||||||
|
1600 + Math.random() * 400 * count];
|
||||||
|
const VOLUMES = [0.0001, 0.2, 0.2, 0.0001];
|
||||||
|
|
||||||
|
const oscillator = this.audioContext.createOscillator();
|
||||||
|
oscillator.type = "sine";
|
||||||
|
const gain = this.audioContext.createGain();
|
||||||
|
oscillator.connect(gain);
|
||||||
|
gain.connect(this.audioContext.destination);
|
||||||
|
|
||||||
|
const now = this.audioContext.currentTime;
|
||||||
|
for (let i = 0; i < TIMES.length; i++) {
|
||||||
|
const time = TIMES[i] + now;
|
||||||
|
if (i === 0) {
|
||||||
|
oscillator.frequency.setValueAtTime(FREQUENCIES[i], time);
|
||||||
|
gain.gain.setValueAtTime(VOLUMES[i], time);
|
||||||
|
} else {
|
||||||
|
oscillator.frequency.exponentialRampToValueAtTime(FREQUENCIES[i], time);
|
||||||
|
gain.gain.exponentialRampToValueAtTime(VOLUMES[i], time);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
oscillator.start(now);
|
||||||
|
oscillator.stop(now + TIMES[TIMES.length - 1]);
|
||||||
|
}, i * 120);
|
||||||
}
|
}
|
||||||
|
|
||||||
const TIMES = [0, 0.06, 0.10, 0.15];
|
|
||||||
const FREQUENCIES = [2200,
|
|
||||||
3500 + Math.random() * 600,
|
|
||||||
2100 + Math.random() * 200,
|
|
||||||
1600 + Math.random() * 400];
|
|
||||||
const VOLUMES = [0.0001, 0.2, 0.2, 0.0001];
|
|
||||||
|
|
||||||
const oscillator = this.audioContext.createOscillator();
|
|
||||||
oscillator.type = "sine";
|
|
||||||
const gain = this.audioContext.createGain();
|
|
||||||
oscillator.connect(gain);
|
|
||||||
gain.connect(this.audioContext.destination);
|
|
||||||
|
|
||||||
const now = this.audioContext.currentTime;
|
|
||||||
for (let i = 0; i < TIMES.length; i++) {
|
|
||||||
const time = TIMES[i] + now;
|
|
||||||
if (i === 0) {
|
|
||||||
oscillator.frequency.setValueAtTime(FREQUENCIES[i], time);
|
|
||||||
gain.gain.setValueAtTime(VOLUMES[i], time);
|
|
||||||
} else {
|
|
||||||
oscillator.frequency.exponentialRampToValueAtTime(FREQUENCIES[i], time);
|
|
||||||
gain.gain.exponentialRampToValueAtTime(VOLUMES[i], time);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
oscillator.start(now);
|
|
||||||
oscillator.stop(now + TIMES[TIMES.length - 1]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user