From 5ef14c0216589ab508dabb387e730b35ab9f7357 Mon Sep 17 00:00:00 2001 From: Francesco Luzzana Date: Mon, 3 Oct 2022 01:27:19 +0200 Subject: [PATCH] db refactor --- .gitignore | 5 +- init_db.py | 16 ++ schema.sql | 64 ++++++ static/css/global.css | 5 - static/css/instruments.css | 7 +- static/css/patch.css | 11 ++ static/css/patches.css | 5 + static/instruments/Bastl_Drum/model.yml | 48 ----- static/instruments/Bastl_Drum/panel.svg | 175 ---------------- .../patches/A_test_patch/A_test_patch.yml | 29 --- .../patches/Second_test/Second_test.yml | 135 ------------- .../instruments/Bastl_Kastle_v1.5/model.yml | 48 ----- .../instruments/Bastl_Kastle_v1.5/panel.svg | 174 ---------------- .../Bastl_Kastle_v1.5/patches/For_Pongi.yml | 66 ------- .../Bastl_Kastle_v1.5/patches/panel.svg | 175 ---------------- .../Bastl_Kastle_v1.5/patches/uzumaki.yml | 58 ------ static/instruments/Test_Panel/model.yml | 23 --- static/instruments/Test_Panel/panel.svg | 134 ------------- .../Test_Panel/patches/A_test_patch.yml | 69 ------- static/js/cables.js | 1 + static/js/panel.js | 2 + static/js/patch.js | 4 + templates/patch.html | 18 +- templates/patches.html | 18 +- workbook.py | 187 ++++++++++++------ 25 files changed, 264 insertions(+), 1213 deletions(-) create mode 100644 init_db.py create mode 100644 schema.sql delete mode 100644 static/instruments/Bastl_Drum/model.yml delete mode 100644 static/instruments/Bastl_Drum/panel.svg delete mode 100644 static/instruments/Bastl_Drum/patches/A_test_patch/A_test_patch.yml delete mode 100644 static/instruments/Bastl_Drum/patches/Second_test/Second_test.yml delete mode 100644 static/instruments/Bastl_Kastle_v1.5/model.yml delete mode 100644 static/instruments/Bastl_Kastle_v1.5/panel.svg delete mode 100644 static/instruments/Bastl_Kastle_v1.5/patches/For_Pongi.yml delete mode 100644 static/instruments/Bastl_Kastle_v1.5/patches/panel.svg delete mode 100644 static/instruments/Bastl_Kastle_v1.5/patches/uzumaki.yml delete mode 100644 static/instruments/Test_Panel/model.yml delete mode 100644 static/instruments/Test_Panel/panel.svg delete mode 100644 static/instruments/Test_Panel/patches/A_test_patch.yml create mode 100644 static/js/patch.js diff --git a/.gitignore b/.gitignore index 8e157bb..1574c69 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ venv/ -static/instruments/ \ No newline at end of file +static/cables/ +static/panels/ +static/snippets/ +database.db diff --git a/init_db.py b/init_db.py new file mode 100644 index 0000000..c26c73f --- /dev/null +++ b/init_db.py @@ -0,0 +1,16 @@ +import sqlite3 + +connection = sqlite3.connect('database.db') + +with open('schema.sql') as f: + connection.executescript(f.read()) + +cur = connection.cursor() + +cur.execute( + "INSERT INTO instruments (name, slug, description, panel) VALUES (?, ?, ?, ?)", + ('Test Instrument', 'test_instrument', 'The classic original the one we like to test', 'test_instrument.svg') + ) + +connection.commit() +connection.close() \ No newline at end of file diff --git a/schema.sql b/schema.sql new file mode 100644 index 0000000..4bb5f58 --- /dev/null +++ b/schema.sql @@ -0,0 +1,64 @@ +DROP TABLE IF EXISTS instruments; +DROP TABLE IF EXISTS params; +DROP TABLE IF EXISTS sockets; +DROP TABLE IF EXISTS instrument_param; +DROP TABLE IF EXISTS instrument_socket; +DROP TABLE IF EXISTS patches; +DROP TABLE IF EXISTS patch_param; +DROP TABLE IF EXISTS snippets; + +CREATE TABLE instruments ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + name TEXT NOT NULL, + slug TEXT NOT NULL, + description TEXT NOT NULL, + panel TEXT NOT NULL +); + +CREATE TABLE params ( + param_name TEXT NOT NULL PRIMARY KEY +); + +CREATE TABLE sockets ( + socket_name TEXT NOT NULL PRIMARY KEY +); + +CREATE TABLE instrument_param ( + instrument_id INTEGER NOT NULL, + param_name TEXT NOT NULL, + PRIMARY KEY (instrument_id, param_name) + ); + + CREATE TABLE instrument_socket ( + instrument_id INTEGER NOT NULL, + socket_name TEXT NOT NULL, + PRIMARY KEY (instrument_id, socket_name) + ); + +CREATE TABLE patches ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + name TEXT NOT NULL, + slug TEXT NOT NULL, + description TEXT NOT NULL, + cables TEXT NOT NULL, + instrument TEXT NOT NULL, + FOREIGN KEY (instrument) REFERENCES instruments(slug) +); + +CREATE TABLE patch_param ( + patch_id INTEGER NOT NULL, + param_name TEXT NOT NULL, + value TEXT NOT NULL, + PRIMARY KEY (patch_id, param_name) +); + +CREATE TABLE snippets ( + filename TEXT NOT NULL, + instrument TEXT NOT NULL, + patch_name TEXT NOT NULL, + description TEXT NOT NULL, + created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP +); + diff --git a/static/css/global.css b/static/css/global.css index 14ce9eb..475d59c 100644 --- a/static/css/global.css +++ b/static/css/global.css @@ -94,8 +94,3 @@ header .title { background: none; } - -svg #params, -svg #sockets { - display: none; -} diff --git a/static/css/instruments.css b/static/css/instruments.css index 3ec2c6d..be9fe54 100644 --- a/static/css/instruments.css +++ b/static/css/instruments.css @@ -1,5 +1,3 @@ - - main { padding: 0 8px; } @@ -43,6 +41,11 @@ main { height: 32px; } +svg #params, +svg #sockets { + display: none; +} + @media (max-width: 767px) { header { display: block; diff --git a/static/css/patch.css b/static/css/patch.css index 3bb9fcc..6bdfbec 100644 --- a/static/css/patch.css +++ b/static/css/patch.css @@ -62,3 +62,14 @@ height: 32px; display: inline-block; } + +svg #params, +svg #sockets { + display: none; +} + +.instrument .cables { + position: absolute; + top: 0; + left: 0; +} diff --git a/static/css/patches.css b/static/css/patches.css index a4de5ca..d6362c2 100644 --- a/static/css/patches.css +++ b/static/css/patches.css @@ -91,6 +91,11 @@ main { font-weight: normal; } +svg #params, +svg #sockets { + display: none; +} + @media (max-width: 767px) { header { display: block; diff --git a/static/instruments/Bastl_Drum/model.yml b/static/instruments/Bastl_Drum/model.yml deleted file mode 100644 index cab1306..0000000 --- a/static/instruments/Bastl_Drum/model.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Bastl Drum -slug: Bastl_Drum -description: The classic one, the one that is not broken -params: -- drum_mod -- drum -- pitch -- decay -- pitch_mod -- tempo_mod -- tempo -sockets: -- decay_3 -- decay_2 -- decay_1 -- noise_3 -- noises_2 -- noises_1 -- clk_3 -- clk_2 -- clk_1 -- lfo_3 -- lfo_2 -- lfo_1 -- drums_2 -- drums_1 -- pattern_3 -- pattern_2 -- pattern_1 -- i/o_right -- i/o_left -- trig_tempo_mod_3 -- trig_tempo_mod_2 -- trig_tempo_mod_1 -- trig_pitch_mod_3 -- trig_pitch_mod_2 -- trig_pitch_mod_1 -- trig_drum_mod_3 -- trig_drum_mod_2 -- trig_drum_mod_1 -- mode_minus -- mode_plus -- clk_in_2 -- clk_in_1 -- trig_in_2 -- trig_in_1 -- feed_2 -- feed_1 diff --git a/static/instruments/Bastl_Drum/panel.svg b/static/instruments/Bastl_Drum/panel.svg deleted file mode 100644 index 2c048ed..0000000 --- a/static/instruments/Bastl_Drum/panel.svg +++ /dev/null @@ -1,175 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/static/instruments/Bastl_Drum/patches/A_test_patch/A_test_patch.yml b/static/instruments/Bastl_Drum/patches/A_test_patch/A_test_patch.yml deleted file mode 100644 index e965b1a..0000000 --- a/static/instruments/Bastl_Drum/patches/A_test_patch/A_test_patch.yml +++ /dev/null @@ -1,29 +0,0 @@ -cables: '' -date: '2022-10-01' -decay: '98' -description: a patch to test -drum: '61' -drum_mod: '50' -name: A test patch -output: JBL Spearker -pitch: '50' -pitch_mod: '50' -routing: Drum to JBL -slug: A_test_patch -tempo: '50' -tempo_mod: '50' diff --git a/static/instruments/Bastl_Drum/patches/Second_test/Second_test.yml b/static/instruments/Bastl_Drum/patches/Second_test/Second_test.yml deleted file mode 100644 index eb26458..0000000 --- a/static/instruments/Bastl_Drum/patches/Second_test/Second_test.yml +++ /dev/null @@ -1,135 +0,0 @@ -cables: '' -date: '2022-02-16' -decay: '50' -description: just the second -drum: '100' -drum_mod: '50' -name: Second test -pitch: '50' -pitch_mod: '50' -slug: Second_test -tempo: '50' -tempo_mod: '50' diff --git a/static/instruments/Bastl_Kastle_v1.5/model.yml b/static/instruments/Bastl_Kastle_v1.5/model.yml deleted file mode 100644 index e53efd8..0000000 --- a/static/instruments/Bastl_Kastle_v1.5/model.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Bastl Kastle v1.5 -slug: Bastl_Kastle_v1.5 -description: The one we know -params: - - pitch_mod - - osc_pitch - - timbre_mod - - waveshape - - osc_timbre - - rate_mod - - lfo_rate -sockets: - - rate_mod_1 - - rate_mod_2 - - rate_mod_3 - - triangle_lfo_1 - - triangle_lfo_2 - - triangle_lfo_3 - - step_generator_1 - - step_generator_2 - - step_generator_3 - - square_lfo_1 - - square_lfo_2 - - square_lfo_3 - - osc_out_1 - - osc_out_2 - - osc_out_3 - - timbre_mod_1 - - timbre_mod_2 - - timbre_mod_3 - - mode_static_minus - - mode_static_plus - - lfo_reset_1 - - lfo_reset_2 - - bit_in_1 - - bit_in_2 - - left_input - - right_input - - mode_minus - - mode_plus - - secondary_osc_out_1 - - secondary_osc_out_2 - - pitch_mode_1 - - pitch_mode_2 - - pitch_mode_3 - - waveshape_1 - - waveshape_2 - - waveshape_3 diff --git a/static/instruments/Bastl_Kastle_v1.5/panel.svg b/static/instruments/Bastl_Kastle_v1.5/panel.svg deleted file mode 100644 index 61fbd4f..0000000 --- a/static/instruments/Bastl_Kastle_v1.5/panel.svg +++ /dev/null @@ -1,174 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/static/instruments/Bastl_Kastle_v1.5/patches/For_Pongi.yml b/static/instruments/Bastl_Kastle_v1.5/patches/For_Pongi.yml deleted file mode 100644 index 854bfbd..0000000 --- a/static/instruments/Bastl_Kastle_v1.5/patches/For_Pongi.yml +++ /dev/null @@ -1,66 +0,0 @@ -cables: '' -date: '2022-06-26' -description: "\U0001F3B5" -lfo_rate: '100' -name: For Pongi -osc_pitch: '0' -osc_timbre: '25' -pitch_mod: '50' -rate_mod: '20' -slug: For_Pongi -timbre_mod: '50' -waveshape: '74' diff --git a/static/instruments/Bastl_Kastle_v1.5/patches/panel.svg b/static/instruments/Bastl_Kastle_v1.5/patches/panel.svg deleted file mode 100644 index 2c048ed..0000000 --- a/static/instruments/Bastl_Kastle_v1.5/patches/panel.svg +++ /dev/null @@ -1,175 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/static/instruments/Bastl_Kastle_v1.5/patches/uzumaki.yml b/static/instruments/Bastl_Kastle_v1.5/patches/uzumaki.yml deleted file mode 100644 index bcf4439..0000000 --- a/static/instruments/Bastl_Kastle_v1.5/patches/uzumaki.yml +++ /dev/null @@ -1,58 +0,0 @@ -cables: '' -date: '2022-06-26' -description: Eheheh -lfo_rate: '50' -name: '@@ uzumaki' -osc_pitch: '50' -osc_timbre: '50' -pitch_mod: '100' -rate_mod: '50' -slug: uzumaki -timbre_mod: '50' -waveshape: '50' diff --git a/static/instruments/Test_Panel/model.yml b/static/instruments/Test_Panel/model.yml deleted file mode 100644 index dfa4b28..0000000 --- a/static/instruments/Test_Panel/model.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Test Panel -slug: Test_Panel -description: it's another test -params: -- soup -- goat_cheese -- pasta -- tequila -- rice_rolls -- lemon -- salt -- shot_rate -- thai_curry -- linzen -- kip -- leek -- stuffed_peppers -- pizza -- kikkerverten -sockets: -- lunch_3 -- breakfast -- dinner_2 diff --git a/static/instruments/Test_Panel/panel.svg b/static/instruments/Test_Panel/panel.svg deleted file mode 100644 index 4370563..0000000 --- a/static/instruments/Test_Panel/panel.svg +++ /dev/null @@ -1,134 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/static/instruments/Test_Panel/patches/A_test_patch.yml b/static/instruments/Test_Panel/patches/A_test_patch.yml deleted file mode 100644 index 73e058b..0000000 --- a/static/instruments/Test_Panel/patches/A_test_patch.yml +++ /dev/null @@ -1,69 +0,0 @@ -cables: '' -date: '2022-06-26' -description: just for fun -goat_cheese: '50' -kikkerverten: '50' -kip: '50' -leek: '50' -lemon: '50' -linzen: '50' -name: A test patch -pasta: '50' -pizza: '50' -rice_rolls: '50' -salt: '50' -shot_rate: '50' -slug: A_test_patch -soup: '50' -stuffed_peppers: '50' -tequila: '50' -thai_curry: '50' diff --git a/static/js/cables.js b/static/js/cables.js index 5187fa0..d577d7f 100644 --- a/static/js/cables.js +++ b/static/js/cables.js @@ -6,6 +6,7 @@ var bufferSize = 10; var svgElement = document.getElementById("svgElement"); svgElement.setAttribute("viewBox", `0 0 ${svgElement.clientWidth} ${svgElement.clientHeight}`); +svgElement.setAttribute("xmlns", "http://www.w3.org/2000/svg"); var rect = svgElement.getBoundingClientRect(); var path = null; diff --git a/static/js/panel.js b/static/js/panel.js index 01b0332..8ae94cd 100644 --- a/static/js/panel.js +++ b/static/js/panel.js @@ -225,7 +225,9 @@ class Panel { createCables() { let cables = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + cables.classList.add("cables"); + cables.setAttribute("xmlns", "http://www.w3.org/2000/svg"); cables.setAttribute("width", this.width); cables.setAttribute("height", this.height); cables.setAttribute("viewBox", `0 0 ${this.width} ${this.height}`); diff --git a/static/js/patch.js b/static/js/patch.js new file mode 100644 index 0000000..84ca42b --- /dev/null +++ b/static/js/patch.js @@ -0,0 +1,4 @@ +const container = document.querySelector("#panel-container"); +const svg = container.querySelector("svg").outerHTML; + +let panel = new Panel(svg, container); diff --git a/templates/patch.html b/templates/patch.html index af7434c..adcacf0 100644 --- a/templates/patch.html +++ b/templates/patch.html @@ -9,6 +9,11 @@ href="{{ url_for('static', filename='css/global.css') }}" /> + + + + +
@@ -40,7 +45,14 @@
- {{panel|safe}} {% if patch['cables'] %} {{patch['cables']|safe}} {% endif %} +
{{panel|safe}}
+ + {% if patch['cables'] %} + + {% endif %}
@@ -53,9 +65,9 @@ {% for snippet in snippets %}
  • {{ '%02d' % loop.index }} -

    {{snippet}}

    +

    {{snippet['description']}}

    diff --git a/templates/patches.html b/templates/patches.html index a399a86..602be04 100644 --- a/templates/patches.html +++ b/templates/patches.html @@ -2,7 +2,7 @@ - {{instrument}} + {{instrument['name']}} / Instruments / -

    {{instrument}}

    +

    {{instrument['name']}}