| @@ -55,33 +55,33 @@ function process(block) { | |||||
| */ | */ | ||||
| block.bufferSize | block.bufferSize | ||||
| /** Voltage of the input port of row `rowIndex`. Read-only. | |||||
| /** Voltage of the input port of column `i`. Read-only. | |||||
| */ | */ | ||||
| block.inputs[rowIndex][bufferIndex] // 0.0 | |||||
| block.inputs[i][bufferIndex] // 0.0 | |||||
| /** Voltage of the output port of row `rowIndex`. Writable. | |||||
| /** Voltage of the output port of column `i`. Writable. | |||||
| */ | */ | ||||
| block.outputs[rowIndex][bufferIndex] // 0.0 | |||||
| block.outputs[i][bufferIndex] // 0.0 | |||||
| /** Value of the knob of row `rowIndex`. Between 0 and 1. Read-only. | |||||
| /** Value of the knob of column `i`. Between 0 and 1. Read-only. | |||||
| */ | */ | ||||
| block.knobs[rowIndex] // 0.0 | |||||
| block.knobs[i] // 0.0 | |||||
| /** Pressed state of the switch of row `rowIndex`. Read-only. | |||||
| /** Pressed state of the switch of column `i`. Read-only. | |||||
| */ | */ | ||||
| block.switches[rowIndex] // false | |||||
| block.switches[i] // false | |||||
| /** Brightness of the RGB LED of row `rowIndex`, between 0 and 1. Writable. | |||||
| /** Brightness of the RGB LED of column `i`, between 0 and 1. Writable. | |||||
| */ | */ | ||||
| block.lights[rowIndex][0] // 0.0 (red) | |||||
| block.lights[rowIndex][1] // 0.0 (green) | |||||
| block.lights[rowIndex][2] // 0.0 (blue) | |||||
| block.lights[i][0] // 0.0 (red) | |||||
| block.lights[i][1] // 0.0 (green) | |||||
| block.lights[i][2] // 0.0 (blue) | |||||
| /** Brightness of the switch RGB LED of row `rowIndex`. Writable. | |||||
| /** Brightness of the switch RGB LED of column `i`. Writable. | |||||
| */ | */ | ||||
| block.switchLights[rowIndex][0] // 0.0 (red) | |||||
| block.switchLights[rowIndex][1] // 0.0 (green) | |||||
| block.switchLights[rowIndex][2] // 0.0 (blue) | |||||
| block.switchLights[i][0] // 0.0 (red) | |||||
| block.switchLights[i][1] // 0.0 (green) | |||||
| block.switchLights[i][2] // 0.0 (blue) | |||||
| } | } | ||||
| ``` | ``` | ||||
| @@ -0,0 +1,29 @@ | |||||
| // Simplest possible script using all variables | |||||
| // by Andrew Belt | |||||
| function process(block) { | |||||
| // Loop through each column | |||||
| for (var i = 0; i < 6; i++) { | |||||
| // Get input | |||||
| var x = block.inputs[i][0] | |||||
| // Get gain knob | |||||
| var gain = block.knobs[i] | |||||
| // Apply gain to input | |||||
| var y = x * gain | |||||
| // Set gain light (red = 0) | |||||
| block.lights[i][0] = gain | |||||
| // Check mute switch | |||||
| if (block.switches[i]) { | |||||
| // Mute output | |||||
| y = 0 | |||||
| // Enable mute light (red = 0) | |||||
| block.switchLights[i][0] = 1 | |||||
| } | |||||
| else { | |||||
| // Disable mute light | |||||
| block.switchLights[i][0] = 0 | |||||
| } | |||||
| // Set output | |||||
| block.outputs[i][0] = y | |||||
| } | |||||
| } | |||||
| @@ -33,8 +33,10 @@ function process(block) { | |||||
| for (var i = 0; i < 6; i++) { | for (var i = 0; i < 6; i++) { | ||||
| var h = (1 - i / 6 + phase) % 1 | var h = (1 - i / 6 + phase) % 1 | ||||
| var rgb = hsvToRgb(h, 1, 1) | var rgb = hsvToRgb(h, 1, 1) | ||||
| block.lights[i] = rgb | |||||
| block.switchLights[i] = rgb | |||||
| for (var c = 0; c < 3; c++) { | |||||
| block.lights[i][c] = rgb[c] | |||||
| block.switchLights[i][c] = rgb[c] | |||||
| } | |||||
| block.outputs[i][0] = Math.sin(2 * Math.PI * h) * 5 + 5 | block.outputs[i][0] = Math.sin(2 * Math.PI * h) * 5 + 5 | ||||
| } | } | ||||
| } | } | ||||
| @@ -19,7 +19,7 @@ function process(block) { | |||||
| var freq = 261.6256 * Math.pow(2, pitch) | var freq = 261.6256 * Math.pow(2, pitch) | ||||
| display("Freq: " + freq.toFixed(3) + " Hz") | display("Freq: " + freq.toFixed(3) + " Hz") | ||||
| // Set all output samples in block | |||||
| // Set all samples in output buffer | |||||
| var deltaPhase = config.frameDivider * block.sampleTime * freq | var deltaPhase = config.frameDivider * block.sampleTime * freq | ||||
| for (var i = 0; i < block.bufferSize; i++) { | for (var i = 0; i < block.bufferSize; i++) { | ||||
| // Accumulate phase | // Accumulate phase | ||||
| @@ -128,7 +128,7 @@ struct Prototype : Module { | |||||
| // Reset settings | // Reset settings | ||||
| frameDivider = 32; | frameDivider = 32; | ||||
| frame = 0; | frame = 0; | ||||
| block.bufferSize = 1; | |||||
| block = ScriptEngine::ProcessBlock(); | |||||
| bufferIndex = 0; | bufferIndex = 0; | ||||
| } | } | ||||
| @@ -250,6 +250,20 @@ struct MessageChoice : LedDisplayChoice { | |||||
| void step() override { | void step() override { | ||||
| text = module ? module->message : ""; | text = module ? module->message : ""; | ||||
| } | } | ||||
| void draw(const DrawArgs& args) override { | |||||
| nvgScissor(args.vg, RECT_ARGS(args.clipBox)); | |||||
| if (font->handle >= 0) { | |||||
| nvgFillColor(args.vg, color); | |||||
| nvgFontFaceId(args.vg, font->handle); | |||||
| nvgTextLetterSpacing(args.vg, 0.0); | |||||
| nvgTextLineHeight(args.vg, 1.08); | |||||
| nvgFontSize(args.vg, 12); | |||||
| nvgTextBox(args.vg, textOffset.x, textOffset.y, box.size.x - textOffset.x, text.c_str(), NULL); | |||||
| } | |||||
| nvgResetScissor(args.vg); | |||||
| } | |||||
| }; | }; | ||||
| @@ -272,6 +286,7 @@ struct PrototypeDisplay : LedDisplay { | |||||
| MessageChoice* messageChoice = new MessageChoice; | MessageChoice* messageChoice = new MessageChoice; | ||||
| messageChoice->box.pos = fileChoice->box.getBottomLeft(); | messageChoice->box.pos = fileChoice->box.getBottomLeft(); | ||||
| messageChoice->box.size.x = box.size.x; | messageChoice->box.size.x = box.size.x; | ||||
| messageChoice->box.size.y = box.size.y - messageChoice->box.pos.y; | |||||
| messageChoice->module = module; | messageChoice->module = module; | ||||
| addChild(messageChoice); | addChild(messageChoice); | ||||
| } | } | ||||