Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
convertHeldToSongNotes() {
if (!this.props.heldNotes) {
return []
}
let notes = new SongNoteList()
let dur = 40 / this.props.noteWidth
// notes that are held down but aren't correct
Object.keys(this.props.heldNotes)
.filter((note) => !this.props.notes.inHead(note))
.forEach((note, idx) => {
notes.push(new SongNote(note, 0, dur))
})
return this.filterVisibleNotes(notes)
}
it("creates an empty song notes", function() {
let song = new SongNoteList()
expect(song.getStopInBeats()).toEqual(0)
})
it("gets duration from song with notes", function() {
let song = new SongNoteList()
song.push(new SongNote("C5", 2, 1))
song.push(new SongNote("D5", 0, 1))
expect(song.getStartInBeats()).toEqual(0)
expect(song.getStopInBeats()).toEqual(3)
})
filterVisibleNotes(notes) {
if (notes.length == 0) {
return notes
}
if (!this.props.filterPitch) {
return notes
}
let out = new SongNoteList()
notes.forEach(n => {
let pitch = parseNote(n.note)
if (this.props.filterPitch(pitch)) {
out.push(n)
}
})
return out
}
playCurrentInterval() {
let current = this.state.currentMelody
if (!current) {
return
}
let song = this.state.melodySongs[current.song]
let first = new SongNoteList()
let note1 = song[0].clone()
let note2 = song[1].clone()
note1.duration = 1
note2.duration = 1
if (this.state.autoplayIntervalOrder == "reverse") {
note1.start = 1
note2.start = 0
} else if (this.state.autoplayIntervalOrder == "harmonic") {
note1.start = 0
note2.start = 0
} else {
note1.start = 0
playCurrentRoot() {
let current = this.state.currentMelody
if (!current) {
return
}
let song = this.state.melodySongs[current.song]
let first = new SongNoteList()
let note = song[0].clone()
note.duration = 1
first.push(note)
return this.playSong(first)
}
convertToSongNotes() {
let notes = new SongNoteList()
let beat = 0
let dur = 40 / this.props.noteWidth
let noteClasses = {}
let toRow = n =>
noteStaffOffset(this.props.keySignature.enharmonic(n))
let appendClass = (note, cls) => {
if (noteClasses[note.id]) {
noteClasses[note.id].push(cls)
} else {
noteClasses[note.id] = [cls]
}
}