How to use the st/music.KeySignature.forCount function in st

To help you get started, we’ve selected a few st examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github leafo / sightreading.training / static / js / components / song_editor.es6 View on Github external
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 = "+"
      }
github leafo / sightreading.training / static / js / components / pages / play_along_page.es6 View on Github external
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),
github leafo / sightreading.training / static / js / components / pages / play_along_page.es6 View on Github external
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
      }
github leafo / sightreading.training / static / js / components / song_editor.es6 View on Github external
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: {
github leafo / sightreading.training / static / js / components / pages / play_along_page.es6 View on Github external
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>
github leafo / sightreading.training / static / js / components / pages / play_along_page.es6 View on Github external
render() {
    let keySignature = KeySignature.forCount(0)

    if (this.state.song &amp;&amp; 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>
    }