How to use the st/music.MajorScale 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 / music_spec.es6 View on Github external
it("gets notes in F MajorScale", function() {
    let scale = new MajorScale("F");
    // TODO: should be Bb5
    expect(scale.getRange(5)).toEqual([
      "F5", "G5", "A5", "Bb5", "C6", "D6", "E6", "F6"
    ]);
  });
github leafo / sightreading.training / static / spec / music_spec.es6 View on Github external
it("gets enharmonic spelling of notes for key", function() {
    let key = new KeySignature(-3) // b e a
    let notes = new MajorScale(key.name()).getRange(4).map((n) => key.enharmonic(n))

    expect(notes).toEqual([
      "Eb4", "F4", "G4", "Ab4", "Bb4", "C5", "D5", "Eb5"
    ])
  })
})
github leafo / sightreading.training / static / js / generators.es6 View on Github external
export function testRandomNotes() {
  let scale = new MajorScale("C")
  // let notes = scale.getLooseRange("A4", "C7")
  let notes = scale.getLooseRange("C3", "C7")

  let r = new RandomNotes(notes, {})

  let totalCount = 0
  let counts = {}
  for (let note of notes) {
    counts[note] = 0
  }

  for (let i = 0; i < 10000; i++) {
    for (let group of r.handGroups()) {
      for (let n of group) {
        counts[n] += 1
      }
github leafo / sightreading.training / static / spec / music_spec.es6 View on Github external
it("gets notes in C MajorScale", function() {
    let scale = new MajorScale("C");
    expect(scale.getRange(5)).toEqual([
      "C5", "D5", "E5", "F5", "G5", "A5", "B5", "C6"
    ]);
  });
github leafo / sightreading.training / static / spec / music_spec.es6 View on Github external
it("converts degree to note name", function() {
    let scale = new MajorScale("G")
    expect(scale.degreeToName(1)).toEqual("G")
    expect(scale.degreeToName(2)).toEqual("A")
    expect(scale.degreeToName(3)).toEqual("B")
    expect(scale.degreeToName(4)).toEqual("C")
    expect(scale.degreeToName(5)).toEqual("D")
    expect(scale.degreeToName(6)).toEqual("E")
    expect(scale.degreeToName(7)).toEqual("F#")
    expect(scale.degreeToName(8)).toEqual("G")
    expect(scale.degreeToName(9)).toEqual("A")
  })
github leafo / sightreading.training / static / spec / music_spec.es6 View on Github external
it("gets scale degrees for G major", function() {
    let scale = new MajorScale("G")
    let range = scale.getLooseRange("C5", "C6")

    expect(range.map(scale.getDegree.bind(scale))).toEqual([
      4, 5, 6, 7, 1, 2, 3, 4
    ])
  })
github leafo / sightreading.training / static / spec / music_spec.es6 View on Github external
it("gets notes in loose range for scale", function() {
    let scale = new MajorScale("G");
    let range = scale.getLooseRange("C5", "C6")
    expect(range).toEqual([
      "C5", "D5", "E5", "F#5", "G5", "A5", "B5", "C6"
    ]);
  });
github leafo / sightreading.training / static / js / note_list.es6 View on Github external
getKeyRange() {
    let notes = new MajorScale("C").getRange(3, 24, 2);
    return [notes[0], notes[notes.length - 1]];
  }
github leafo / sightreading.training / static / js / data.es6 View on Github external
create: function(staff, keySignature, options) {
      let scale = new MajorScale(keySignature)
      let progressionInputs = this.inputs.find(i => i.name == "progression")
      let progression = progressionInputs.values.find(v => v.name == options.progression)
      return new ProgressionGenerator(scale, staff.range, progression.value, options)
    }
  },
github leafo / sightreading.training / static / js / chord_generators.es6 View on Github external
constructor(keySignature, opts={}) {
    this.noteCount = opts.notes || 3
    this.keySignature = keySignature
    if (opts.commonNotes > 0) {
      this.commonNotes = opts.commonNotes
    }

    this.generator = new MersenneTwister()

    if (keySignature.isChromatic()) {
      this.scale = keySignature.defaultScale()
    } else {
      switch (opts.scale) {
        case "major":
          this.scale = new MajorScale(keySignature.name())
          break
        case "natural minor":
          this.scale = new MinorScale(keySignature.name())
          break
        case "harmonic minor":
          this.scale = new HarmonicMinorScale(keySignature.name())
          break
        case "melodic minor":
          this.scale = new AscendingMelodicMinorScale(keySignature.name())
          break
        case "major blues":
          this.scale = new MajorBluesScale(keySignature.name())
          break
        default:
          this.scale = keySignature.defaultScale()
      }