From 34df2ca203ea934537edb490b8cb632cee650f65 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 7 Jun 2018 20:41:34 +0200 Subject: send as png --- app/client/live/player.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'app/client/live') 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) -- cgit v1.2.3-70-g09d2