Browse Source

feat: Add basic AudioHandler/Helpers

master
Denis Thiessen 6 months ago
parent
commit
5bb794bc8a
  1. 33
      src/core/audio/AudioHandler.jsx
  2. 26
      src/core/audio/ChordHelper.jsx

33
src/core/audio/AudioHandler.jsx

@ -0,0 +1,33 @@
import {Component} from 'react';
import * as Tone from "tone";
export default class AudioHandler extends Component {
playTabEarconSonification() {
}
playTabModelSonification() {
}
playDetailEarconSonification() {
}
playDetailModelSonification() {
}
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);
}
}

26
src/core/audio/ChordHelper.jsx

@ -0,0 +1,26 @@
import * as Tone from "tone";
export function buildChord(notes, octave) {
return notes.map(note => {return (note + octave);})
}
export function buildNote(note, octave) {
return (note + octave);
}
export function generateChord(rootNote, chordType) {
// Define intervals for different chord types
const chordIntervals = {
'major': [0, 4, 7],
'minor': [0, 3, 7],
'7th': [0, 4, 7, 10],
'diminished': [0, 3, 6],
'augmented': [0, 4, 8],
'sus2': [0, 2, 7],
'sus4': [0, 5, 7]
};
const intervals = chordIntervals[chordType];
return Tone.Frequency(rootNote).harmonize(intervals);
}
Loading…
Cancel
Save