diff options
Diffstat (limited to 'app/client/live')
| -rw-r--r-- | app/client/live/player.js | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/app/client/live/player.js b/app/client/live/player.js index d4831e2..3fd33e8 100644 --- a/app/client/live/player.js +++ b/app/client/live/player.js @@ -1,12 +1,19 @@ import { store } from '../store' import Whammy from './whammy' import types from '../types' -import pix2wav from '../audio/pix2wav' +import * as pix2wav from '../audio/pix2wav' let fps = 0, last_frame -let recording = false, saving = false +let recording = false, saving = false, synthesizing = false let videoWriter +export function startSynthesizing(){ + synthesizing = true +} +export function stopSynthesizing(){ + synthesizing = false +} + export function startRecording(){ videoWriter = new Whammy.Video(10) recording = true @@ -46,6 +53,10 @@ export function onFrame (data) { URL.revokeObjectURL(url) const ctx = canvas.getContext('2d-lodpi') ctx.drawImage(img, 0, 0, canvas.width, canvas.height) + if (synthesizing) { + const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height) + pix2wav.play({ imageData }) + } if (recording) { console.log('record frame') videoWriter.add(canvas) |
