Denis Thiessen
6 months ago
5 changed files with 66 additions and 27 deletions
-
32package-lock.json
-
1package.json
-
3src/components/ScrollableTab.jsx
-
51src/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() { |
|
||||
pushToSonificationLog("tab_earcon"); |
|
||||
} |
|
||||
|
|
||||
playTabModelSonification() { |
|
||||
pushToSonificationLog("tab_model"); |
|
||||
} |
|
||||
|
|
||||
playDetailEarconSonification() { |
|
||||
pushToSonificationLog("detail_earcon"); |
|
||||
} |
|
||||
|
const drumSynth = new Tone.Sampler({ |
||||
|
C3: drumSample, |
||||
|
}).toDestination(); |
||||
|
|
||||
playDetailModelSonification() { |
|
||||
pushToSonificationLog("detail_model"); |
|
||||
} |
|
||||
|
|
||||
setRotation(angle) { |
|
||||
|
const setRotation = (angle) => { |
||||
Tone.Listener.forwardX.value = Math.sin(angle); |
Tone.Listener.forwardX.value = Math.sin(angle); |
||||
Tone.Listener.forwardY.value = 0; |
Tone.Listener.forwardY.value = 0; |
||||
Tone.Listener.forwardZ.value = -Math.cos(angle); |
Tone.Listener.forwardZ.value = -Math.cos(angle); |
||||
} |
|
||||
|
}; |
||||
|
|
||||
setRotationRamp(panner, angle, rampTime) { |
|
||||
|
const setRotationRamp = (panner, angle, rampTime) => { |
||||
panner.positionX.rampTo(Math.sin(angle), rampTime); |
panner.positionX.rampTo(Math.sin(angle), rampTime); |
||||
panner.positionY.rampTo(0, rampTime); |
panner.positionY.rampTo(0, rampTime); |
||||
panner.positionZ.rampTo(-Math.cos(angle), rampTime); |
panner.positionZ.rampTo(-Math.cos(angle), rampTime); |
||||
} |
|
||||
|
}; |
||||
|
|
||||
|
export function playTabEarconSonification() { |
||||
|
pushToSonificationLog("tab_earcon"); |
||||
|
} |
||||
|
|
||||
|
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"); |
||||
|
} |
||||
|
|
||||
|
export function playDetailEarconSonification() { |
||||
|
pushToSonificationLog("detail_earcon"); |
||||
|
} |
||||
|
|
||||
|
export function playDetailModelSonification() { |
||||
|
pushToSonificationLog("detail_model"); |
||||
} |
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue