Denis Thiessen
6 months ago
5 changed files with 66 additions and 27 deletions
-
32package-lock.json
-
1package.json
-
3src/components/ScrollableTab.jsx
-
47src/core/audio/AudioHandler.jsx
-
BINsrc/core/audio/samples/snare_drum.wav
@ -1,33 +1,42 @@ |
|||||
import { Component } from "react"; |
|
||||
import * as Tone from "tone"; |
import * as Tone from "tone"; |
||||
import { pushToSonificationLog } from "../log/SensorLogger"; |
import { pushToSonificationLog } from "../log/SensorLogger"; |
||||
|
import drumSample from "./samples/snare_drum.wav"; |
||||
|
|
||||
export default class AudioHandler extends Component { |
|
||||
playTabEarconSonification() { |
|
||||
|
const drumSynth = new Tone.Sampler({ |
||||
|
C3: drumSample, |
||||
|
}).toDestination(); |
||||
|
|
||||
|
const setRotation = (angle) => { |
||||
|
Tone.Listener.forwardX.value = Math.sin(angle); |
||||
|
Tone.Listener.forwardY.value = 0; |
||||
|
Tone.Listener.forwardZ.value = -Math.cos(angle); |
||||
|
}; |
||||
|
|
||||
|
const setRotationRamp = (panner, angle, rampTime) => { |
||||
|
panner.positionX.rampTo(Math.sin(angle), rampTime); |
||||
|
panner.positionY.rampTo(0, rampTime); |
||||
|
panner.positionZ.rampTo(-Math.cos(angle), rampTime); |
||||
|
}; |
||||
|
|
||||
|
export function playTabEarconSonification() { |
||||
pushToSonificationLog("tab_earcon"); |
pushToSonificationLog("tab_earcon"); |
||||
} |
} |
||||
|
|
||||
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"); |
pushToSonificationLog("tab_model"); |
||||
} |
} |
||||
|
|
||||
playDetailEarconSonification() { |
|
||||
|
export function playDetailEarconSonification() { |
||||
pushToSonificationLog("detail_earcon"); |
pushToSonificationLog("detail_earcon"); |
||||
} |
} |
||||
|
|
||||
playDetailModelSonification() { |
|
||||
|
export function playDetailModelSonification() { |
||||
pushToSonificationLog("detail_model"); |
pushToSonificationLog("detail_model"); |
||||
} |
} |
||||
|
|
||||
setRotation(angle) { |
|
||||
Tone.Listener.forwardX.value = Math.sin(angle); |
|
||||
Tone.Listener.forwardY.value = 0; |
|
||||
Tone.Listener.forwardZ.value = -Math.cos(angle); |
|
||||
} |
|
||||
|
|
||||
setRotationRamp(panner, angle, rampTime) { |
|
||||
panner.positionX.rampTo(Math.sin(angle), rampTime); |
|
||||
panner.positionY.rampTo(0, rampTime); |
|
||||
panner.positionZ.rampTo(-Math.cos(angle), rampTime); |
|
||||
} |
|
||||
} |
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue