summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/index.js20
-rw-r--r--client/lib/scales.js15
2 files changed, 29 insertions, 6 deletions
diff --git a/client/index.js b/client/index.js
index 5fb08fc..6879688 100644
--- a/client/index.js
+++ b/client/index.js
@@ -23,8 +23,6 @@ var loop = new Tone.Sequence(function(time, col){
}
}, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], "16n")
-nx.colorize('#f4d142')
-
nx.onload = () => {
grid = nx.widgets.grid
grid.sequenceMode = true
@@ -49,8 +47,26 @@ nx.onload = () => {
nx.widgets.flip.on('*', e => e.press && flip())
nx.widgets.flop.on('*', e => e.press && flop())
+ nx.colorize('#f4d142')
+
+ scales.build()
+ scales.onChange((s) => {
+ const labels = document.querySelector('#labels')
+ let str = ''
+ for (let i = 0; i < noteCount; i++) {
+ let n = i % s.scale.length
+ str += (n+1) + '<br>'
+ }
+ labels.innerHTML = str
+ })
+ scales.pick(0)
+
loop.start()
Tone.Transport.bpm.value = 108
+ nx.widgets.tempo.min = 10
+ nx.widgets.tempo.max = 1000
+ nx.widgets.tempo.set({ value: 108 })
+ nx.widgets.tempo.on('*', e => Tone.Transport.bpm.value = nx.widgets.tempo.val.value )
Tone.Transport.start()
}
diff --git a/client/lib/scales.js b/client/lib/scales.js
index 1462504..fd7b5a7 100644
--- a/client/lib/scales.js
+++ b/client/lib/scales.js
@@ -120,6 +120,7 @@ const scales = [
].map( (opt) => new Intonation(opt) )
let scale = scales[0]
+let handleChange = function(){}
function build () {
scales.forEach( (scale, i) => {
@@ -127,24 +128,30 @@ function build () {
scale.heading.innerHTML = scale.name
scale.heading.classList.add('heading')
scale.heading.addEventListener('click', function(){
- set_scale(i)
+ pick(i)
})
scale_list.appendChild(scale.heading)
})
- set_scale(0)
+ pick(0)
}
-function set_scale (i){
+function pick (i){
if (scale) {
scale.heading.classList.remove('selected')
}
scale = scales[i]
scale.heading.classList.add('selected')
+ handleChange(scale)
}
function current () {
return scale
}
-export default { scales, current, build }
+function onChange (fn) {
+ handleChange = fn
+}
+
+
+export default { scales, current, build, pick, onChange }