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

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

*/

#include <cstring>

namespace scripts
{

//================== channelize.lua ==================
static const unsigned char temp_binary_data_2[] =
"--- MIDI Channelizer.\n"
"--\n"
"-- This is a MIDI filter which forces a specified channel on all messages. Set\n"
"-- the channel parameter to '0' to bypass the filter.\n"
"--\n"
"-- @script      channelize\n"
"-- @type        DSP\n"
"-- @license     GPL v3\n"
"-- @author      Michael Fisher\n"
"\n"
"local MidiBuffer    = require ('el.MidiBuffer')\n"
"local script        = require ('el.script')\n"
"local round         = require ('el.round')\n"
"\n"
"-- Buffer to render filtered output\n"
"local output        = MidiBuffer.new()\n"
"\n"
"local function layout()\n"
"    return {\n"
"        audio       = { 0, 0 },\n"
"        midi        = { 1, 1 },\n"
"        control     = {{\n"
"            {\n"
"                name        = \"Channel\",\n"
"                symbol      = \"channel\",\n"
"                min         = 0,\n"
"                max         = 16,\n"
"                default     = 0\n"
"            }\n"
"        }}\n"
"    }\n"
"end\n"
"\n"
"-- prepare for rendering\n"
"local function prepare()\n"
"    -- reserve 128 bytes of memory and clear the output buffer\n"
"    output:reserve (128)\n"
"    output:clear()\n"
"end\n"
"\n"
"local function process (_, m, p)\n"
"    -- Get MIDI input buffer fromt the MidiPipe\n"
"    local input = m:get (1)\n"
"\n"
"    -- Get the channel number from the parameter array, and round to integer\n"
"    local channel = round.integer (p[1])\n"
"\n"
"    -- For each input message, set the specified channel\n"
"    output:clear()\n"
"    for msg, frame in input:messages() do\n"
"        if channel > 0 and msg:channel() > 0 then\n"
"            msg:setChannel (channel)\n"
"        end\n"
"        output:insert (msg, frame)\n"
"    end\n"
"\n"
"    -- DSP scripts use replace processing, so swap in the rendered output\n"
"    input:swap (output)\n"
"end\n"
"\n"
"return {\n"
"    type        = 'DSP',\n"
"    layout      = layout,\n"
"    parameters  = parameters,\n"
"    prepare     = prepare,\n"
"    process     = process,\n"
"    release     = release\n"
"}\n"
"\n"
"-- SPDX-FileCopyrightText: Copyright (C) Kushview, LLC.\n"
"-- SPDX-License-Identifier: GPL-3.0-or-later\n";

const char* channelize_lua = (const char*) temp_binary_data_2;
}
