diff options
Diffstat (limited to 'app')
| -rw-r--r-- | app/client/audio/lib/_draw.js | 139 | ||||
| -rw-r--r-- | app/client/audio/lib/draw.js | 4 | ||||
| -rw-r--r-- | app/client/audio/wav2pix.js | 2 | ||||
| -rw-r--r-- | app/client/dataset/dataset.component.js | 2 | ||||
| -rw-r--r-- | app/client/dataset/dataset.new.js | 7 | ||||
| -rw-r--r-- | app/client/modules/pix2pix/index.js | 1 | ||||
| -rw-r--r-- | app/client/modules/pix2wav/index.js | 3 | ||||
| -rw-r--r-- | app/client/modules/pix2wav/pix2wav.reducer.js | 31 | ||||
| -rw-r--r-- | app/client/modules/pix2wav/views/pix2wav.show.js | 8 |
9 files changed, 14 insertions, 183 deletions
diff --git a/app/client/audio/lib/_draw.js b/app/client/audio/lib/_draw.js deleted file mode 100644 index 974fa62..0000000 --- a/app/client/audio/lib/_draw.js +++ /dev/null @@ -1,139 +0,0 @@ -import { - browser, requestAudioContext, - randint, randrange, clamp, mod, -} from './lib/util' - -import './lib/vendor/hidpi-canvas' - -import mouse from './lib/mouse' -import color from './lib/color' - -let w, h -let rx, ry - -const pixels_per_second = 512 // 1024 - -const canvas = document.createElement('canvas') -// document.body.appendChild(canvas) -// document.body.addEventListener('resize', resize) -resize() -recenter() -requestAnimationFrame(animate) - -// must request context after resizing -const ctx = canvas.getContext('2d') - -const scratch = document.createElement('canvas') -const scratchCtx = scratch.getContext('2d-lodpi') - -function resize(ww, hh){ - w = canvas.width = ww || window.innerWidth - h = canvas.height = hh || window.innerHeight - canvas.style.width = w + 'px' - canvas.style.height = h + 'px' -} -function recenter(){ - rx = randint(w), ry = randint(h) -} -let frame = null -function onFrame(fn){ - frame = fn -} -function animate(t){ - requestAnimationFrame(animate) - if (frame) { - frame(t) - frame = null - } - // ctx.save() - // ctx.globalAlpha = 0.0001 - // ctx.translate(w/2, h/2) - // ctx.rotate(0.1) - // ctx.translate(-rx, -ry) - // ctx.drawImage(canvas, 0, 0) - // ctx.restore() -} -function clear(n, x, y, ww, hh){ - ctx.fillStyle = 'rgba(255,255,255,' + (n || 0.9) + ')' - ctx.fillRect(x || 0, y || 0, ww || w, hh || h) - recenter() -} -function triangle(px,py,r){ - setTimeout( () => tri(px,py,r), Math.random()*10) - // setTimeout( () => tri(px,py,r), Math.random()*200) - // setTimeout( () => tri(px,py,r), Math.random()*300) -} -function tri(px, py, r) { - ctx.save() - ctx.globalCompositeOperation = 'multiply' - ctx.fillStyle = color.color((px+py)/(w+h), 0, 1, 0.2) - function p(){ - let theta = randrange(0, Math.PI*2) - let x = px + Math.cos(theta) * r - let y = py + Math.sin(theta) * r - return { x, y } - } - ctx.beginPath() - const p0 = p(), p1 = p(), p2 = p() - ctx.moveTo(p0.x, p0.y) - ctx.lineTo(p1.x, p1.y) - ctx.lineTo(p2.x, p2.y) - ctx.lineTo(p0.x, p0.y) - ctx.fill() - ctx.restore() -} -function line(y){ - ctx.beginPath() - ctx.moveTo(0, y) - ctx.lineTo(w, y) - ctx.strokeStyle = "#888" - ctx.strokeWidth = 1 - ctx.stroke() -} -function dot(x, y, r){ - ctx.fillStyle = "#f00" - ctx.beginPath() - ctx.moveTo(x, y) - ctx.arc(x, y, r, 0, 2*Math.PI) - ctx.fill() -} -function waveform(pcm, sr, pos, zoom){ - sr = sr || 44100 - pos = pos || 0 - - var width = w - var height = Math.floor(h/4) - var half_height = Math.floor(height/2) - var x0 = 0 - var y0 = 20 - var ymid = y0 + half_height - var max_width_in_seconds = width / pixels_per_second - var max_width_in_samples = max_width_in_seconds * sr - var pcm_length = pcm.length - var len = Math.min(pcm_length, max_width_in_samples) - var pcm_step = sr / pixels_per_second - var i - ctx.save() - - clear(1, x0, y0, width, height) - - line(ymid) - ctx.beginPath() - for (i = 0; i < width; i += 0.5) { - var si = Math.floor(pcm_step * i + pos) - if (si > pcm_length) break - var val = pcm[si] // -1, 1 - // ctx.moveTo(x0 + i, ymid) - ctx.lineTo(x0 + i, ymid + val * half_height) - } - ctx.strokeStyle = "rgba(250,20,0,0.9)" - ctx.strokeWidth = 1 - ctx.stroke() - ctx.restore() -} - -export default { - canvas, ctx, onFrame, resize, - triangle, clear, line, dot, - waveform, spectrum, raw_spectrum, -}
\ No newline at end of file diff --git a/app/client/audio/lib/draw.js b/app/client/audio/lib/draw.js index f5ba3ac..e523b6a 100644 --- a/app/client/audio/lib/draw.js +++ b/app/client/audio/lib/draw.js @@ -1,7 +1,7 @@ const scratch = document.createElement('canvas') const scratchCtx = scratch.getContext('2d-lodpi') -function spectrum(spec, x0, y0, ww, hh){ +export function spectrum(spec, x0, y0, ww, hh){ const data = spec.data const fft_size = spec.fft_size const half_fft_size = spec.fft_size / 2 @@ -56,7 +56,7 @@ function spectrum(spec, x0, y0, ww, hh){ ctx.restore() } -function raw_spectrum(spec, x0, y0, ww, hh, def_min_r, def_min_i){ +export function raw_spectrum(spec, x0, y0, ww, hh, def_min_r, def_min_i){ const data = spec.data const fft_size = spec.fft_size const half_fft_size = spec.fft_size / 2 diff --git a/app/client/audio/wav2pix.js b/app/client/audio/wav2pix.js index 089816d..e0a10fd 100644 --- a/app/client/audio/wav2pix.js +++ b/app/client/audio/wav2pix.js @@ -2,7 +2,7 @@ import Tone from 'tone' import JSZip from 'jszip' import FileSaver from 'file-saver' -import draw from './lib/draw' +import * as draw from './lib/draw' import output from './lib/output' import spectrum from './lib/spectrum' diff --git a/app/client/dataset/dataset.component.js b/app/client/dataset/dataset.component.js index af734ad..12f7987 100644 --- a/app/client/dataset/dataset.component.js +++ b/app/client/dataset/dataset.component.js @@ -5,8 +5,6 @@ import util from '../util' import actions from '../actions' -import DatasetForm from './dataset.form' -import NewDatasetForm from './dataset.new' import { FileList, FileRow } from '../common/fileList.component' import Loading from '../common/loading.component' diff --git a/app/client/dataset/dataset.new.js b/app/client/dataset/dataset.new.js index 617aa90..bc169c7 100644 --- a/app/client/dataset/dataset.new.js +++ b/app/client/dataset/dataset.new.js @@ -10,7 +10,7 @@ import TextInput from '../common/textInput.component' function NewDatasetForm (props) { const { loading, status, error, history, actions, module } = props if (loading) return <Loading /> - console.log(props) + console.log(props) return ( <div class='opaque'> <div class='heading'> @@ -32,10 +32,7 @@ function NewDatasetForm (props) { ) } -const mapStateToProps = state => { - console.log(state); - return state.dataset -} +const mapStateToProps = state => state const mapDispatchToProps = (dispatch, ownProps) => ({ actions: bindActionCreators(datasetActions, dispatch), diff --git a/app/client/modules/pix2pix/index.js b/app/client/modules/pix2pix/index.js index 9e3d466..c45ea3e 100644 --- a/app/client/modules/pix2pix/index.js +++ b/app/client/modules/pix2pix/index.js @@ -23,6 +23,7 @@ function links(){ return ( <span> <span><Link to="/pix2pix/datasets/">datasets</Link></span> + <span>Process</span> <span><Link to="/pix2pix/live/">live</Link></span> </span> ) diff --git a/app/client/modules/pix2wav/index.js b/app/client/modules/pix2wav/index.js index 9071d04..a77448c 100644 --- a/app/client/modules/pix2wav/index.js +++ b/app/client/modules/pix2wav/index.js @@ -20,7 +20,8 @@ function router () { function links(){ return ( <span> - <span>datasets</span> + <span><Link to="/pix2wav/datasets/">datasets</Link></span> + <span><Link to="/pix2wav/live/">live</Link></span> </span> ) } diff --git a/app/client/modules/pix2wav/pix2wav.reducer.js b/app/client/modules/pix2wav/pix2wav.reducer.js index 6d6548a..0b55b07 100644 --- a/app/client/modules/pix2wav/pix2wav.reducer.js +++ b/app/client/modules/pix2wav/pix2wav.reducer.js @@ -1,39 +1,20 @@ import types from '../../types' +import datasetReducer from '../../dataset/dataset.reducer' const pix2wavInitialState = { loading: true, + progress: { i: 0, n: 0 }, error: null, - folders: [], folder_id: 0, data: null, - lossReport: null, } const pix2wavReducer = (state = pix2wavInitialState, action) => { - // console.log(action.type) - switch(action.type) { - case types.pix2wav.init: - return { - ...state, - loading: false, - data: action.data, - } - - case types.socket.connect: - return { - ...state, - } - - case types.task.task_begin: - return { - ...state, - } - - case types.task.task_finish: - return { - ...state, - } + if (action.data && action.data.module === 'pix2wav') { + state = datasetReducer(state, action) + } + switch (action.type) { default: return state } diff --git a/app/client/modules/pix2wav/views/pix2wav.show.js b/app/client/modules/pix2wav/views/pix2wav.show.js index 46a2436..acb99b1 100644 --- a/app/client/modules/pix2wav/views/pix2wav.show.js +++ b/app/client/modules/pix2wav/views/pix2wav.show.js @@ -46,14 +46,6 @@ class Pix2wavShow extends Component { <UploadStatus /> </div> </div> - {folder && folder.name && folder.name !== 'unsorted' && - <DatasetForm - title='Add Files' - module={pix2wavModule} - folder={folder} - canUpload canAddURL - /> - } <DatasetComponent loading={pix2wav.loading} progress={pix2wav.progress} |
