Browse Source

feat: Added cooldown to sounds.

master
Denis Thiessen 5 months ago
parent
commit
4e8cbad951
  1. 5
      src/components/DetailElement.jsx
  2. 94
      src/core/audio/AudioHandler.jsx

5
src/components/DetailElement.jsx

@ -113,12 +113,11 @@ const touchEvent = function (event) {
const parentCollapseElement = getParentCollapseElement(eventElement); const parentCollapseElement = getParentCollapseElement(eventElement);
const contentNode = getContainerNode(parentCollapseElement); const contentNode = getContainerNode(parentCollapseElement);
const densities = calculateDensities(contentNode); const densities = calculateDensities(contentNode);
console.log(densities);
if (type === "model") { if (type === "model") {
playDetailModelSonification();
playDetailModelSonification(densities.textDensity, densities.linkDensity);
} else if (type === "earcon") { } else if (type === "earcon") {
playDetailEarconSonification();
playDetailEarconSonification(densities.textDensity, densities.linkDensity);
} }
}; };

94
src/core/audio/AudioHandler.jsx

@ -18,46 +18,72 @@ const setRotationRamp = (panner, angle, rampTime) => {
panner.positionZ.rampTo(-Math.cos(angle), rampTime); panner.positionZ.rampTo(-Math.cos(angle), rampTime);
}; };
var offCooldown = true;
export function playTabEarconSonification() { export function playTabEarconSonification() {
var loop = new Tone.Loop((time) => {
drumSynth.triggerAttackRelease("C3", "4n", time);
}, "4n");
loop.iterations = 2;
loop.start();
drumSynth.context.resume();
Tone.Transport.start();
pushToSonificationLog("tab_earcon");
if (offCooldown) {
var loop = new Tone.Loop((time) => {
drumSynth.triggerAttackRelease("C3", "4n", time);
}, "4n");
loop.iterations = 2;
loop.start();
drumSynth.context.resume();
Tone.Transport.start();
pushToSonificationLog("tab_earcon");
offCooldown = false;
setTimeout(() => {
offCooldown = true;
}, 500);
}
} }
export function playTabModelSonification() { export function playTabModelSonification() {
var loop = new Tone.Loop((time) => {
drumSynth.triggerAttackRelease("C3", "4n", time);
}, "4n");
loop.iterations = 2;
loop.start();
drumSynth.context.resume();
Tone.Transport.start();
pushToSonificationLog("tab_model");
if (offCooldown) {
var loop = new Tone.Loop((time) => {
drumSynth.triggerAttackRelease("C3", "4n", time);
}, "4n");
loop.iterations = 2;
loop.start();
drumSynth.context.resume();
Tone.Transport.start();
pushToSonificationLog("tab_model");
offCooldown = false;
setTimeout(() => {
offCooldown = true;
}, 500);
}
} }
export function playDetailEarconSonification() {
var loop = new Tone.Loop((time) => {
drumSynth.triggerAttackRelease("C3", "4n", time);
}, "4n");
loop.iterations = 2;
loop.start();
drumSynth.context.resume();
Tone.Transport.start();
pushToSonificationLog("detail_earcon");
export function playDetailEarconSonification(textDensity, linkDensity) {
if (offCooldown) {
var loop = new Tone.Loop((time) => {
drumSynth.triggerAttackRelease("C3", "4n", time);
}, "4n");
loop.iterations = 2;
loop.start();
drumSynth.context.resume();
Tone.Transport.start();
pushToSonificationLog("detail_earcon");
offCooldown = false;
setTimeout(() => {
offCooldown = true;
}, 500);
}
} }
export function playDetailModelSonification() {
var loop = new Tone.Loop((time) => {
drumSynth.triggerAttackRelease("C3", "4n", time);
}, "4n");
loop.iterations = 2;
loop.start();
drumSynth.context.resume();
Tone.Transport.start();
pushToSonificationLog("detail_model");
export function playDetailModelSonification(textDensity, linkDensity) {
if (offCooldown) {
var loop = new Tone.Loop((time) => {
drumSynth.triggerAttackRelease("C3", "4n", time);
}, "4n");
loop.iterations = 2;
loop.start();
drumSynth.context.resume();
Tone.Transport.start();
pushToSonificationLog("detail_model");
offCooldown = false;
setTimeout(() => {
offCooldown = true;
}, 500);
}
} }
Loading…
Cancel
Save