-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsynth.js
More file actions
27 lines (25 loc) · 801 Bytes
/
synth.js
File metadata and controls
27 lines (25 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import {
GestureRecognizer,
DrawingUtils,
PoseLandmarker
} from '@mediapipe/tasks-vision';
import * as core from '@magenta/music/es6/core.js';
import * as poseDetection from '@tensorflow-models/pose-detection';
import * as tf from '@tensorflow/tfjs-core';
import * as Tone from 'tone';
const player = new core.Player();
const worker = new Worker('/worker.js');
document.getElementById("playButton").addEventListener("click", () => {
worker.postMessage({"sequence": []});
worker.onmessage = async (event) => {
if (event.data.fyi) {
console.log(event.data.fyi);
} else {
const sample = event.data.sample;
console.log("Sampel", sample);
await player.start(sample, tempo);
worker.postMessage({});
// Do something with this sample
}
};
})