Skip to content

Commit

Permalink
2.11.5
Browse files Browse the repository at this point in the history
  • Loading branch information
quinton-ashley committed Nov 28, 2024
1 parent 165427e commit 4a7319d
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@q5/q5",
"version": "2.11.3",
"version": "2.11.5",
"license": "LGPL-3.0",
"description": "A sequel to p5.js that's optimized for interactive art",
"author": "quinton-ashley",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "q5",
"version": "2.11.4",
"version": "2.11.5",
"description": "A sequel to p5.js that's optimized for interactive art",
"author": "quinton-ashley",
"contributors": [
Expand Down
14 changes: 9 additions & 5 deletions q5.js
Original file line number Diff line number Diff line change
Expand Up @@ -2549,7 +2549,7 @@ Q5.modules.input = ($, q) => {
let c = $.canvas;

$._startAudio = () => {
if ($.getAudioContext && $.getAudioContext()?.state == 'suspended') $.userStartAudio();
if (!Q5.aud || Q5.aud?.state == 'suspended') $.userStartAudio();
};

$._updateMouse = (e) => {
Expand Down Expand Up @@ -3140,10 +3140,12 @@ Q5.modules.sound = ($, q) => {
let s = new Q5.Sound(path, cb);
s.crossOrigin = 'Anonymous';
s.addEventListener('canplaythrough', () => {
q._preloadCount--;
s.loaded = true;
if (Q5.aud) s.init();
if (cb) cb(s);
if (!s.loaded) {
q._preloadCount--;
s.loaded = true;
if (Q5.aud) s.init();
if (cb) cb(s);
}
});
sounds.push(s);
return s;
Expand All @@ -3166,10 +3168,12 @@ if (window.Audio) {
s.source = Q5.aud.createMediaElementSource(s);
s.source.connect(s.panner);
s.panner.connect(Q5.aud.destination);
let pan = s.pan;
Object.defineProperty(s, 'pan', {
get: () => s.panner.pan.value,
set: (v) => (s.panner.pan.value = v)
});
if (pan) s.pan = pan;
}
setVolume(level) {
this.volume = level;
Expand Down
2 changes: 1 addition & 1 deletion q5.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/q5-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Q5.modules.input = ($, q) => {
let c = $.canvas;

$._startAudio = () => {
if ($.getAudioContext && $.getAudioContext()?.state == 'suspended') $.userStartAudio();
if (!Q5.aud || Q5.aud?.state == 'suspended') $.userStartAudio();
};

$._updateMouse = (e) => {
Expand Down
12 changes: 8 additions & 4 deletions src/q5-sound.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ Q5.modules.sound = ($, q) => {
let s = new Q5.Sound(path, cb);
s.crossOrigin = 'Anonymous';
s.addEventListener('canplaythrough', () => {
q._preloadCount--;
s.loaded = true;
if (Q5.aud) s.init();
if (cb) cb(s);
if (!s.loaded) {
q._preloadCount--;
s.loaded = true;
if (Q5.aud) s.init();
if (cb) cb(s);
}
});
sounds.push(s);
return s;
Expand All @@ -34,10 +36,12 @@ if (window.Audio) {
s.source = Q5.aud.createMediaElementSource(s);
s.source.connect(s.panner);
s.panner.connect(Q5.aud.destination);
let pan = s.pan;
Object.defineProperty(s, 'pan', {
get: () => s.panner.pan.value,
set: (v) => (s.panner.pan.value = v)
});
if (pan) s.pan = pan;
}
setVolume(level) {
this.volume = level;
Expand Down

0 comments on commit 4a7319d

Please sign in to comment.