Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onMidiMessage(message) {
let [raw, pitch, velocity] = message.data;
let cmd = raw >> 4,
channel = raw & 0xf,
type = raw & 0xf0;
let n = noteName(pitch)
if (NOTE_EVENTS[type] == "noteOn") {
if (velocity == 0) {
this.releaseNote(n);
} else if (!document.hidden) { // ignore when the browser tab isn't active
this.pressNote(n);
}
}
if (NOTE_EVENTS[type] == "noteOff") {
this.releaseNote(n);
}
}
onMidiMessage(message) {
let [raw, pitch, velocity] = message.data;
let cmd = raw >> 4,
channel = raw & 0xf,
type = raw & 0xf0;
let n = noteName(pitch)
if (NOTE_EVENTS[type] == "noteOn") {
if (velocity == 0) {
this.noteOff(n);
} else if (!document.hidden) { // ignore when the browser tab isn't active
this.noteOn(n, velocity);
}
}
if (NOTE_EVENTS[type] == "noteOff") {
this.noteOff(n);
}
if (NOTE_EVENTS[type] == "dataEntry") {
if (pitch == 64) {
if (velocity > 0) {
start, stop - start)
)
break
case 3:
out.push(
new SongNote(chordNotes[1], start, stop - start)
)
break
}
})
for (let note of out) {
while (parseNote(note.note) >= maxPitch) {
// shift everything done by octave
for (let note of out) {
note.note = noteName(parseNote(note.note) - 12)
}
}
}
return out
}
}
transpose(semitones) {
return new SongNote(
noteName(parseNote(this.note) + semitones), this.start, this.duration
)
}
this.inDivisions(blockStart, blockStop, 3, (start, stop, k) => {
let d = (stop - start) / 2
let one = chordNotes[0]
let two = chordNotes[2]
if (parseNote(two) >= maxPitch) {
one = noteName(parseNote(chordNotes[2]) - 12)
two = chordNotes[0]
}
switch (k) {
case 0:
out.push(
new SongNote(one, start, d * 3 )
)
break
case 1:
out.push(
new SongNote(one, start + d, d)
)
break
case 2:
out.push(
let currentValue = this.cachedSettings[input.name]
let options = []
for (let i=input.max; i >= input.min; i--) {
options.push(noteName(i))
}
return <div>
<label>
Note
<select> {
this.updateInputValue(input, parseNote(value))
}}
value={noteName(currentValue)}
options={options.map(name => ({ value: name, name }))}
/>
}
</select></label></div>
renderSongPlayer() {
let current = this.state.currentMelody
let currentSongTools
if (current) {
let currentSong = this.state.melodySongs[current.song]
let stopSong
if (this.state.playingTimer && !this.state.autoplayTimer) {
stopSong = <button type="button"> this.state.playingTimer.stop() }>Stop</button>
}
let firstNote = noteName(parseNote(currentSong[0].note) + this.state.playbackTranspose)
let disabled = !!(this.state.playing || this.state.autoplayTimer)
let title = `${current.interval} - ${current.title} (${firstNote})`
if (this.state.autoplayState == "playingInterval") {
title = "Listen to interval..."
}
currentSongTools = <div>
<div>{title}</div>
<div>
<button type="button" disabled="{disabled}"> {
this.playCurrentRoot()</button></div></div>
function staffRange(staff, noteRange) {
if (noteRange) {
return [
noteName(Math.max(noteRange[0], parseNote(staff.range[0]))),
noteName(Math.min(noteRange[1], parseNote(staff.range[1])))
]
} else {
return staff.range
}
}
let currentValue = this.cachedSettings[input.name]
let [min, max] = currentValue
let possibleMin = []
let possibleMax = []
let staffMin, staffMax
if (this.props.currentStaff) {
let staff = this.props.currentStaff
staffMin = parseNote(staff.range[0])
staffMax = parseNote(staff.range[1])
}
for (let i=input.max; i >= input.min; i--) {
let iName = noteName(i)
if (i < staffMin) { continue }
if (i > staffMax) { continue }
if (i >= min) {
possibleMax.push(iName)
}
if (i <= max) {
possibleMin.push(iName)
}
}
return <div>
<label>
Min</label></div>
let min = parseNote(this[0].note)
let max = min
for (let songNote of this) {
let pitch = parseNote(songNote.note)
if (pitch < min) {
min = pitch
}
if (pitch > max) {
max = pitch
}
}
return [noteName(min), noteName(max)]
}