How to use the st/music.KeySignature 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 / song_parser.es6 View on Github external
if (restTiming) {
            if (restTiming.start) {
              break // do nothing
            }

            if (restTiming.duration) {
              duration *= restTiming.duration
            }
          }

          state.position += duration
          break
        }
        case "keySignature": {
          state.keySignature = new KeySignature(+command[1])
          break
        }
        case "timeSignature": {
          let [, perBeat, noteValue] = command
          state.beatsPerNote = 4 / noteValue
          state.beatsPerMeasure = state.beatsPerNote * perBeat
          break
        }
        case "macro": {
          let [, macroName] = command
          let chord = AutoChords.coerceChord(macroName)

          if (chord) {
            if (!song.autoChords) {
              song.autoChords = []
            }
github leafo / sightreading.training / static / spec / music_spec.es6 View on Github external
it("gets name for key signature", function() {

    expect(new KeySignature(0).name()).toBe("C")

    expect(new KeySignature(1).name()).toBe("G")
    expect(new KeySignature(2).name()).toBe("D")
    expect(new KeySignature(3).name()).toBe("A")
    expect(new KeySignature(4).name()).toBe("E")
    expect(new KeySignature(5).name()).toBe("B")

    expect(new KeySignature(-1).name()).toBe("F")
    expect(new KeySignature(-2).name()).toBe("Bb")
    expect(new KeySignature(-3).name()).toBe("Eb")
    expect(new KeySignature(-4).name()).toBe("Ab")
    expect(new KeySignature(-5).name()).toBe("Db")
    expect(new KeySignature(-6).name()).toBe("Gb")
  })
github leafo / sightreading.training / static / spec / music_spec.es6 View on Github external
it("gets name for key signature", function() {

    expect(new KeySignature(0).name()).toBe("C")

    expect(new KeySignature(1).name()).toBe("G")
    expect(new KeySignature(2).name()).toBe("D")
    expect(new KeySignature(3).name()).toBe("A")
    expect(new KeySignature(4).name()).toBe("E")
    expect(new KeySignature(5).name()).toBe("B")

    expect(new KeySignature(-1).name()).toBe("F")
    expect(new KeySignature(-2).name()).toBe("Bb")
    expect(new KeySignature(-3).name()).toBe("Eb")
    expect(new KeySignature(-4).name()).toBe("Ab")
    expect(new KeySignature(-5).name()).toBe("Db")
    expect(new KeySignature(-6).name()).toBe("Gb")
  })
github leafo / sightreading.training / static / spec / generators_spec.es6 View on Github external
it("should create generator", function() {
      let generator = new MultiKeyChordGenerator(new KeySignature(0))
      for (let i = 0; i < 10; i++) {
        let chord = generator.nextChord()
        expect(chord).toBeTruthy()
      }
    })
  })
github leafo / sightreading.training / static / spec / music_spec.es6 View on Github external
it("gets name for key signature", function() {

    expect(new KeySignature(0).name()).toBe("C")

    expect(new KeySignature(1).name()).toBe("G")
    expect(new KeySignature(2).name()).toBe("D")
    expect(new KeySignature(3).name()).toBe("A")
    expect(new KeySignature(4).name()).toBe("E")
    expect(new KeySignature(5).name()).toBe("B")

    expect(new KeySignature(-1).name()).toBe("F")
    expect(new KeySignature(-2).name()).toBe("Bb")
    expect(new KeySignature(-3).name()).toBe("Eb")
    expect(new KeySignature(-4).name()).toBe("Ab")
    expect(new KeySignature(-5).name()).toBe("Db")
    expect(new KeySignature(-6).name()).toBe("Gb")
  })
github leafo / sightreading.training / static / spec / music_spec.es6 View on Github external
it("gets key signature notes for E", function() {
    let key = new KeySignature(4)
    expect(key.isFlat()).toBe(false)
    expect(key.isSharp()).toBe(true)

    expect(key.accidentalNotes()).toEqual(["F", "C", "G", "D"])

    expect(key.notesInRange(...trebleCleff)).toEqual(["F5", "C6", "G6", "D6"])
    expect(key.notesInRange(...trebleCleff)).toEqual(["F5", "C6", "G6", "D6"])
  })
github leafo / sightreading.training / static / spec / music_spec.es6 View on Github external
it("gets name for key signature", function() {

    expect(new KeySignature(0).name()).toBe("C")

    expect(new KeySignature(1).name()).toBe("G")
    expect(new KeySignature(2).name()).toBe("D")
    expect(new KeySignature(3).name()).toBe("A")
    expect(new KeySignature(4).name()).toBe("E")
    expect(new KeySignature(5).name()).toBe("B")

    expect(new KeySignature(-1).name()).toBe("F")
    expect(new KeySignature(-2).name()).toBe("Bb")
    expect(new KeySignature(-3).name()).toBe("Eb")
    expect(new KeySignature(-4).name()).toBe("Ab")
    expect(new KeySignature(-5).name()).toBe("Db")
    expect(new KeySignature(-6).name()).toBe("Gb")
  })
github leafo / sightreading.training / static / js / components / pages / sight_reading_page.es6 View on Github external
midi: null,
      noteShaking: false,
      anyOctave: false,

      heldNotes: {},
      touchedNotes: {},
      scrollSpeed: 100,

      noteWidth: DEFAULT_NOTE_WIDTH,

      bufferSize: 10,
      keyboardOpen: true,
      settingsOpen: false,
      scale: window.innerWidth < 1000 ? 0.8 : 1,
      stats: new NoteStats(N.session.currentUser),
      keySignature: new KeySignature(0),
    }
  }