How to use the st/song_note_list.SongNoteList 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_notes.es6 View on Github external
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)
  }
github leafo / sightreading.training / static / spec / song_spec.es6 View on Github external
it("creates an empty song notes", function() {
    let song = new SongNoteList()
    expect(song.getStopInBeats()).toEqual(0)
  })
github leafo / sightreading.training / static / spec / song_spec.es6 View on Github external
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)
  })
github leafo / sightreading.training / static / js / components / staff_notes.es6 View on Github external
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
  }
github leafo / sightreading.training / static / js / components / ear_training / melody_recognition_exercise.es6 View on Github external
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
github leafo / sightreading.training / static / js / components / ear_training / melody_recognition_exercise.es6 View on Github external
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)
  }
github leafo / sightreading.training / static / js / components / staff_notes.es6 View on Github external
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]
      }
    }