How to use the st/music.noteStaffOffset 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 / staff / ledger_lines.es6 View on Github external
renderLedgerLinesForNote(note, idx) {
    const props = this.props

    let offset = noteStaffOffset(note.note)
    let outside = offset > props.upperRow || offset < props.lowerRow
    if (!outside) {
      return
    }

    let letterDelta = 0
    let below = false

    // above
    if (offset > props.upperRow) {
      letterDelta = offset - props.upperRow;
    }

    // below
    if (offset < props.lowerRow) {
      letterDelta = props.lowerRow - offset;
github leafo / sightreading.training / static / js / components / staff / whole_notes.es6 View on Github external
renderNote(note, idx, notesByColumn) {
    const props = this.props
    let key = props.keySignature

    let noteName = key.enharmonic(note.note)

    let pitch = parseNote(noteName)
    let row = noteStaffOffset(noteName)

    let fromTop = props.upperRow - row;
    let offsetLeft = props.offsetLeft || 0
    let left = offsetLeft + note.getStart() * this.props.pixelsPerBeat

    let column = notesByColumn[note.getStart().toString()]

    let style = {
      top: `${Math.floor(fromTop * 25/2)}%`,
      left: `${left}px`
    }

    let outside = row > props.upperRow || row < props.lowerRow
    let accidentals = key.accidentalsForNote(noteName)

    let noteClasses = null
github leafo / sightreading.training / static / js / components / staff_notes.es6 View on Github external
let toRow = n =>
      noteStaffOffset(this.props.keySignature.enharmonic(n))
github leafo / sightreading.training / static / js / components / staves.es6 View on Github external
{sigNotes.map((n, i) => {
        let fromTop = topOffset - noteStaffOffset(n);
        let style = {
          top: `${Math.floor(fromTop * 25/2)}%`,
          left: `${i * 20}px`
        }

        return <img src="{src}" style="{style}" data-note="{n}">;
      })}
    ;
github leafo / sightreading.training / static / js / components / staves.es6 View on Github external
this.props.notes.forEach(note =&gt; {
        if (this.props.filterPitch) {
          let pitch = parseNote(note.note)
          if (!this.props.filterPitch(pitch)) {
            return
          }
        }

        let row = noteStaffOffset(note.note)

        if (min == null || row &lt; min) {
          min = row
        }

        if (max == null || row &gt; max) {
          max = row
        }
      })
    }
github leafo / sightreading.training / static / js / components / staff / bar_notes.es6 View on Github external
renderNote(note, idx) {
    const key = this.props.keySignature
    let noteName = note.note
    let pitch = parseNote(noteName)

    let pixelsPerBeat = this.props.pixelsPerBeat 
    let row = noteStaffOffset(noteName)

    let fromTop = this.props.upperRow - row
    let fromLeft = note.getStart() * pixelsPerBeat + 2
    let width = note.getRenderStop() * pixelsPerBeat - fromLeft - 4

    let accidentals = key.accidentalsForNote(noteName)

    let style = {
      top: `${Math.floor(fromTop * 25/2)}%`,
      left: `${this.props.offsetLeft + fromLeft}px`,
      width: `${width}px`
    }

    let outsideLoop = false

    if (this.props.loopLeft != null && this.props.loopRight != null) {