diff options
author | Joris | 2022-06-21 07:59:57 +0200 |
---|---|---|
committer | Joris | 2022-06-21 07:59:57 +0200 |
commit | 46f39fa93fa99eef2691d6dc905b9d083eb170cb (patch) | |
tree | 1d39b1b358a49a4c194dbf852cf80b5f07629361 /src/view | |
parent | 5944be94dfd221f41cfb5e60e007c159b617f5dc (diff) |
Add more drum sounds
Diffstat (limited to 'src/view')
-rw-r--r-- | src/view/sequencer.ts | 40 |
1 files changed, 11 insertions, 29 deletions
diff --git a/src/view/sequencer.ts b/src/view/sequencer.ts index bc26e69..f7e397f 100644 --- a/src/view/sequencer.ts +++ b/src/view/sequencer.ts @@ -7,27 +7,15 @@ import * as block from 'view/sequencer/block' export function view() { let index = -1 - let columns = [{ - [Sound.Bass]: true, - [Sound.Snare]: false, - [Sound.HitHatClosed]: false, - }] + let columns = [soundsLib.record(sound => sound == Sound.Kick)] let blocksNode = h('div', { className: 'g-Sequencer__Blocks' }, - block.column([ - { - checked: false, - onCheck: checked => columns[0][Sound.HitHatClosed] = checked - }, - { - checked: false, - onCheck: checked => columns[0][Sound.Snare] = checked - }, - { - checked: true, - onCheck: checked => columns[0][Sound.Bass] = checked - } - ]) + block.column( + soundsLib.all().map(sound => ({ + checked: sound == Sound.Kick, + onCheck: checked => columns[0][sound] = checked + })) + ) ) let onNextStep = (sounds: soundsLib.Sounds) => { @@ -69,11 +57,7 @@ export function view() { columns.pop() }, onAdd: index => { - columns.push({ - [Sound.Bass]: false, - [Sound.Snare]: false, - [Sound.HitHatClosed]: false, - }) + columns.push(soundsLib.record(sound => false)) blocksNode.appendChild(block.column( soundsLib.all().map(sound => ({ checked: false, @@ -86,9 +70,7 @@ export function view() { { className: 'g-Sequencer__Grid' }, h('ol', { className: 'g-Sequencer__Column' }, - soundItem('Hit-hat (closed)', Sound.HitHatClosed), - soundItem('Snare', Sound.Snare), - soundItem('Bass', Sound.Bass) + ...soundsLib.all().map(soundItem) ), blocksNode ) @@ -97,13 +79,13 @@ export function view() { return sequencer } -function soundItem(name: string, sound: Sound): Element { +function soundItem(sound: Sound): Element { return h('li', { onclick: async () => { let sounds = await soundsLib.load() soundsLib.play(sounds, sound) } }, - name + soundsLib.toString(sound) ) } |