From 35e57671f2cf055bd096e1d53b511efb604d683a Mon Sep 17 00:00:00 2001 From: s-ol Date: Mon, 21 Mar 2022 23:02:42 +0100 Subject: add various labeling schemes --- app/app.js | 74 ++++++++++++++++++++++++++++++++++++++++++++---------------- app/notes.js | 17 ++++---------- 2 files changed, 59 insertions(+), 32 deletions(-) diff --git a/app/app.js b/app/app.js index d85d9c5..5074285 100644 --- a/app/app.js +++ b/app/app.js @@ -46,24 +46,51 @@ const Hexagon = ({ x, y, children, state, note, major, scale, noteon, noteoff }) ); }; +// B A +// A B A C B +// o C o o +// C + + const layouts = { wicki_hayden: { major: 'row', map: ([x, y], [w, h]) => { - let note = 48 + 2 * x + 6 * y; + // A = 5 + // B = 7 + // C = 2 = x + // A + B = 12 = y + let note = 41 + 2 * x + 6 * y; if (y % 2 == 0) note += 1; return note; }, }, harmonic: { + // A = 3 + // B = 7 = y + // C = 4 + // C - A = 1 = x + + // A = 7 = y + // B = 4 + // C = -3 + // B + C = 1 = x major: 'col', map: ([x, y], [w, h]) => { let note = 48 + x * 0.5 + y * 7; - if (x % 2 === 1) note += 3.5; + if (x % 2 === 1) note -= 3.5; return note; }, }, gerhard: { + // A = -3 + // B = 1 + // C = 4 + // + // A = 1 = y + // B = 4 + // C = 3 + // B + C = 7 = x major: 'col', map: ([x, y], [w, h]) => { let note = 48 + x * 3.5 + y; @@ -101,7 +128,7 @@ const tallyup = (steps, offset=0) => { }; }; -const Keyboard = ({ w, h, layout: { major, map }, showMidi, state, scale, noteon, noteoff }) => ( +const Keyboard = ({ w, h, layout: { major, map }, state, scale, labels, noteon, noteoff }) => (
- {showMidi ? note : notes.music[note % 12]} + {labels ? labels[note % 12] : note} ); }) @@ -217,6 +244,7 @@ export default class App extends React.Component { state = { layout: 'wicki_hayden', scale: 'major', + labels: 'english', offset: 60, state: {}, w: 12, @@ -270,13 +298,12 @@ export default class App extends React.Component { this.send(NOTE_OFF, note); } - set(key) { - return (e) => { - let value = e.target.value; - if (key === 'w' || key === 'h') value = +value; - this.setState({ [key]: value }); - }; - } + set = (e) => { + const key = e.target.name; + let value = e.target.value; + if (key === 'w' || key === 'h') value = +value; + this.setState({ [key]: value }); + }; onoffset = (offset) => (e) => this.setState({ offset }); @@ -319,8 +346,8 @@ export default class App extends React.Component { } render() { - const { configure, showMidi } = this.props; - const { w, h, scale, offset, layout, state } = this.state; + const { configure } = this.props; + const { w, h, scale, layout, labels, offset, state } = this.state; const chord = Object.entries(state).filter(([note, on]) => on).map(([k, _]) => k); chord.sort(); @@ -333,18 +360,27 @@ export default class App extends React.Component {
-
+
+ + +
- @@ -363,9 +399,9 @@ export default class App extends React.Component {
- + {'x'} - +
@@ -376,9 +412,9 @@ export default class App extends React.Component { h={h} noteon={this.noteon.bind(this)} noteoff={this.noteoff.bind(this)} - showMidi={showMidi} layout={layouts[layout]} scale={scale !== "none" && offset !== null && tallyup(scales[scale], offset)} + labels={notes.labels[this.state.labels]} offset={offset} state={state} /> diff --git a/app/notes.js b/app/notes.js index 3d71a41..bd124a5 100644 --- a/app/notes.js +++ b/app/notes.js @@ -1,16 +1,7 @@ -export const music = { - 11: 'B', - 10: 'A#', - 9: 'A', - 8: 'G#', - 7: 'G', - 6: 'F#', - 5: 'F', - 4: 'E', - 3: 'D#', - 2: 'D', - 1: 'C#', - 0: 'C', +export const labels = { + english: 'C C# D D# E F F# G G# A A# B'.split(' '), + german: 'C C# D D# E F F# G G# A A# H'.split(' '), + sol: 'do do# re re# mi fa fa# sol sol# la la# si'.split(' '), }; export const key2midi = { -- cgit v1.2.3