Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions frontend/src/hooks/useSound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,13 @@ function playChord(
// Exponential decay to simulate vibraphone resonance
gainNode.gain.exponentialRampToValueAtTime(0.0001, startTime + durationSec);

for (const note of chord.notes) {
for (let i = 0; i < chord.notes.length; i++) {
const note = chord.notes[i];
const osc = ctx.createOscillator();
osc.type = chord.type;
osc.frequency.setValueAtTime(midiToHz(note), startTime);
// Slight detune per note for vibraphone width
osc.detune.setValueAtTime((chord.notes.indexOf(note) - 1) * 2, startTime);
osc.detune.setValueAtTime((i - 1) * 2, startTime);
osc.connect(gainNode);
osc.start(startTime);
osc.stop(startTime + durationSec + 0.05);
Expand Down
Loading