How to use the st/chord_generators.ChordGenerator 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 / generators_spec.es6 View on Github external
it("generates some chords without an error", function() {
    let generator = new ChordGenerator(new KeySignature(0))
    for (let i = 0; i < 10; i++) {
      let chord = generator.nextChord()
      expect(chord).toBeTruthy()
    }
  })
github leafo / sightreading.training / static / spec / generators_spec.es6 View on Github external
it("gets all chords for scale", function() {
    let generator = new ChordGenerator(new KeySignature(0))
    let chords = generator.allChords()

    expect(chords).toEqual([
      new Chord("C", "M"),
      new Chord("D", "m"),
      new Chord("E", "m"),
      new Chord("F", "M"),
      new Chord("G", "M"),
      new Chord("A", "m"),
      new Chord("B", "dim"),
    ])
  })
github leafo / sightreading.training / static / js / data.es6 View on Github external
create: function(staff, keySignature, options) {
      return new ChordGenerator(keySignature, options)
    }
  },
github leafo / sightreading.training / static / js / components / flash_cards / chord_identification_exercise.es6 View on Github external
if (!keySignature) {
      this.setState({
        currentCard: null
      })

      return
    }

    if (!this.generators) {
      this.generators = {}
    }

    let generatorKey = `${keySignature.count}-${notes}`
    if (!this.generators[generatorKey]) {
      this.generators[generatorKey] = new ChordGenerator(keySignature, { notes })
    }

    let chord = this.generators[generatorKey].nextChord()

    let inversion = this.props.settings.inversions ? this.rand.int() % 3 : 0

    this.setState({
      cardNumber: this.state.cardNumber + 1,
      cardError: false,
      cardMistakes: null,
      partialAnswer: null,

      currentCard: {
        notes,
        octave: 5,
        keySignature,