mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-11 10:49:59 +01:00
* Add wasm code * First working model * Add PixelManipulation web assembly code to browser and node * Tests corrected for modules * Corrected test script * Add wasm bechmarks * Update Readme * Applies toggling functionality and refactored PixelManipulation code * Added documentation and corrected wasm toggling * change noise reduction module to use wasm code * Corrected formatting and removed extra comments * Add default wasm option and made README changes * Fixed negative test timings * combined benchmarks file * Update benchmark.js * Removed copies of wasm file and corrected test format * Update package.json Co-Authored-By: Jeffrey Warren <jeff@unterbahn.com> * Added wasm file and removed redundant code * Removed earlier benchmarks * move test/core/sequencer/benchmark.js to its own test command, not passing to tape-spec * Solves memory leaks and blank lines * Solves memory leaks and blank lines * Added handler for node code * Modify test script * Modify test script * Correct doc and removed pace fuctionality
68 lines
1.9 KiB
JavaScript
68 lines
1.9 KiB
JavaScript
const getStepUtils = require('./util/getStep.js');
|
|
|
|
// insert one or more steps at a given index in the sequencer
|
|
function InsertStep(ref, index, name, o) {
|
|
if (ref.sequences[name]) {
|
|
return ref.importJSON(ref.sequences[name]);
|
|
}
|
|
|
|
if (ref.detectStringSyntax(name)) {
|
|
return ref.stringToSteps(name);
|
|
}
|
|
|
|
function insertStep(index, name, o_) {
|
|
if (ref.modules[name]) var moduleInfo = ref.modules[name][1];
|
|
else {
|
|
console.log('Module ' + name + ' not found.');
|
|
}
|
|
|
|
var o = ref.copy(o_);
|
|
|
|
o.number = ref.options.sequencerCounter++; //Gives a Unique ID to each step
|
|
o.name = o_.name || name || moduleInfo.name;
|
|
o.description = o_.description || moduleInfo.description;
|
|
o.moduleInfo = o_.moduleInfo || moduleInfo;
|
|
o.selector = o_.selector || 'ismod-' + name;
|
|
o.container = o_.container || ref.options.selector;
|
|
o.inBrowser = ref.options.inBrowser;
|
|
o.useWasm = (ref.options.useWasm === false) ? false : true;
|
|
if (index == -1) index = ref.steps.length;
|
|
|
|
o.step = {
|
|
name: o.name,
|
|
description: o.description,
|
|
moduleInfo: o.moduleInfo,
|
|
ID: o.number,
|
|
inBrowser: ref.options.inBrowser,
|
|
ui: ref.options.ui,
|
|
options: o
|
|
};
|
|
var UI = ref.events;
|
|
|
|
// define the expandSteps function for sequencer
|
|
ref.modules[name].expandSteps = function expandSteps(stepsArray) {
|
|
for (var i in stepsArray) {
|
|
let step = stepsArray[i];
|
|
ref.insertSteps(index + Number.parseInt(i), step['name'], step['options']);
|
|
}
|
|
};
|
|
|
|
// Tell UI that a step has been set up.
|
|
o = o || {};
|
|
|
|
if (!ref.modules[name][1].length) {
|
|
UI.onSetup(o.step, { index: index });
|
|
ref.steps.splice(index, 0, ref.modules[name][0](o, UI));
|
|
} else {
|
|
ref.modules[name][0](o, UI);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
insertStep(index, name, o);
|
|
ref.steps = ref.steps;
|
|
|
|
}
|
|
module.exports = InsertStep;
|