summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/index.js14
-rw-r--r--client/lib/scales.js12
2 files changed, 16 insertions, 10 deletions
diff --git a/client/index.js b/client/index.js
index 38f8410..35faf17 100644
--- a/client/index.js
+++ b/client/index.js
@@ -35,6 +35,12 @@ nx.onload = () => {
grid.resize(480, 640)
grid.draw()
+ nx.widgets.scale.choices = scales.names()
+ nx.widgets.scale.init()
+ nx.widgets.scale.on('*', e => scales.pick(e.value))
+ scales.onChange((s) => { buildLabels() })
+ buildLabels()
+
grid.on('*', e => ('level' in e) && buildLabels())
nx.widgets.shiftUp.on('*', e => e.press && shiftUp())
nx.widgets.shiftDown.on('*', e => e.press && shiftDown())
@@ -51,12 +57,6 @@ nx.onload = () => {
nx.colorize('#f4d142')
- scales.build()
- scales.onChange((s) => {
- buildLabels()
- })
- scales.pick(0)
-
loop.start()
Tone.Transport.bpm.value = 108
nx.widgets.tempo.min = 10
@@ -78,10 +78,12 @@ function buildLabels () {
let index = noteCount - i - 12
let n = mod(index, scaleCount)
let ns = (n+1)
+ /*
if (ns == 1) {
let octave = (index / scaleCount)
ns = ns + '<small>' + octave + '</small>'
}
+ */
if (subScale.includes(n)) {
str += '<b>' + (ns) + '</b><br>'
}
diff --git a/client/lib/scales.js b/client/lib/scales.js
index fd7b5a7..8480f9e 100644
--- a/client/lib/scales.js
+++ b/client/lib/scales.js
@@ -136,12 +136,12 @@ function build () {
pick(0)
}
-function pick (i){
+function pick (i) {
if (scale) {
- scale.heading.classList.remove('selected')
+ scale.heading && scale.heading.classList.remove('selected')
}
scale = scales[i]
- scale.heading.classList.add('selected')
+ scale.heading && scale.heading.classList.add('selected')
handleChange(scale)
}
@@ -153,5 +153,9 @@ function onChange (fn) {
handleChange = fn
}
+function names () {
+ return scales.map( scale => scale.name )
+}
+
-export default { scales, current, build, pick, onChange }
+export default { scales, current, build, pick, names, onChange }