diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-06-06 16:30:49 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-06-06 16:30:49 +0200 |
| commit | 31fbca46a82a33bd8038f2d40722e9e0ffc61253 (patch) | |
| tree | c77e362e50f9656ff4e47df453ca042a3d97acd5 /public/bundle.js | |
| parent | 1ba1d455167bfd507d3cf14d43fbd430caeb7fe7 (diff) | |
starting frame offset
Diffstat (limited to 'public/bundle.js')
| -rw-r--r-- | public/bundle.js | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/public/bundle.js b/public/bundle.js index 0de966e..51c7bbe 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -1764,6 +1764,8 @@ var loadPCM = exports.loadPCM = function loadPCM(file) { var renderFrames = exports.renderFrames = function renderFrames(file, _ref) { var _ref$frame_step = _ref.frame_step, frame_step = _ref$frame_step === undefined ? FRAME_STEP : _ref$frame_step, + _ref$frame_start = _ref.frame_start, + frame_start = _ref$frame_start === undefined ? 0 : _ref$frame_start, _ref$max = _ref.max, max = _ref$max === undefined ? 12 : _ref$max; return function (dispatch) { @@ -1778,7 +1780,7 @@ var renderFrames = exports.renderFrames = function renderFrames(file, _ref) { var frames = []; var count = 0; var _len = pcm.length - FRAME_LENGTH; - var offset = _len / 4; + var offset = Math.round(_len * frame_start); for (; offset < _len && count < max; offset += frame_step, count += 1) { frames.push(render(pcm.slice(offset, offset + FRAME_LENGTH), sr, count)); } @@ -1792,6 +1794,8 @@ var renderFrames = exports.renderFrames = function renderFrames(file, _ref) { var buildZip = exports.buildZip = function buildZip(name, file, _ref2) { var _ref2$frame_step = _ref2.frame_step, frame_step = _ref2$frame_step === undefined ? FRAME_STEP : _ref2$frame_step, + _ref2$frame_start = _ref2.frame_start, + frame_start = _ref2$frame_start === undefined ? 0 : _ref2$frame_start, _ref2$max = _ref2.max, max = _ref2$max === undefined ? 10000 : _ref2$max; return function (dispatch) { @@ -1809,12 +1813,12 @@ var buildZip = exports.buildZip = function buildZip(name, file, _ref2) { var steps = (pcm.length - FRAME_LENGTH) / frame_step; console.log(steps); - var offset = 0, - count = 0, - _len = pcm.length - FRAME_LENGTH; + var count = 0; + var _len = pcm.length - FRAME_LENGTH; + var offset = Math.round(_len * frame_start); for (; offset < _len && count < max; offset += frame_step, count += 1) { if (count % 10 === 0) { - dispatch({ type: _types2.default.wav2pix.progress, progress: { i: count / steps * 6, n: 6 } }); + dispatch({ type: _types2.default.wav2pix.progress, progress: { i: count / max * 6, n: 6 } }); } render(pcm.slice(offset, offset + FRAME_LENGTH), sr, count, zip_folder); } @@ -7746,6 +7750,7 @@ var SpectrogramUpload = function (_Component) { pcm: null, name: "", frames: [], + frame_start: 0, max: 3000, frame_step: wav2pixActions.FRAME_STEP }; @@ -7784,9 +7789,10 @@ var SpectrogramUpload = function (_Component) { var _state = this.state, file = _state.file, pcm = _state.pcm, - frame_step = _state.frame_step; + frame_step = _state.frame_step, + frame_start = _state.frame_start; - this.props.wav2pix.renderFrames(pcm || file, { frame_step: frame_step }).then(function (data) { + this.props.wav2pix.renderFrames(pcm || file, { frame_start: frame_start, frame_step: frame_step }).then(function (data) { console.log('got frames', data.frames.length); _this3.setState(_extends({}, _this3.state, { frames: data.frames, @@ -7803,14 +7809,15 @@ var SpectrogramUpload = function (_Component) { pcm = _state2.pcm, file = _state2.file, max = _state2.max, - frame_step = _state2.frame_step; + frame_step = _state2.frame_step, + frame_start = _state2.frame_start; - this.props.wav2pix.buildZip(this.state.name, pcm || file, { frame_step: frame_step, max: max }).then(function (_ref) { + this.props.wav2pix.buildZip(this.state.name, pcm || file, { frame_start: frame_start, frame_step: frame_step, max: max }).then(function (_ref) { var zip = _ref.zip, filename = _ref.filename, count = _ref.count; - _this4.props.datasetActions.uploadFile(_this4.props.module, _this4.props.folder, zip, filename, { count: count, max: max, frame_step: frame_step }); + _this4.props.datasetActions.uploadFile(_this4.props.module, _this4.props.folder, zip, filename, { count: count, max: max, frame_step: frame_step, frame_size: wav2pixActions.FRAME_LENGTH / 44100 }); }); } }, { @@ -7918,6 +7925,7 @@ var SpectrogramUpload = function (_Component) { { title: 'Duration' }, Math.floor(duration) + ' s.' ), + (0, _preact.h)('br', null), (0, _preact.h)( _common.Param, { title: 'Frames' }, @@ -7957,6 +7965,17 @@ var SpectrogramUpload = function (_Component) { value: this.state.name }), (0, _preact.h)(_common.Slider, { + name: 'Starting Frame', + min: 0, max: 1, type: 'float', + value: this.state.frame_start, + defaultValue: 0, + onChange: function onChange(frame_start) { + _this6.setState({ frame_start: frame_start }, function () { + _this6.rebuildFrames(); + }); + } + }), + (0, _preact.h)(_common.Slider, { name: 'No. Frames', min: 10, max: Math.min(total_frame_count, 1000), type: 'int', value: this.state.max, |
