Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(keySignature, opts={}) {
super(keySignature, opts)
let keys = KeySignature.allKeySignatures()
this.chordToKeys = {}
for (let key of keys) {
for (let chord of new MajorScale(key).allChords(this.noteCount)) {
let cName = chord.toString()
this.chordToKeys[cName] = this.chordToKeys[cName] || []
this.chordToKeys[cName].push(key)
}
}
}
setupNext() {
let sigs = KeySignature.allKeySignatures().filter(ks =>
this.props.settings.keySignatures["" + ks.count]
)
let notes = 3
let keySignature = sigs[this.rand.int() % sigs.length]
if (!keySignature) {
this.setState({
currentCard: null
})
return
}
if (!this.generators) {
this.generators = {}
renderKeys() {
let keyButton = (key) =>
<button> {
this.props.setKeySignature(key)
}}
className={classNames("toggle_option", {
active: this.props.currentKey.name() == key.name()
})}
key={key.name()}>
{key.name()}
</button>
return KeySignature.allKeySignatures().concat([
new ChromaticKeySignature()
]).map(key => keyButton(key))
}
}
render() {
let settings = this.props.currentSettings
return <div>
<section>
<h4>Key signature</h4>
{KeySignature.allKeySignatures().map(ks => {
let count = "" + ks.count
return <label>
<input checked="{settings.keySignatures[count]">
this.props.updateSettings({
...settings,
keySignatures: {
...settings.keySignatures,
[count]: !settings.keySignatures[count]
}
})
}
type="checkbox" />
{" "}
{ks.name()}</label></section></div>