How to use the st/song_note_list.SongNote 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 / spec / song_spec.es6 View on Github external
it("gets notes in time range", function() {
    let song = SongNoteList.newSong([
      ["C5", 0, 1],
      ["D5", 1, 1],
      ["E5", 3, 1],
      ["D5", 5, 1],

      ["F5", 1, 5], // overlap (1 - 6)
      ["F5", 1, 3], // overlap start (1 - 4)
      ["F5", 4, 2], // overlap end (4 - 6)
    ])

    let range = song.notesInRange(3,5)
    matchNotes(range, [
      new SongNote("E5", 3, 1),
      new SongNote("F5", 1, 5),
      new SongNote("F5", 1, 3),
      new SongNote("F5", 4, 2),
    ])
  })
})
github leafo / sightreading.training / static / spec / parser_spec.es6 View on Github external
it("loads notes with timing", function() {
    let song = SongParser.load(`
      dt
      m0 c5 c5 c5
      m0 g5 a5 g5
      ht
      m1 c6
    `)

    matchNotes(song, [
      // first measure
      new SongNote("C5", 0, 0.5),
      new SongNote("C5", 0.5, 0.5),
      new SongNote("C5", 1.0, 0.5),

      new SongNote("G5", 0, 0.5),
      new SongNote("A5", 0.5, 0.5),
      new SongNote("G5", 1.0, 0.5),

      // second measure
      new SongNote("C6", 4, 1),
    ])
  })
github leafo / sightreading.training / static / js / auto_chords.es6 View on Github external
this.inDivisions(blockStart, blockStop, 1 + rate, (start, stop, k) => {
      if (k % bpm == 0) {
        // root on beat
        out.push(
          new SongNote(chordNotes[0], start, stop - start)
        )
      } else {
        // 5 on everything else
        out.push(
          new SongNote(chordNotes[2], start, stop - start)
        )
      }
    })
github leafo / sightreading.training / static / spec / parser_spec.es6 View on Github external
it("sets position when using blocks", function() {
    let song = SongParser.load(`
      {
        dt
        a5
        a5.2
      }
      g6
    `)

    matchNotes(song, [
      new SongNote("A5", 0, 0.5),
      new SongNote("A5", 0.5, 1),
      new SongNote("G6", 1.5, 1),
    ])
  })
github leafo / sightreading.training / static / spec / parser_spec.es6 View on Github external
it("renders a chord with restore position", function() {
    let song = SongParser.load(`
      c5 | e5 | g5
      a6
    `)

    matchNotes(song, [
      new SongNote("C5", 0, 1),
      new SongNote("E5", 0, 1),
      new SongNote("G5", 0, 1),
      new SongNote("A6", 1, 1),
    ])
  })
github leafo / sightreading.training / static / js / auto_chords.es6 View on Github external
}

      switch (k) {
        case 0:
          out.push(
            new SongNote(one, start, d * 3 )
          )
          break
        case 1:
          out.push(
            new SongNote(one, start + d, d)
          )
          break
        case 2:
          out.push(
            new SongNote(two, start, d * 3 )
          )
          break
        case 3:
          out.push(
            new SongNote(two, start + d, d)
          )
          break
      }
    })
github leafo / sightreading.training / static / spec / parser_spec.es6 View on Github external
m1 {
        e5
        d5
        c5
      }
    `)

    matchNotes(song, [
      new SongNote("C5", 0, 1),
      new SongNote("D5", 1, 2),
      new SongNote("G4", 0, 3),

      new SongNote("E5", 3, 1),
      new SongNote("D5", 4, 1),
      new SongNote("C5", 5, 1),
    ])
  })
github leafo / sightreading.training / static / js / components / staff_notes.es6 View on Github external
} else {
            offset = 0
          }

          let sNote = new SongNote(n, beat, dur)

          if (offset == 1) {
            appendClass(sNote, "group_offset")
          }

          lastRow = row
          notes.push(withClasses(sNote))
        })

      } else {
        notes.push(withClasses(new SongNote(column, beat, dur)))
      }

      beat += 1
    })
github leafo / sightreading.training / static / js / auto_chords.es6 View on Github external
let two = chordNotes[2]

      if (parseNote(two) >= maxPitch) {
        one = noteName(parseNote(chordNotes[2]) - 12)
        two = chordNotes[0]
      }

      switch (k) {
        case 0:
          out.push(
            new SongNote(one, start, d * 3 )
          )
          break
        case 1:
          out.push(
            new SongNote(one, start + d, d)
          )
          break
        case 2:
          out.push(
            new SongNote(two, start, d * 3 )
          )
          break
        case 3:
          out.push(
            new SongNote(two, start + d, d)
          )
          break
      }
    })
github leafo / sightreading.training / static / js / auto_chords.es6 View on Github external
this.inDivisions(blockStart, blockStop, 3, (start, stop, k) => {
      let d = (stop - start) / 2

      let one = chordNotes[0]
      let two = chordNotes[2]

      if (parseNote(two) >= maxPitch) {
        one = noteName(parseNote(chordNotes[2]) - 12)
        two = chordNotes[0]
      }

      switch (k) {
        case 0:
          out.push(
            new SongNote(one, start, d * 3 )
          )
          break
        case 1:
          out.push(
            new SongNote(one, start + d, d)
          )
          break
        case 2:
          out.push(
            new SongNote(two, start, d * 3 )
          )
          break
        case 3:
          out.push(
            new SongNote(two, start + d, d)
          )