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

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

*/

#include <cstring>

namespace scripts
{

//================== spontonchordchooser.lua ==================
static const unsigned char temp_binary_data_6[] =
"--- Spoton Scale Chooser\n"
"--\n"
"-- Configures chord configurations for Spoton using MIDI CC\n"
"--\n"
"-- @script      spontonchordchooser\n"
"-- @type        DSP\n"
"-- @license     GPL v3\n"
"-- @author      Lokki\n"
"\n"
"local round   = require('el.round')\n"
"\n"
"-- variables for scales\n"
"local scl_idx\n"
"local root_note\n"
"--current scale in use\n"
"local scl_cur = { 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 }\n"
"--all scales that you want to set\n"
"local scl_maj = { 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1 } --major\n"
"local scl_min = { 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0 } --minor\n"
"local scl_pma = { 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0 } --major penta\n"
"local scl_pmi = { 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0 } --minor penta\n"
"local scl_mix = { 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0 } --mixolydian\n"
"local scl_hmi = { 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1 } --harmonic minor\n"
"local scl_dor = { 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0 } --dorian\n"
"local scl_phr = { 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0 } --phrygian\n"
"local scl_chr = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } --chromatic\n"
"local scl_lyd = { 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1 } --lydian\n"
"local scl_wht = { 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 } --wholetone\n"
"local scl_dip = { 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0 } --diminished halfstep lower\n"
"local scl_din = { 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1 } --diminished halfstep higher\n"
"local scl_bmi = { 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0 } --bluesscale (minor)\n"
"local scl_bma = { 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0 } --blues major\n"
"local scl_alt = { 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0 } --altered\n"
"local scl_hma = { 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0 } --hm5\n"
"local scl_aug = { 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 } --augemted\n"
"\n"
"--table of all scales for easy recalling\n"
"local scl_all = {\n"
"    scl_maj, scl_min, scl_pma, scl_pmi, scl_mix, scl_hmi,\n"
"    scl_dor, scl_phr, scl_chr, scl_lyd, scl_wht, scl_dip,\n"
"    scl_din, scl_bmi, scl_bma, scl_alt, scl_hma, scl_aug\n"
"}\n"
"\n"
"local function layout()\n"
"    return {\n"
"        audio   = { 0, 0 },\n"
"        midi    = { 1, 0 },\n"
"        control = { {\n"
"            {\n"
"                name    = \"CC_Scale\",\n"
"                symbol  = \"scale\",\n"
"                min     = 0,\n"
"                max     = 127,\n"
"                default = 14\n"
"            },\n"
"            {\n"
"                name    = \"CC_Root\",\n"
"                symbol  = \"root\",\n"
"                min     = 0,\n"
"                max     = 127,\n"
"                default = 6\n"
"            },\n"
"            {\n"
"                name    = \"CC_Bypass\",\n"
"                symbol  = \"bypass\",\n"
"                min     = 0,\n"
"                max     = 127,\n"
"                default = 90\n"
"            }\n"
"        }, {\n"
"            {\n"
"                name   = \"C\",\n"
"                symbol = \"c_state\",\n"
"                min    = 0,\n"
"                max    = 1,\n"
"\n"
"            },\n"
"            {\n"
"                name   = \"C#\",\n"
"                symbol = \"cis_state\",\n"
"                min    = 0,\n"
"                max    = 1,\n"
"\n"
"            },\n"
"            {\n"
"                name   = \"D\",\n"
"                symbol = \"d_state\",\n"
"                min    = 0,\n"
"                max    = 1,\n"
"\n"
"            },\n"
"            {\n"
"                name   = \"D#\",\n"
"                symbol = \"dis_state\",\n"
"                min    = 0,\n"
"                max    = 1,\n"
"\n"
"            },\n"
"            {\n"
"                name   = \"E\",\n"
"                symbol = \"e_state\",\n"
"                min    = 0,\n"
"                max    = 1,\n"
"\n"
"            },\n"
"            {\n"
"                name   = \"F\",\n"
"                symbol = \"f_state\",\n"
"                min    = 0,\n"
"                max    = 1,\n"
"\n"
"            },\n"
"            {\n"
"                name   = \"F#\",\n"
"                symbol = \"fis_state\",\n"
"                min    = 0,\n"
"                max    = 1,\n"
"\n"
"            },\n"
"            {\n"
"                name   = \"G\",\n"
"                symbol = \"g_state\",\n"
"                min    = 0,\n"
"                max    = 1,\n"
"\n"
"            },\n"
"            {\n"
"                name   = \"G#\",\n"
"                symbol = \"gis_state\",\n"
"                min    = 0,\n"
"                max    = 1,\n"
"\n"
"            },\n"
"            {\n"
"                name   = \"A\",\n"
"                symbol = \"a_state\",\n"
"                min    = 0,\n"
"                max    = 1,\n"
"\n"
"            },\n"
"            {\n"
"                name   = \"A#\",\n"
"                symbol = \"ais_state\",\n"
"                min    = 0,\n"
"                max    = 1,\n"
"\n"
"            },\n"
"            {\n"
"                name   = \"B\",\n"
"                symbol = \"b_state\",\n"
"                min    = 0,\n"
"                max    = 1,\n"
"\n"
"            },\n"
"            {\n"
"                name   = \"Bypass\",\n"
"                symbol = \"bypass\",\n"
"                min    = 0,\n"
"                max    = 1,\n"
"\n"
"            },\n"
"\n"
"        }\n"
"        }\n"
"    }\n"
"end\n"
"\n"
"local function process(_, m, p, c)\n"
"    -- Get MIDI input buffer fromt the MidiPipe\n"
"    local input     = m:get(1)\n"
"\n"
"    -- Get the cc numbers from the parameter array, and round to integer\n"
"    local cc_scale  = round.integer(p[1])\n"
"    local cc_root   = round.integer(p[2])\n"
"    local cc_bypass = round.integer(p[3])\n"
"    --process the relevant cc messages\n"
"\n"
"    for msg, frame in input:messages() do\n"
"        if msg:isController() then\n"
"            if msg:isControllerType(cc_scale) then\n"
"                if msg:controllerValue() < #scl_all then\n"
"                    scl_idx = msg:controllerValue() + 1\n"
"                    scl_cur = scl_all[scl_idx]\n"
"                end\n"
"            elseif msg:isControllerType(cc_root) then\n"
"                root_note = msg:controllerValue()\n"
"                for i = 1, 12 do\n"
"                    local index = math.tointeger(root_note + i - 1) % 12\n"
"                    c[index + 1] = scl_cur[i]\n"
"                end\n"
"            elseif msg:isControllerType(cc_bypass) then\n"
"                if msg:controllerValue() > 0 then\n"
"                    c[13] = 0\n"
"                else\n"
"                    c[13] = 1\n"
"                end\n"
"            end\n"
"        end\n"
"    end\n"
"end\n"
"\n"
"return {\n"
"    type    = 'DSP',\n"
"    layout  = layout,\n"
"    process = process,\n"
"}\n"
"\n"
"-- SPDX-FileCopyrightText: Copyright (C) Lokki.\n"
"-- SPDX-License-Identifier: GPL-3.0-or-later\n";

const char* spontonchordchooser_lua = (const char*) temp_binary_data_6;
}
