Browse Source

feat: Added final sonification effect.

master
Denis Thiessen 4 months ago
parent
commit
dce0f4e052
  1. 33
      src/core/audio/AudioHandler.jsx

33
src/core/audio/AudioHandler.jsx

@ -203,21 +203,34 @@ export function playDetailModelSonification(textDensity, linkDensity) {
if (offCooldown) { if (offCooldown) {
const synth = drumSynth.toDestination(); const synth = drumSynth.toDestination();
// To circumvent a bug with reverb creation. Doesn't affect the lack of reverb though... See below.
const reverbAmount = linkDensity === 0 ? 1 : linkDensity;
const reverb = new Tone.Reverb(reverbAmount).toDestination();
reverb.wet.value = 0;
reverb.wet.rampTo(1, 0.25);
const textDensityFrequencyString = 2 * textDensity + "n"; const textDensityFrequencyString = 2 * textDensity + "n";
var loop2 = new Tone.Loop((time) => {
synth.triggerAttackRelease("C3", textDensityFrequencyString, time);
synth.triggerAttackRelease(
"C3",
textDensityFrequencyString,
time + (0.1 + 0.8 / textDensity)
);
}, "4n").start();
loop2.iterations = (linkDensity - 1) / 2 + 1;
Tone.Transport.start();
const now = Tone.now();
synth.triggerAttackRelease("C3", textDensityFrequencyString, now);
const reverbSynth = linkDensity > 0 ? drumSynth.connect(reverb) : drumSynth;
reverbSynth.triggerAttackRelease(
"C3",
textDensityFrequencyString,
now + 0.2
);
pushToSonificationLog("detail_model"); pushToSonificationLog("detail_model");
offCooldown = false; offCooldown = false;
setTimeout(() => { setTimeout(() => {
offCooldown = true; offCooldown = true;
reverb.wet.value = 0;
synth.disconnect();
reverbSynth.disconnect();
Tone.Transport.stop();
}, 500); }, 500);
} }
} }
Loading…
Cancel
Save