Loading files
<!doctype html>
<html class="h-100" lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
<meta name="description" content="AMYboard. The best synth for $29">
<link rel="apple-touch-icon" sizes="180x180" href="/img/apple-touch-icon.png">
<meta property="og:title" content="AMYboard. The best synth for $29">
<meta property="og:image" content="https://amyboard.com/img/amyboard_preview.png">
<meta property="og:description" content="AMYboard. The best synth for $29">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@shorepinesound">
<meta name="twitter:creator" content="@shorepinesound">
<meta name="twitter:title" content="AMYboard. The best synth for $29">
<meta name="twitter:description" content="AMYboard. The best synth for $29">
<meta name="twitter:image" content="https://amyboard.com/img/amyboard_preview.png">
<meta property="og:type" content="product" />
<meta property="og:url" content="https://amyboard.com/" />
<meta property="og:site_name" content="AMYboard" />
<meta property="product:price:amount" content="29.90" />
<meta property="product:price:currency" content="USD" />
<meta property="og:availability" content="instock" />
<link rel="icon" type="image/png" sizes="32x32" href="img/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="img/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="96x96" href="img/favicon.png">
<meta name="author" content="shore pine sound systems">
<meta name="HandheldFriendly" content="true">
<title>AMYboard. Now available</title>
<base href="/">
<link rel="stylesheet" href="css/theme.css">
<link href="css/prism.css" rel="stylesheet" />
<link rel="stylesheet" href="/css/all.css" id="treejs_styles">
<link rel="stylesheet" href="amyrepl.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.48.4/codemirror.min.css" />
<script src="tree.js"></script>
<link rel="stylesheet" href="treejs.css" id="treejs_styles">
<!-- These filenames are replaced by the build system -->
<script src="AMYBOARDMJS" type="module"></script>
<script type="text/javascript" id="amy_js_include" src="AMYJS"></script>
<script src="editor_knobs.js"></script>
<script src="./mini-coi.js" scope="./"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/webmidi@latest/dist/iife/webmidi.iife.js"></script>
<script src="vendor/qwerty-hancock.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/6.65.7/codemirror.min.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/6.65.7/mode/python/python.min.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script type="text/javascript" src="amy_event_layout.generated.js"></script>
<script type="text/javascript" src="pcm_presets.generated.js"></script>
<script type="text/javascript" src="amy_parameters.js"></script>
<script>
window.AMYBOARD_WORLD_API_BASE = "https://tulipcc-production.up.railway.app";
</script>
<script type="text/javascript" src="spss.js"></script>
<style>
/* inter-300 - latin */
@font-face {
font-family: 'Inter';
font-style: normal;
font-weight: 300;
font-display: swap;
src: local(''),
url('./fonts/inter-v12-latin-300.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('./fonts/inter-v12-latin-300.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}
@font-face {
font-family: 'Inter';
font-style: normal;
font-weight: 500;
font-display: swap;
src: local(''),
url('./fonts/inter-v12-latin-500.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('./fonts/inter-v12-latin-500.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}
@font-face {
font-family: 'Inter';
font-style: normal;
font-weight: 700;
font-display: swap;
src: local(''),
url('./fonts/inter-v12-latin-700.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('./fonts/inter-v12-latin-700.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}
.knob-grid .ui-knob-container {
width: 68px;
height: 68px;
margin: 0 auto;
overflow: visible;
}
.knob-grid {
--bs-gutter-y: 0.75rem;
}
.amy-knob {
width: 52px;
height: 52px;
margin: 0 auto;
touch-action: none;
user-select: none;
}
.amy-knob:focus-visible .amy-knob-face {
outline: 2px solid #f2c94c;
outline-offset: 4px;
}
.amy-knob-face {
width: 100%;
height: 100%;
border-radius: 50%;
position: relative;
transform: rotate(var(--angle, 135deg));
background: radial-gradient(circle at 35% 35%, #515151 0%, #2c2c2c 55%, #1a1a1a 100%);
box-shadow: inset -6px -6px 12px rgba(0, 0, 0, 0.35),
inset 6px 6px 12px rgba(255, 255, 255, 0.06),
0 10px 20px rgba(0, 0, 0, 0.25);
}
.amy-knob-indicator {
position: absolute;
top: 5px;
left: 50%;
width: 5px;
height: 5px;
background: #f2c94c;
border-radius: 50%;
transform: translateX(-50%);
box-shadow: 0 0 6px rgba(242, 201, 76, 0.7);
}
.amy-knob-indicator-log {
background: #7fd3ff;
box-shadow: 0 0 6px rgba(127, 211, 255, 0.75);
}
.amy-pushbutton {
width: 52px;
height: 72px;
margin: 0 auto;
border-radius: 10px;
background: var(--pushbutton-color, #d04437);
display: flex;
align-items: flex-start;
justify-content: center;
padding-top: 6px;
cursor: pointer;
user-select: none;
box-shadow: inset -4px -6px 10px rgba(0, 0, 0, 0.3),
inset 4px 4px 8px rgba(255, 255, 255, 0.12),
0 10px 18px rgba(0, 0, 0, 0.28);
}
.amy-pushbutton:focus-visible {
outline: 2px solid #f2c94c;
outline-offset: 4px;
}
.amy-pushbutton-led {
width: 14px;
height: 14px;
border-radius: 50%;
background: #3a0a0a;
box-shadow: inset -2px -2px 4px rgba(0, 0, 0, 0.35),
inset 2px 2px 4px rgba(255, 255, 255, 0.08);
}
.amy-pushbutton.is-on .amy-pushbutton-led {
background: #ff3b2f;
box-shadow: 0 0 10px rgba(255, 59, 47, 0.9),
inset 0 0 6px rgba(255, 255, 255, 0.45);
}
.amy-select {
width: 100%;
display: flex;
justify-content: center;
}
.amy-select-control {
width: 80px;
height: 72px;
display: grid;
grid-template-rows: 18px 1fr 18px;
align-items: center;
justify-items: center;
background: #1e1e1e;
color: #f8f8f8;
border: 1px solid #333;
border-radius: 10px;
padding: 4px;
font-size: 9px;
box-shadow: inset -4px -4px 8px rgba(0, 0, 0, 0.35),
inset 4px 4px 8px rgba(255, 255, 255, 0.06);
}
.amy-select-control:focus-within {
outline: 2px solid #f2c94c;
outline-offset: 2px;
}
.amy-select-btn {
width: 100%;
height: 18px;
border: none;
border-radius: 6px;
background: #2c2c2c;
color: #f2c94c;
font-size: 10px;
line-height: 1;
cursor: pointer;
padding: 0;
position: relative;
--arrow-color: #f2c94c;
--arrow-hole-opacity: 0;
}
.amy-select-btn:active {
background: #3a3a3a;
}
.amy-select-btn:disabled {
cursor: default;
}
.amy-select-btn.is-disabled {
--arrow-color: #666;
--arrow-hole-opacity: 1;
}
.amy-select-btn::before {
content: "";
position: absolute;
left: 50%;
top: 50%;
width: 0;
height: 0;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
transform: translate(-50%, -50%);
}
.amy-select-btn::after {
content: "";
position: absolute;
left: 50%;
top: 50%;
width: 0;
height: 0;
border-left: 3px solid transparent;
border-right: 3px solid transparent;
transform: translate(-50%, -50%);
opacity: var(--arrow-hole-opacity);
}
.amy-select-btn-up::before {
border-bottom: 6px solid var(--arrow-color);
}
.amy-select-btn-down::before {
border-top: 6px solid var(--arrow-color);
}
.amy-select-btn-up::after {
border-bottom: 4px solid #2c2c2c;
}
.amy-select-btn-down::after {
border-top: 4px solid #2c2c2c;
}
.amy-select-display {
width: 100%;
text-align: center;
font-size: 9px;
line-height: 1.1;
padding: 0 2px;
color: #f8f8f8;
user-select: none;
}
.amy-select-display-clickable {
text-decoration: underline;
text-underline-offset: 2px;
cursor: pointer;
}
.amy-wave-preset-popup {
position: absolute;
z-index: 10000;
width: max-content;
max-width: 320px;
max-height: 260px;
overflow-y: auto;
background: #181818;
border: 1px solid #444;
border-radius: 8px;
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.35);
padding: 6px;
}
.amy-wave-preset-popup-title {
font-size: 11px;
font-weight: 600;
color: #ddd;
margin: 2px 4px 6px;
}
.amy-wave-preset-option {
width: 100%;
text-align: left;
border: none;
background: transparent;
color: #f0f0f0;
border-radius: 6px;
padding: 4px 6px;
font-size: 11px;
line-height: 1.2;
}
.amy-wave-preset-option:hover {
background: #2a2a2a;
}
.amy-wave-preset-option.is-selected {
background: #2f4737;
color: #bfe8c6;
}
.knob-spacer {
width: 68px;
height: 68px;
margin: 0 auto;
}
.amy-keyboard {
width: 100%;
max-width: 900px;
height: 140px;
margin: 0 auto;
position: relative;
user-select: none;
}
#canvas {
width: 100%;
max-width: 256px;
height: auto;
aspect-ratio: 1 / 1;
display: block;
}
@media (min-width: 800px) {
.knob-col {
flex: 0 0 8.333%;
max-width: 8.333%;
}
}
.knob-section-header {
text-align: center;
font-weight: 600;
letter-spacing: 0.08em;
text-transform: uppercase;
color: #f2f2f2;
background: #2b2b2b;
border-radius: 10px;
padding: 4px 10px;
margin: 4px 0 2px;
font-size: 10px;
width: 100%;
box-sizing: border-box;
}
.nav-tabs .nav-link {
font-size: 0.85rem;
padding: 0.35rem 0.75rem;
}
#send-tab {
background: #daf4de;
border-color: #a9d8b3;
color: #1f5f2b;
}
#send-tab:hover {
background: #c9eecf;
border-color: #95caa1;
color: #184c23;
}
#send-tab.active {
background: #3ecf66;
border-color: #2aab50;
color: #0f3b1a;
font-weight: 600;
}
.tab-header-row {
border-bottom: 1px solid var(--bs-nav-tabs-border-color, #dee2e6);
}
.tab-header-row .nav-tabs {
border-bottom: 0;
margin-bottom: -1px;
}
.form-control,
.form-select,
.form-check-label {
font-size: 0.85rem;
}
.settings-wrap {
max-width: 760px;
}
.settings-list {
background: linear-gradient(180deg, #f9fafb 0%, #f2f4f7 100%);
border: 1px solid #dde2e7;
border-radius: 12px;
padding: 0.5rem;
}
.settings-item {
display: flex;
align-items: center;
gap: 0.6rem;
padding: 0.65rem 0.75rem;
border-radius: 10px;
background: #ffffff;
border: 1px solid #e7ebef;
}
.settings-item + .settings-item {
margin-top: 0.45rem;
}
.settings-item .form-check-input {
margin-top: 0;
}
.settings-item .form-check-label {
color: #1f2937;
font-weight: 500;
}
.knob-value {
font-size: 0.62rem;
padding: 0.2rem 0.4rem;
}
.knob-label {
font-size: 0.65rem;
line-height: 1.1;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.knob-section {
flex: 0 0 100%;
max-width: 100%;
border-radius: 12px;
overflow: hidden;
padding-bottom: 4px;
}
@media (min-width: 800px) {
.knob-section-main {
flex: 0 0 min(100%, calc(var(--knob-units, var(--knob-count, 14)) * 7.142%));
max-width: min(100%, calc(var(--knob-units, var(--knob-count, 14)) * 7.142%));
width: min(100%, calc(var(--knob-units, var(--knob-count, 14)) * 7.142%));
}
.knob-section-main .knob-col {
flex: 0 0 calc(100% * var(--knob-span, 1) / var(--knob-units, var(--knob-count, 14)));
max-width: calc(100% * var(--knob-span, 1) / var(--knob-units, var(--knob-count, 14)));
}
}
@media (max-width: 799px) {
.knob-col-spacer {
display: none;
}
}
#patch-pane {
background: linear-gradient(135deg, #e6e6e6 0%, #99918b 100%);
border-radius: 12px;
padding: 24px;
}
.patch-toolbar {
background:rgba(44, 55, 55, 0.75);
border-radius: 12px;
padding: 6px 6px;
margin-left: -8px;
margin-right: -8px;
}
.patch-select-group .patch-init-btn {
font-size: 0.75rem;
padding: 0.25rem 0.6rem;
}
.patch-select-group {
gap: 4px;
}
.patch-select-group .form-select {
font-size: 0.8rem;
padding-top: 0.25rem;
padding-bottom: 0.25rem;
max-width: 240px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.patch-save-group {
gap: 4px;
align-items: center;
}
.patch-save-group .patch-save-btn {
font-size: 0.75rem;
padding: 0.25rem 0.6rem;
}
.patch-save-group .patch-save-input {
max-width: 120px;
height: calc(1.5em + 0.75rem + 2px);
}
.patch-save-group .patch-load-btn {
font-size: 0.75rem;
padding: 0.25rem 0.6rem;
}
#channel-active-checkbox + label {
color: #fff;
}
.env-file-list {
background-color: #002b36;
}
.env-file-item {
width: 100%;
border: 0;
margin: 0;
padding: 2px 5px;
text-align: left;
background-color: #002b36;
color: #839496;
font-size: 12px;
border-radius: 0;
}
.env-file-item:hover {
background-color: #073642;
color: #839496;
}
.env-file-item.selected,
.env-file-item.selected:hover {
background-color: #606060;
color: #fff;
}
.env-file-empty {
padding: 6px 8px;
font-size: 12px;
color: #839496;
background-color: #002b36;
}
</style>
</head>
<body>
<nav id="navScroll" class="navbar navbar-expand-lg navbar-light fixed-top scrolled" tabindex="0">
<div class="container">
<a class="navbar-brand pe-4 fs-4" href="/editor/">
<img src="img/amyboard.svg" width="32" height="32" alt="AMYboard logo" />
<span class="ms-1 fw-bolder">AMYboard online</span>
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link" href="https://github.com/shorepine/amy">
<img src="img/github-mark.svg" width="24" height="24" /> Github
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://discord.com/invite/TzBFkUb8pG">
<img src="img/discord-mark-black.svg" width="24" height="24" /> Discord
</a>
</li>
</ul>
<ul class="navbar-nav ms-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link btn btn-warning btn-xl shadow me-3 rounded-0 mt-2" href="/">
<img src="img/amyboard.svg" width="24" height="24" /> AMYboard
</a>
</li>
</ul>
</div>
</div>
</nav>
<script type="module">
mp = await loadMicroPython({
linebuffer: false,
pystack: 64 * 1024,
heapsize: 8 * 1024 * 1024
});
await sleep_ms(50);
// Tell MP to start serving a REPL
await mp.replInit();
await sleep_ms(50);
// Start up the AMYboard stuff
await start_amyboard();
await refresh_amyboard_world_files();
// Create the editor and see if there's a share URL to decompress into it
var editorElement = document.getElementById('collapseEditor');
editor = CodeMirror.fromTextArea(document.getElementById(`code`), {
mode: {
name: "python",
version: 3,
singleLineStringErrors: false,
lint: false
},
lineNumbers: true,
indentUnit: 4,
matchBrackets: true,
spellCheck: false,
autocorrect: false,
theme: "lucario",
lint: false,
});
editor.on("change", function() {
window.environment_editor_dirty = true;
});
document.addEventListener("click", function() {
if (typeof window.save_editor_if_dirty === "function") {
window.save_editor_if_dirty();
}
});
editor.setSize(null,editor_height);
if (typeof flush_pending_environment_editor_load === "function") {
await flush_pending_environment_editor_load();
}
</script>
<main class="container pt-5 mt-5">
<div class="card border-0 bg-light shadow-sm mb-3">
<div class="card-body">
<form name="amyboard_settings">
<div class="row align-items-center">
<div class="col-md-auto align-top small d-flex align-items-center" id="audioin_grow">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="amy_audioin" onClick="toggle_audioin();"/>
<label class="form-check-label" for="amy_audioin">Allow audio input</label>
</div>
</div>
<div class="col-12 col-md-4 align-self-start small mt-2 mt-md-0" id="midi-input-col">
<div id="midi-input-panel">
<select onchange="setup_midi_devices()" name="midi_input" class="form-select form-select-sm" aria-label=".form-select-sm example">
<option selected>[Not available]</option>
</select>
</div>
</div>
<div class="col-12 col-md-4 align-self-start small mt-2 mt-md-0" id="midi-output-col">
<div id="midi-output-panel">
<select onchange="setup_midi_devices()" name="midi_output" class="form-select form-select-sm" aria-label=".form-select-sm example">
<option selected>[Not available]</option>
</select>
</div>
</div>
<div class="col-12 col-md-8 align-self-start small mt-2 mt-md-0 d-none" id="midi-warning-col">
<div class="alert alert-warning py-2 mb-0">
This page can use WebMIDI on <a href="https://caniuse.com/midi" target="_blank">supported browsers</a>.
</div>
</div>
</div>
</form>
</div>
</div>
<div class="card border-0 bg-light shadow-sm">
<div class="card-body">
<div class="d-flex justify-content-between align-items-center tab-header-row">
<ul class="nav nav-tabs w-100" id="editorTabs" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="patch-tab" data-bs-toggle="tab" data-bs-target="#patch-pane" type="button" role="tab" aria-controls="patch-pane" aria-selected="true">Patch</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="environment-tab" data-bs-toggle="tab" data-bs-target="#environment-pane" type="button" role="tab" aria-controls="environment-pane" aria-selected="false">Code</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="settings-tab" data-bs-toggle="tab" data-bs-target="#settings-pane" type="button" role="tab" aria-controls="settings-pane" aria-selected="false">Settings</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="world-tab" data-bs-toggle="tab" data-bs-target="#world-pane" type="button" role="tab" aria-controls="world-pane" aria-selected="false">AMYboard World</button>
</li>
<li class="nav-item ms-auto" role="presentation">
<button class="nav-link" id="send-tab" data-bs-toggle="tab" data-bs-target="#send-pane" type="button" role="tab" aria-controls="send-pane" aria-selected="false">Send to my AMYboard</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="upgrade-tab" data-bs-toggle="tab" data-bs-target="#upgrade-pane" type="button" role="tab" aria-controls="upgrade-pane" aria-selected="false">Upgrade Firmware</button>
</li>
</ul>
</div>
<div class="tab-content pt-4">
<div class="tab-pane fade show active" id="patch-pane" role="tabpanel" aria-labelledby="patch-tab">
<div class="row align-items-center mb-4 patch-toolbar gx-1">
<div class="col-12 col-md-auto">
<select class="form-select" id="midi-channel-select" aria-label="MIDI Channel">
<option value="1" selected>Channel 1</option>
<option value="2">Channel 2</option>
<option value="3">Channel 3</option>
<option value="4">Channel 4</option>
<option value="5">Channel 5</option>
<option value="6">Channel 6</option>
<option value="7">Channel 7</option>
<option value="8">Channel 8</option>
<option value="9">Channel 9</option>
<option value="10">Channel 10</option>
<option value="11">Channel 11</option>
<option value="12">Channel 12</option>
<option value="13">Channel 13</option>
<option value="14">Channel 14</option>
<option value="15">Channel 15</option>
<option value="16">Channel 16</option>
</select>
</div>
<div class="col-12 col-md-auto mt-2 mt-md-0 d-flex align-items-center">
<div class="form-check ms-1">
<input class="form-check-input" type="checkbox" id="channel-active-checkbox" checked />
<label class="form-check-label small" for="channel-active-checkbox">Active</label>
</div>
</div>
<div class="col-12 col-md-1 d-none d-md-block"></div>
<div class="col-12 col-md-auto mt-2 mt-md-0 d-flex align-items-center">
<button class="btn btn-light btn-sm rounded-0" type="button" disabled>Patch: <span id="patch-active-name">None</span></button>
</div>
<div class="col-12 col-md-auto mt-2 mt-md-0">
<div class="d-flex gap-2">
<button class="btn btn-warning btn-sm rounded-pill" type="button" id="patch-open-load-modal-btn">Load</button>
<button class="btn btn-danger btn-sm rounded-pill" type="button" id="patch-save-action-btn">Save</button>
<button class="btn btn-secondary btn-sm rounded-pill" type="button" id="patch-revert-action-btn">Revert</button>
<button class="btn btn-secondary btn-sm rounded-pill" type="button" id="patch-clear-channel-btn">Clear</button>
</div>
</div>
</div>
<div class="row g-4 knob-grid" id="knob-grid"></div>
</div>
<div class="tab-pane fade" id="environment-pane" role="tabpanel" aria-labelledby="environment-tab">
<div class="alert fixed-top d-none" id="alert_box"></div>
<div class="row g-0 headertext">
<div class="col-4 col-md-2 headertext">
<span class="px-1 small align-middle">Your Files</span>
<div id="treecontainer"></div>
<div class="mt-1 d-flex gap-1">
<button
type="button"
title="Upload file into current environment"
data-toggle="tooltip"
data-placement="top"
class="btn btn-sm btn-primary"
onclick="upload()"
><i class="fas fa-upload"></i></button>
<button
type="button"
title="New file"
data-toggle="tooltip"
data-placement="top"
class="btn btn-sm btn-success"
onclick="create_new_environment_file()"
><i class="fas fa-plus"></i></button>
<button
type="button"
title="Rename file"
data-toggle="tooltip"
data-placement="top"
class="btn btn-sm btn-warning"
onclick="open_rename_environment_file_modal()"
><i class="fas fa-pen"></i></button>
<button
type="button"
title="Delete file"
data-toggle="tooltip"
data-placement="top"
class="btn btn-sm btn-danger"
onclick="delete_selected_environment_file()"
><i class="fas fa-trash"></i></button>
</div>
</div>
<div class="col-8 col-md-10 headertext">
<span class="px-1 small align-middle">Code editor</span>
<section class="input">
<div><textarea id="code" name="code"></textarea></div>
</section>
</div>
</div>
<div class="row g-0 py-0 my-0 grippierow">
<p class="text-center grippie" id="editor_grippie">• • •</p>
</div>
<div class="row mb-4 mt-1">
<div class="col-12">
<div class="border rounded bg-light px-3 py-2 d-flex flex-wrap align-items-center gap-2">
<button
type="button"
title="Start environment"
data-toggle="tooltip"
data-placement="top"
class="btn btn-sm btn-success"
onclick="run_current_environment()"
>Start</button>
<button
type="button"
title="Clear current environment"
data-toggle="tooltip"
data-placement="top"
class="btn btn-sm btn-outline-danger"
onclick="clear_current_environment_from_default()"
>Clear</button>
</div>
</div>
</div>
<div class="row mb-4 mt-1 align-items-start">
<div class="col-6 col-md-4">
<canvas id="canvas" width="256" height="256"></canvas>
</div>
<div class="col-6 col-md-4">
<div id="cv-knob-grid" class="row g-4"></div>
</div>
</div>
</div> <!-- end environment tab -->
<div class="tab-pane fade" id="settings-pane" role="tabpanel" aria-labelledby="settings-tab">
<div class="settings-wrap">
<h6 class="mb-2">Hardware settings</h6>
<div class="small text-muted mb-3">These settings are for your AMYboard hardware behavior.</div>
<div class="settings-list">
<div class="settings-item">
<input class="form-check-input" type="checkbox" id="setting-modular-10vpp" />
<label class="form-check-label" for="setting-modular-10vpp">Modular 10vpp Volume (Also set your DIP Switches)</label>
</div>
<div class="settings-item">
<input class="form-check-input" type="checkbox" id="setting-midi-type-b" />
<label class="form-check-label" for="setting-midi-type-b">Use MIDI Type B instead of A</label>
</div>
<div class="settings-item">
<input class="form-check-input" type="checkbox" id="setting-drumkit-channel-10" />
<label class="form-check-label" for="setting-drumkit-channel-10">Drum kit on channel 10</label>
</div>
</div>
</div>
</div>
<div class="tab-pane fade" id="world-pane" role="tabpanel" aria-labelledby="world-tab">
<div class="row mb-2">
<div class="col-12">
<div class="border rounded p-3 bg-light">
<div class="d-flex align-items-center mb-2">
<span class="fw-semibold">Environments (latest)</span>
<button
type="button"
title="Refresh environments"
data-toggle="tooltip"
data-placement="top"
class="btn btn-sm btn-link text-secondary p-0 ms-2"
onclick="refresh_amyboard_world_files()"
><i class="fas fa-sync"></i></button>
</div>
<div class="row g-2 mb-2">
<div class="col-12 col-md-7">
<input
type="text"
id="amyboard_world_search"
class="form-control form-control-sm"
maxlength="100"
placeholder="Search by description, filename, or username"
onkeydown="if (event.key === 'Enter') { refresh_amyboard_world_files(); }"
/>
</div>
<div class="col-12 col-md-3 d-flex align-items-center">
<div id="amyboard_world_tag_pills" class="d-flex flex-wrap gap-1"></div>
</div>
<div class="col-12 col-md-2 d-grid">
<button type="button" class="btn btn-sm btn-outline-secondary" onclick="refresh_amyboard_world_files()">Search</button>
</div>
</div>
<div id="amyboard_world_file_list" class="small" style="max-height: 360px; overflow-y: auto;"></div>
</div>
</div>
</div>
<div class="row mb-2">
<div class="col-12">
<div class="border rounded p-3 bg-light">
<div class="fw-semibold mb-2">Upload your Environment</div>
<div class="mb-2">This will upload your patches and code to AMYboard World for anyone to try!</div>
<div class="row g-2">
<div class="col-12 col-md-4">
<label for="environment_username" class="form-label mb-1">Username</label>
<input type="text" id="environment_username" class="small form-control" maxlength="20" placeholder="Username" />
<div class="form-text">1-20 chars: A-Z, a-z, 0-9.</div>
</div>
<div class="col-12 col-md-4">
<label for="editor_filename" class="form-label mb-1">Environment name</label>
<input type="text" id="editor_filename" class="small form-control" maxlength="20" placeholder="Environment Name" />
<div class="form-text">1-20 chars: A-Z, a-z, 0-9, -, _.</div>
</div>
<div class="col-12 col-md-4">
<label for="environment_description" class="form-label mb-1">Description</label>
<textarea id="environment_description" class="small form-control" maxlength="400" rows="3" placeholder="Description"></textarea>
<div class="form-text">1-400 characters.</div>
</div>
</div>
<div class="mt-2">
<button type="button" id="upload_current_environment_btn" class="btn btn-sm btn-primary" onclick="upload_current_environment()">Upload</button>
</div>
</div>
</div>
</div>
</div>
<div class="tab-pane fade" id="send-pane" role="tabpanel" aria-labelledby="send-tab">
<div id="send-amyboard-unsupported" class="d-none">
<p class="mb-0">This browser does not support WebMIDI. Use Chrome, Edge, or Opera to send files to AMYboard.</p>
</div>
<div id="send-amyboard-supported" class="d-none">
<p class="mb-3">Ensure your AMYboard is connected to the MIDI <strong>out</strong> port selected above.
If you're connected over USB, the MIDI out port should say "AMYboard."</p>
<p class="mb-3">We'll send over the current environment, settings, and the state of the current patches per active
channel and their MIDI CC assignments. </p>
<p class="mb-3">Any existing patches or environments on your AMYboard will be overwritten.</p>
<button type="button" class="btn btn-primary" id="send-amyboard-send-btn" onclick="send_to_amyboard_now()">Send</button>
<div id="send-amyboard-progress-wrap" class="mt-3 d-none">
<div class="progress" style="height: 14px;">
<div
id="send-amyboard-progress-bar"
class="progress-bar progress-bar-striped progress-bar-animated"
role="progressbar"
style="width: 0%;"
aria-valuemin="0"
aria-valuemax="100"
aria-valuenow="0"
></div>
</div>
<div id="send-amyboard-progress-text" class="small text-muted mt-1"></div>
</div>
<div id="send-amyboard-status" class="small mt-2 d-none"></div>
</div>
</div>
<div class="tab-pane fade" id="upgrade-pane" role="tabpanel" aria-labelledby="upgrade-tab">
<div class="esptool-frame-wrap">
<iframe
class="esptool-frame"
src="esptool/index.html"
title="Adafruit WebSerial ESPTool"
allow="serial"
loading="lazy"
></iframe>
</div>
</div>
</div>
</div>
</div> <!-- end patch / env card -->
<div class="card border-0 bg-light shadow-sm mt-3">
<div class="card-body">
<div id="amy-keyboard" class="amy-keyboard"></div>
</div>
</div>
</main>
<div class="modal fade" id="renameEnvironmentFileModal" tabindex="-1" aria-labelledby="renameEnvironmentFileModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="renameEnvironmentFileModalLabel">Rename file</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<label for="rename_environment_filename" class="form-label mb-1">New file name</label>
<input type="text" id="rename_environment_filename" class="form-control form-control-sm" />
</div>
<div class="modal-footer">
<button type="button" class="btn btn-sm btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-sm btn-primary" onclick="submit_rename_environment_file()">Rename</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="confirmEnvironmentActionModal" tabindex="-1" aria-labelledby="confirmEnvironmentActionModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="confirm_environment_action_title">Confirm</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p id="confirm_environment_action_body" class="mb-0"></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-sm btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-sm btn-danger" id="confirm_environment_action_btn">Confirm</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="loadPatchModal" tabindex="-1" aria-labelledby="loadPatchModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<div>
<h5 class="modal-title" id="loadPatchModalLabel">Load Patch</h5>
<div class="small text-muted" id="load-patch-channel-label">Into Channel 1</div>
</div>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<label for="load-patch-your-patches" class="form-label mb-1">Your Patches</label>
<select class="form-select form-select-sm mb-3" id="load-patch-your-patches"></select>
<div class="mb-3">
<button type="button" class="btn btn-sm btn-primary" id="load-your-patch-btn">Load</button>
</div>
<label for="load-patch-presets" class="form-label mb-1">Presets</label>
<select class="form-select form-select-sm" id="load-patch-presets"></select>
<div class="mt-2">
<button type="button" class="btn btn-sm btn-primary" id="load-preset-btn">Load</button>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-sm btn-secondary" data-bs-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="savePatchModal" tabindex="-1" aria-labelledby="savePatchModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="savePatchModalLabel">Save Patch</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<label for="save-patch-name" class="form-label mb-1">Name</label>
<input
type="text"
class="form-control form-control-sm"
id="save-patch-name"
maxlength="25"
title="Use 1-25 ASCII characters: letters, numbers, dot, underscore, or dash."
/>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-sm btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-sm btn-primary" id="save-patch-confirm-btn">Save</button>
</div>
</div>
</div>
</div>
<footer>
<div class="container small border-top">
<div class="row py-5 d-flex justify-content-between">
<div class="col-12 col-lg-6 col-xl-3 border-end p-5">
<img src="img/shorepine.svg" width="24" height="24" />
<address class="text-secondary mt-3">
<strong>shore pine sound systems</strong>
</address>
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link link-secondary ps-0" aria-current="page" href="https://github.com/shorepine">Github</a>
</li>
<li class="nav-item">
<a class="nav-link link-secondary ps-0" href="https://discord.com/invite/TzBFkUb8pG">Discord</a>
</li>
<li class="nav-item">
<a class="nav-link link-secondary ps-0" href="https://instagram.com/shorepinesound">Instagram</a>
</li>
<li class="nav-item">
<a class="nav-link link-secondary ps-0" href="mailto:brian@variogram.com">Email</a>
</li>
</ul>
</div>
</div>
</div>
</footer>
<script src="js/bootstrap.bundle.min.js"></script>
<script src="js/aos.js"></script>
<script src="js/prism.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script src="patches.generated.js"></script>
<script src="editor_knobs.js"></script>
<script>
AOS.init({
duration: 800,
});
</script>
<script>
// On keypress or click anywhere, start audio worklet
document.body.addEventListener('click', start_audio, true);
document.body.addEventListener('keydown', start_audio, true);
let scrollpos = window.scrollY;
const header = document.querySelector(".navbar");
const header_height = header.offsetHeight;
const add_class_on_scroll = () => header.classList.add("scrolled", "shadow-sm");
const remove_class_on_scroll = () => header.classList.remove("scrolled", "shadow-sm");
window.addEventListener("scroll", function() {
scrollpos = window.scrollY;
if (scrollpos >= header_height) {
add_class_on_scroll();
} else {
remove_class_on_scroll();
}
});
// Handle the grippie bars on the page for the editor & Tulip blocks
var editor_grippie_held = false;
var editor_grippie_y_start = 0;
$('body').on('mouseup', function mouseState(e) {
editor_grippie_held = false;
});
$('#editor_grippie').on('mousedown mousemove', function mouseState(e) {
if (e.type == "mousedown") {
e.preventDefault();
editor_grippie_held = true;
editor_grippie_y_start = e.clientY;
}
if(e.type == "mousemove") {
if(editor_grippie_held) {
e.preventDefault();
editor_height = editor_height + (e.clientY - editor_grippie_y_start);
if(editor_height < 200) editor_height = 200;
editor.setSize(null, editor_height);
document.getElementById('treecontainer').setAttribute("style","height:"+editor_height.toString()+"px");
}
}
});
// Set up the tooltips
$(function () {
$('[data-toggle="tooltip"]').tooltip({delay: { "show": 3000, "hide": 500 }, trigger:'hover'})
})
$('[rel="tooltip"]').on('click', function () {
$(this).tooltip('hide')
});
// Handle the CV knobs
const cvGrid = document.getElementById("cv-knob-grid");
if (cvGrid && typeof init_knobs === "function") {
window.amy_cv_knobs = [
{ section: "CV Input", min_value: -10, max_value: 10, display_name: "CV1", default_value: 0 },
{ section: "CV Input", min_value: -10, max_value: 10, display_name: "CV2", default_value: 0 }
];
init_knobs(window.amy_cv_knobs, "cv-knob-grid", function(index, value) {
if (typeof window.amy_cv_knob_change === "function") {
window.amy_cv_knob_change(index, value);
}
});
}
if(editor) editor.refresh();
editor_shown = true;
</script>
<script>
window.addEventListener("DOMContentLoaded", function() {
const hardwareSettingsMap = [
{ id: "setting-modular-10vpp", key: "amyboard.hardware.modular_10vpp_volume" },
{ id: "setting-midi-type-b", key: "amyboard.hardware.midi_type_b" },
{ id: "setting-drumkit-channel-10", key: "amyboard.hardware.drumkit_channel_10" }
];
hardwareSettingsMap.forEach(function(setting) {
const checkbox = document.getElementById(setting.id);
if (!checkbox) {
return;
}
try {
checkbox.checked = localStorage.getItem(setting.key) === "1";
} catch (e) {}
checkbox.addEventListener("change", function() {
try {
localStorage.setItem(setting.key, checkbox.checked ? "1" : "0");
} catch (e) {}
});
});
const sendTab = document.getElementById("send-tab");
if (sendTab) {
sendTab.addEventListener("shown.bs.tab", function() {
if (typeof window.open_send_to_amyboard_modal === "function") {
window.open_send_to_amyboard_modal();
}
});
}
const environmentTab = document.getElementById("environment-tab");
if (environmentTab) {
environmentTab.addEventListener("shown.bs.tab", function() {
Promise.resolve()
.then(function() {
if (typeof window.sync_persistent_fs === "function") {
return window.sync_persistent_fs();
}
})
.then(function() {
if (typeof window.fill_tree === "function") {
return window.fill_tree();
}
})
.catch(function() {});
});
}
const midiChannelSelect = document.getElementById("midi-channel-select");
const channelActiveCheckbox = document.getElementById("channel-active-checkbox");
function syncActiveCheckboxForChannel() {
if (!channelActiveCheckbox) {
return;
}
const active = Array.isArray(window.active_channels) ? !!window.active_channels[window.current_synth || 1] : (window.current_synth || 1) === 1;
channelActiveCheckbox.checked = active;
}
if (midiChannelSelect) {
midiChannelSelect.value = String(window.current_synth || 1);
midiChannelSelect.addEventListener("change", function() {
const parsed = Number(midiChannelSelect.value);
if (Number.isInteger(parsed) && parsed >= 1 && parsed <= 16) {
window.current_synth = parsed;
syncActiveCheckboxForChannel();
refreshLoadPatchChannelLabel();
refreshPatchActiveNameLabel();
refreshSavePatchDirtyIndicator();
if (channelActiveCheckbox && channelActiveCheckbox.checked) {
if (typeof window.refresh_knobs_for_active_channel === "function") {
window.refresh_knobs_for_active_channel({ sendControlMappings: false });
}
}
}
});
}
if (channelActiveCheckbox) {
channelActiveCheckbox.addEventListener("change", function() {
if (typeof window.set_channel_active === "function") {
window.set_channel_active(window.current_synth || 1, channelActiveCheckbox.checked);
}
if (channelActiveCheckbox.checked) {
if (typeof window.refresh_knobs_for_active_channel === "function") {
window.refresh_knobs_for_active_channel({ sendControlMappings: true });
}
}
});
}
const patchLoadModalButton = document.getElementById("patch-open-load-modal-btn");
const loadPatchModalEl = document.getElementById("loadPatchModal");
const patchSaveActionButton = document.getElementById("patch-save-action-btn");
const patchRevertActionButton = document.getElementById("patch-revert-action-btn");
const patchClearChannelButton = document.getElementById("patch-clear-channel-btn");
const savePatchModalEl = document.getElementById("savePatchModal");
const savePatchNameInput = document.getElementById("save-patch-name");
const savePatchConfirmButton = document.getElementById("save-patch-confirm-btn");
const yourPatchesSelect = document.getElementById("load-patch-your-patches");
const presetsSelect = document.getElementById("load-patch-presets");
const loadYourPatchButton = document.getElementById("load-your-patch-btn");
const loadPatchChannelLabel = document.getElementById("load-patch-channel-label");
const patchActiveNameEl = document.getElementById("patch-active-name");
function refreshPatchActiveNameLabel() {
if (!patchActiveNameEl) return;
const channel = Number(window.current_synth || 1);
let name = null;
if (Array.isArray(window.channel_patch_names) && typeof window.channel_patch_names[channel] === "string") {
name = String(window.channel_patch_names[channel] || "").trim();
}
patchActiveNameEl.textContent = name ? name : "None";
}
window.refresh_patch_active_name_label = refreshPatchActiveNameLabel;
function refreshSavePatchDirtyIndicator() {
if (!patchSaveActionButton) return;
const channel = Number(window.current_synth || 1);
const isDirty = !!(Array.isArray(window.channel_patch_dirty) && window.channel_patch_dirty[channel]);
patchSaveActionButton.textContent = isDirty ? "Save*" : "Save";
patchSaveActionButton.title = isDirty ? "This channel has unsaved changes." : "";
}
window.refresh_save_patch_dirty_indicator = refreshSavePatchDirtyIndicator;
function refreshLoadPatchChannelLabel() {
if (!loadPatchChannelLabel) return;
const channel = Number(window.current_synth || 1);
loadPatchChannelLabel.textContent = "Into Channel " + String(channel);
}
function refreshYourPatchesDropdown() {
if (!yourPatchesSelect) return;
let files = [];
if (typeof window.list_environment_files === "function") {
files = window.list_environment_files();
}
const patchFiles = (Array.isArray(files) ? files : [])
.filter(function(filename) {
return String(filename || "").toLowerCase().endsWith(".patch");
})
.sort(function(a, b) {
return String(a || "").localeCompare(String(b || ""));
});
yourPatchesSelect.innerHTML = "";
if (!patchFiles.length) {
const option = document.createElement("option");
option.value = "";
option.textContent = "No patches found";
yourPatchesSelect.appendChild(option);
yourPatchesSelect.disabled = true;
return;
}
yourPatchesSelect.disabled = false;
patchFiles.forEach(function(filename) {
const option = document.createElement("option");
option.value = filename;
option.textContent = String(filename).replace(/\.patch$/i, "");
yourPatchesSelect.appendChild(option);
});
}
if (typeof init_patches_select === "function" && presetsSelect) {
init_patches_select("load-patch-presets");
}
refreshLoadPatchChannelLabel();
refreshPatchActiveNameLabel();
refreshSavePatchDirtyIndicator();
if (patchLoadModalButton && loadPatchModalEl && window.bootstrap) {
function positionLoadPatchModalNearButton() {
const dialog = loadPatchModalEl.querySelector(".modal-dialog");
if (!dialog) return;
const rect = patchLoadModalButton.getBoundingClientRect();
const viewportWidth = window.innerWidth || document.documentElement.clientWidth || 0;
const viewportHeight = window.innerHeight || document.documentElement.clientHeight || 0;
const dialogWidth = Math.min(360, Math.max(280, viewportWidth - 24));
const estimatedHeight = 360;
let left = rect.left;
if (left + dialogWidth > viewportWidth - 12) {
left = viewportWidth - dialogWidth - 12;
}
if (left < 12) {
left = 12;
}
let top = rect.bottom + 8;
if (top + estimatedHeight > viewportHeight - 12) {
top = Math.max(12, rect.top - estimatedHeight - 8);
}
dialog.style.position = "fixed";
dialog.style.margin = "0";
dialog.style.width = dialogWidth + "px";
dialog.style.maxWidth = dialogWidth + "px";
dialog.style.left = left + "px";
dialog.style.top = top + "px";
dialog.style.transform = "none";
}
patchLoadModalButton.addEventListener("click", function() {
refreshLoadPatchChannelLabel();
refreshYourPatchesDropdown();
positionLoadPatchModalNearButton();
const modal = window.bootstrap.Modal.getOrCreateInstance(loadPatchModalEl);
modal.show();
});
loadPatchModalEl.addEventListener("shown.bs.modal", positionLoadPatchModalNearButton);
window.addEventListener("resize", function() {
if (loadPatchModalEl.classList.contains("show")) {
positionLoadPatchModalNearButton();
}
});
if (loadYourPatchButton && yourPatchesSelect) {
loadYourPatchButton.addEventListener("click", async function() {
const selected = String(yourPatchesSelect.value || "").trim();
if (!selected) {
if (typeof show_alert === "function") {
show_alert("Select a patch to load.");
}
return;
}
if (typeof window.load_saved_patch_file_into_current_channel !== "function") {
if (typeof show_alert === "function") {
show_alert("Load patch is not available.");
}
return;
}
loadYourPatchButton.disabled = true;
try {
await window.load_saved_patch_file_into_current_channel(selected);
refreshPatchActiveNameLabel();
refreshSavePatchDirtyIndicator();
const modal = window.bootstrap.Modal.getOrCreateInstance(loadPatchModalEl);
modal.hide();
} catch (e) {
if (typeof show_alert === "function") {
show_alert("Could not load patch.");
}
} finally {
loadYourPatchButton.disabled = false;
}
});
}
}
if (patchSaveActionButton && savePatchModalEl && window.bootstrap) {
if (savePatchNameInput) {
savePatchNameInput.addEventListener("input", function() {
const cleaned = String(savePatchNameInput.value || "")
.replace(/[^A-Za-z0-9._-]/g, "")
.slice(0, 25);
if (savePatchNameInput.value !== cleaned) {
savePatchNameInput.value = cleaned;
}
});
}
function positionSavePatchModalNearButton() {
const dialog = savePatchModalEl.querySelector(".modal-dialog");
if (!dialog) return;
const rect = patchSaveActionButton.getBoundingClientRect();
const viewportWidth = window.innerWidth || document.documentElement.clientWidth || 0;
const viewportHeight = window.innerHeight || document.documentElement.clientHeight || 0;
const dialogWidth = Math.min(360, Math.max(280, viewportWidth - 24));
const estimatedHeight = 220;
let left = rect.left;
if (left + dialogWidth > viewportWidth - 12) {
left = viewportWidth - dialogWidth - 12;
}
if (left < 12) {
left = 12;
}
let top = rect.bottom + 8;
if (top + estimatedHeight > viewportHeight - 12) {
top = Math.max(12, rect.top - estimatedHeight - 8);
}
dialog.style.position = "fixed";
dialog.style.margin = "0";
dialog.style.width = dialogWidth + "px";
dialog.style.maxWidth = dialogWidth + "px";
dialog.style.left = left + "px";
dialog.style.top = top + "px";
dialog.style.transform = "none";
}
patchSaveActionButton.addEventListener("click", function() {
const channel = Number(window.current_synth || 1);
if (savePatchNameInput) {
let existingName = "";
if (Array.isArray(window.channel_patch_names) && typeof window.channel_patch_names[channel] === "string") {
existingName = String(window.channel_patch_names[channel] || "").trim();
}
savePatchNameInput.value = existingName;
}
positionSavePatchModalNearButton();
const modal = window.bootstrap.Modal.getOrCreateInstance(savePatchModalEl);
modal.show();
if (savePatchNameInput) {
setTimeout(function() {
savePatchNameInput.focus();
savePatchNameInput.select();
}, 120);
}
});
savePatchModalEl.addEventListener("shown.bs.modal", positionSavePatchModalNearButton);
window.addEventListener("resize", function() {
if (savePatchModalEl.classList.contains("show")) {
positionSavePatchModalNearButton();
}
});
if (savePatchConfirmButton && savePatchNameInput) {
savePatchConfirmButton.addEventListener("click", async function() {
const name = String(savePatchNameInput.value || "").trim();
if (!/^[A-Za-z0-9._-]{1,25}$/.test(name)) {
if (typeof show_alert === "function") {
show_alert("Patch name must be 1-25 chars: letters, numbers, dot, underscore, dash.");
}
savePatchNameInput.focus();
return;
}
if (typeof window.save_current_synth_patch_file !== "function") {
if (typeof show_alert === "function") {
show_alert("Save patch is not available.");
}
return;
}
savePatchConfirmButton.disabled = true;
try {
await window.save_current_synth_patch_file(name);
refreshPatchActiveNameLabel();
refreshSavePatchDirtyIndicator();
const modal = window.bootstrap.Modal.getOrCreateInstance(savePatchModalEl);
modal.hide();
savePatchNameInput.value = "";
} catch (e) {
if (typeof show_alert === "function") {
show_alert("Could not save patch.");
}
} finally {
savePatchConfirmButton.disabled = false;
}
});
}
}
if (patchRevertActionButton) {
patchRevertActionButton.addEventListener("click", async function() {
const channel = Number(window.current_synth || 1);
let patchName = null;
if (Array.isArray(window.channel_patch_names) && typeof window.channel_patch_names[channel] === "string") {
patchName = String(window.channel_patch_names[channel] || "").trim();
}
if (!patchName) {
if (typeof show_alert === "function") {
show_alert("No saved patch to revert to.");
}
return;
}
if (typeof window.load_saved_patch_file_into_current_channel !== "function") {
if (typeof show_alert === "function") {
show_alert("Revert is not available.");
}
return;
}
patchRevertActionButton.disabled = true;
try {
await window.load_saved_patch_file_into_current_channel(patchName + ".patch");
refreshPatchActiveNameLabel();
refreshSavePatchDirtyIndicator();
} catch (e) {
if (typeof show_alert === "function") {
show_alert("Could not revert patch. Saved file may be missing.");
}
} finally {
patchRevertActionButton.disabled = false;
}
});
}
if (patchClearChannelButton) {
patchClearChannelButton.addEventListener("click", async function() {
if (typeof window.clear_current_channel_patch !== "function") {
if (typeof show_alert === "function") {
show_alert("Clear patch is not available.");
}
return;
}
patchClearChannelButton.disabled = true;
try {
await window.clear_current_channel_patch();
refreshPatchActiveNameLabel();
refreshSavePatchDirtyIndicator();
} catch (e) {
if (typeof show_alert === "function") {
show_alert("Could not clear patch.");
}
} finally {
patchClearChannelButton.disabled = false;
}
});
}
if (typeof window.set_channel_active === "function") {
window.set_channel_active(1, true);
for (let ch = 2; ch <= 16; ch += 1) {
window.set_channel_active(ch, false);
}
}
if (Array.isArray(window.channel_control_mapping_sent)) {
window.channel_control_mapping_sent[1] = true;
}
syncActiveCheckboxForChannel();
const keyboard = document.getElementById("amy-keyboard");
if (keyboard) {
const noteNames = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"];
const flatMap = {
"DB": "C#",
"EB": "D#",
"GB": "F#",
"AB": "G#",
"BB": "A#"
};
const noteToMidi = function(note) {
if (typeof note !== "string") return null;
const cleaned = note.trim().toUpperCase();
const match = cleaned.match(/^([A-G]#?|[A-G]B)(-?\\d+)$/);
if (!match) return null;
const normalized = flatMap[match[1]] || match[1];
const noteIndex = noteNames.indexOf(normalized);
if (noteIndex < 0) return null;
const octave = Number(match[2]);
return (octave + 1) * 12 + noteIndex;
};
const freqToMidi = function(freq) {
if (!Number.isFinite(freq) || freq <= 0) return null;
return Math.round(69 + 12 * Math.log2(freq / 440));
};
const QwertyCtor = (window.QwertyHancock && (window.QwertyHancock.QwertyHancock || window.QwertyHancock.default)) || window.QwertyHancock;
if (!QwertyCtor) {
console.error("QwertyHancock constructor not found.");
return;
}
const qwerty = new QwertyCtor({
id: "amy-keyboard",
width: Math.min(900, keyboard.clientWidth || 900),
height: 140,
octaves: 2,
startNote: "C3",
musicalTyping: false,
whiteKeyColour: "#f8f8f8",
blackKeyColour: "#111",
activeColour: "#f2c94c",
borderColour: "#111"
});
qwerty.keyDown = function(note, freq) {
const midi = noteToMidi(note);
const midiFromFreq = freqToMidi(freq);
const finalMidi = Number.isFinite(midi) ? midi : midiFromFreq;
if (Number.isFinite(finalMidi)) {
amy_add_log_message("i"+window.current_synth+"l1n" + finalMidi);
}
if (typeof window.onKeyboardNote === "function") {
window.onKeyboardNote(finalMidi, note);
}
};
qwerty.keyUp = function(note, freq) {
const midi = noteToMidi(note);
const midiFromFreq = freqToMidi(freq);
const finalMidi = Number.isFinite(midi) ? midi : midiFromFreq;
if (Number.isFinite(finalMidi)) {
amy_add_log_message("i"+window.current_synth+"l0n" + finalMidi);
}
};
}
});
</script>
</body>
</html>
701e58161This file is pinned to the selected release. Download the original to open it in your design tool.