Skip to content

Commit

Permalink
feat: 8 voices, sampler is off for now
Browse files Browse the repository at this point in the history
  • Loading branch information
davay42 committed Nov 14, 2024
1 parent 4254b27 commit c44ebf1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
13 changes: 9 additions & 4 deletions composables/useMidi.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { WebMidi } from "webmidi";
import { reactive, onMounted, shallowReactive } from 'vue';
import { reactive, onMounted, shallowReactive, computed } from 'vue';
import { Midi } from "tonal";
import { Chord } from "tonal";

const inputs = shallowReactive({})
const outputs = shallowReactive({})
Expand All @@ -22,6 +24,11 @@ const activeNotes = reactive({})

const midiLog = shallowReactive([])

export const guessChords = computed(() => {
const list = Object.entries(activeNotes).filter(([_, v]) => v).map(([n]) => Midi.midiToNoteName(Number(n), { sharps: true }));
return Chord.detect(list)
})

export function useMidi() {
onMounted(() => {
if (midi.enabled || midi.enabled === null) return
Expand All @@ -38,7 +45,7 @@ export function useMidi() {
})
}).catch(e => midi.enabled = null)
})
return { midi, inputs, outputs, WebMidi, midiLog, midiNote, activeNotes }
return { midi, inputs, outputs, WebMidi, midiLog, midiNote, activeNotes, guessChords }
}


Expand Down Expand Up @@ -92,5 +99,3 @@ function initMidi() {
})
}



1 change: 1 addition & 0 deletions elements/_sampler.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { midiFrequency } from "./index";
import { el } from "@elemaudio/core";

// TODO: Find a way to embed the initial piano sample into html so this works at local file://:/index.html

export const params = {
on: { value: 1, min: 0, max: 1, step: 1, hidden: true, },
Expand Down

0 comments on commit c44ebf1

Please sign in to comment.