Browse Source

feat: Added cooldown to sounds.

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

5
src/components/DetailElement.jsx

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

30
src/core/audio/AudioHandler.jsx

@ -18,7 +18,10 @@ const setRotationRamp = (panner, angle, rampTime) => {
panner.positionZ.rampTo(-Math.cos(angle), rampTime);
};
var offCooldown = true;
export function playTabEarconSonification() {
if (offCooldown) {
var loop = new Tone.Loop((time) => {
drumSynth.triggerAttackRelease("C3", "4n", time);
}, "4n");
@ -27,9 +30,15 @@ export function playTabEarconSonification() {
drumSynth.context.resume();
Tone.Transport.start();
pushToSonificationLog("tab_earcon");
offCooldown = false;
setTimeout(() => {
offCooldown = true;
}, 500);
}
}
export function playTabModelSonification() {
if (offCooldown) {
var loop = new Tone.Loop((time) => {
drumSynth.triggerAttackRelease("C3", "4n", time);
}, "4n");
@ -38,9 +47,15 @@ export function playTabModelSonification() {
drumSynth.context.resume();
Tone.Transport.start();
pushToSonificationLog("tab_model");
offCooldown = false;
setTimeout(() => {
offCooldown = true;
}, 500);
}
}
export function playDetailEarconSonification() {
export function playDetailEarconSonification(textDensity, linkDensity) {
if (offCooldown) {
var loop = new Tone.Loop((time) => {
drumSynth.triggerAttackRelease("C3", "4n", time);
}, "4n");
@ -49,9 +64,15 @@ export function playDetailEarconSonification() {
drumSynth.context.resume();
Tone.Transport.start();
pushToSonificationLog("detail_earcon");
offCooldown = false;
setTimeout(() => {
offCooldown = true;
}, 500);
}
}
export function playDetailModelSonification() {
export function playDetailModelSonification(textDensity, linkDensity) {
if (offCooldown) {
var loop = new Tone.Loop((time) => {
drumSynth.triggerAttackRelease("C3", "4n", time);
}, "4n");
@ -60,4 +81,9 @@ export function playDetailModelSonification() {
drumSynth.context.resume();
Tone.Transport.start();
pushToSonificationLog("detail_model");
offCooldown = false;
setTimeout(() => {
offCooldown = true;
}, 500);
}
}
Loading…
Cancel
Save