Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let input = this.codeInputRef.current
if (!input) {
return
}
let code = this.state.code
let selectionStart = input.selectionStart
let selectionEnd = input.selectionEnd
let before = code.substring(0, input.selectionStart)
let after = code.substring(input.selectionEnd, code.length)
let keySignature = KeySignature.forCount(0)
if (this.props.songNotes && this.props.songNotes.metadata) {
keySignature = KeySignature.forCount(this.props.songNotes.metadata.keySignature || 0)
}
let [, noteName, , octave] = note.match(/([A-G])(#|b)?(\d+)/)
let accidental = ""
switch (keySignature.accidentalsForNote(note)) {
case 0: {
accidental = "="
break
}
case 1: {
accidental = "-"
}
case -1: {
accidental = "+"
}
renderTracks() {
if (!this.state.song) {
return null
}
let keySignature = KeySignature.forCount(0)
if (this.state.song && this.state.song.metadata) {
keySignature = KeySignature.forCount(this.state.song.metadata.keySignature)
}
let renderedTracks = this.state.song.tracks.filter(t => !!t).map((track, idx) => {
let staff = track.fittingStaff()
let staffType = STAVES.find(s => s.name == staff)
if (!staffType) {
return
}
if (this.state.enabledTracks[idx] == false) {
return
}
let staffProps = {
ref: this.getTrackRef(idx),
renderTracks() {
if (!this.state.song) {
return null
}
let keySignature = KeySignature.forCount(0)
if (this.state.song && this.state.song.metadata) {
keySignature = KeySignature.forCount(this.state.song.metadata.keySignature)
}
let renderedTracks = this.state.song.tracks.filter(t => !!t).map((track, idx) => {
let staff = track.fittingStaff()
let staffType = STAVES.find(s => s.name == staff)
if (!staffType) {
return
}
if (this.state.enabledTracks[idx] == false) {
return
}
pressNote(note) {
let input = this.codeInputRef.current
if (!input) {
return
}
let code = this.state.code
let selectionStart = input.selectionStart
let selectionEnd = input.selectionEnd
let before = code.substring(0, input.selectionStart)
let after = code.substring(input.selectionEnd, code.length)
let keySignature = KeySignature.forCount(0)
if (this.props.songNotes && this.props.songNotes.metadata) {
keySignature = KeySignature.forCount(this.props.songNotes.metadata.keySignature || 0)
}
let [, noteName, , octave] = note.match(/([A-G])(#|b)?(\d+)/)
let accidental = ""
switch (keySignature.accidentalsForNote(note)) {
case 0: {
accidental = "="
break
}
case 1: {
accidental = "-"
}
case -1: {
render() {
let keySignature = KeySignature.forCount(0)
if (this.state.song && this.state.song.metadata) {
keySignature = KeySignature.forCount(this.state.song.metadata.keySignature)
}
let songError = null
if (this.state.songError) {
songError = <div>
<div>
<strong>There was an error loading the song: </strong>
{this.state.songError}
</div>
</div>
}
let renderedTracks = this.renderTracks()
return <div></div>
render() {
let keySignature = KeySignature.forCount(0)
if (this.state.song && this.state.song.metadata) {
keySignature = KeySignature.forCount(this.state.song.metadata.keySignature)
}
let songError = null
if (this.state.songError) {
songError = <div>
<div>
<strong>There was an error loading the song: </strong>
{this.state.songError}
</div>
</div>
}