/* ==================================== JUCER_BINARY_RESOURCE ====================================

   This is an auto-generated file: Any edits you make may be overwritten!

*/

#include <cstring>

namespace scripts
{

//================== midicc.lua ==================
static const unsigned char temp_binary_data_7[] =
"--- MIDI CC.\n"
"--\n"
"-- Converts a normalized value (0.0 - 1.0) into a 0-127 MIDI Continuous Controller\n"
"-- value. Emits a MIDI CC message on MIDI-out and exposes the scaled value as a\n"
"-- control output. A message is only sent when the scaled value changes.\n"
"--\n"
"-- @script      midicc\n"
"-- @type        DSP\n"
"-- @license     GPL v3\n"
"-- @author      Michael Fisher\n"
"\n"
"local MidiBuffer = require ('el.MidiBuffer')\n"
"local midi       = require ('el.midi')\n"
"local round      = require ('el.round')\n"
"\n"
"local output    = MidiBuffer.new()\n"
"local lastValue = -1\n"
"\n"
"local function layout()\n"
"    return {\n"
"        audio   = { 0, 0 },\n"
"        midi    = { 0, 1 },\n"
"        control = { {\n"
"            { name = \"Value\",   symbol = \"value\",   min = 0.0, max = 1.0, default = 0.0 },\n"
"            { name = \"CC\",      symbol = \"cc\",      min = 0,   max = 127, default = 1 },\n"
"            { name = \"Channel\", symbol = \"channel\", min = 1,   max = 16,  default = 1 }\n"
"        }, {\n"
"            { name = \"Value\", symbol = \"value\", min = 0, max = 127, default = 0 }\n"
"        } }\n"
"    }\n"
"end\n"
"\n"
"local function prepare()\n"
"    output:reserve (128)\n"
"    output:clear()\n"
"end\n"
"\n"
"local function process (_, m, p, c)\n"
"    local out = m:get (1)\n"
"    output:clear()\n"
"\n"
"    local value   = round.integer (p[1] * 127)\n"
"    local cc      = round.integer (p[2])\n"
"    local channel = round.integer (p[3])\n"
"\n"
"    -- Expose the scaled value as a control output.\n"
"    c[1] = value\n"
"\n"
"    -- Only emit a message when the scaled value changes.\n"
"    if value ~= lastValue then\n"
"        output:insertPacked (midi.controller (channel, cc, value), 0)\n"
"        lastValue = value\n"
"    end\n"
"\n"
"    out:swap (output)\n"
"end\n"
"\n"
"return {\n"
"    type    = 'DSP',\n"
"    layout  = layout,\n"
"    prepare = prepare,\n"
"    process = process\n"
"}\n"
"\n"
"-- SPDX-FileCopyrightText: Copyright (C) Kushview, LLC.\n"
"-- SPDX-License-Identifier: GPL-3.0-or-later\n";

const char* midicc_lua = (const char*) temp_binary_data_7;
}
