How to use the st/music.noteName 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 / pages / sight_reading_page.es6 View on Github external
onMidiMessage(message) {
    let [raw, pitch, velocity] = message.data;

    let cmd = raw >> 4,
      channel = raw & 0xf,
      type = raw & 0xf0;

    let n = noteName(pitch)

    if (NOTE_EVENTS[type] == "noteOn") {
      if (velocity == 0) {
        this.releaseNote(n);
      } else if (!document.hidden) { // ignore when the browser tab isn't active
        this.pressNote(n);
      }
    }

    if (NOTE_EVENTS[type] == "noteOff") {
      this.releaseNote(n);
    }
  }
github leafo / sightreading.training / static / js / midi.es6 View on Github external
onMidiMessage(message) {
    let [raw, pitch, velocity] = message.data;

    let cmd = raw >> 4,
      channel = raw & 0xf,
      type = raw & 0xf0;

    let n = noteName(pitch)

    if (NOTE_EVENTS[type] == "noteOn") {
      if (velocity == 0) {
        this.noteOff(n);
      } else if (!document.hidden) { // ignore when the browser tab isn't active
        this.noteOn(n, velocity);
      }
    }

    if (NOTE_EVENTS[type] == "noteOff") {
      this.noteOff(n);
    }

    if (NOTE_EVENTS[type] == "dataEntry") {
      if (pitch == 64) {
        if (velocity > 0) {
github leafo / sightreading.training / static / js / auto_chords.es6 View on Github external
start, stop - start)
          )
          break
        case 3:
          out.push(
            new SongNote(chordNotes[1], start, stop - start)
          )
          break
      }
    })

    for (let note of out) {
      while (parseNote(note.note) >= maxPitch) {
        // shift everything done by octave
        for (let note of out) {
          note.note = noteName(parseNote(note.note) - 12)
        }
      }
    }


    return out
  }
}
github leafo / sightreading.training / static / js / song_note_list.es6 View on Github external
transpose(semitones) {
    return new SongNote(
      noteName(parseNote(this.note) + semitones), this.start, this.duration
    )
  }
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(
github leafo / sightreading.training / static / js / components / sight_reading / settings_panel.es6 View on Github external
let currentValue = this.cachedSettings[input.name]

    let options = []

    for (let i=input.max; i >= input.min; i--) {
      options.push(noteName(i))
    }

    return <div>
      <label>
        Note
        <select> {
            this.updateInputValue(input, parseNote(value))
          }}
          value={noteName(currentValue)}
          options={options.map(name =&gt; ({ value: name, name }))}
        /&gt;
      
    

  }
</select></label></div>
github leafo / sightreading.training / static / js / components / ear_training / melody_recognition_exercise.es6 View on Github external
renderSongPlayer() {
    let current = this.state.currentMelody

    let currentSongTools
    if (current) {
      let currentSong = this.state.melodySongs[current.song]

      let stopSong
      if (this.state.playingTimer &amp;&amp; !this.state.autoplayTimer) {
        stopSong = <button type="button"> this.state.playingTimer.stop() }&gt;Stop</button>
      }

      let firstNote = noteName(parseNote(currentSong[0].note) + this.state.playbackTranspose)

      let disabled = !!(this.state.playing || this.state.autoplayTimer)

      let title = `${current.interval} - ${current.title} (${firstNote})`
      if (this.state.autoplayState == "playingInterval") {
        title = "Listen to interval..."
      }

      currentSongTools = <div>
        <div>{title}</div>
        <div>
          <button type="button" disabled="{disabled}"> {
              this.playCurrentRoot()</button></div></div>
github leafo / sightreading.training / static / js / data.es6 View on Github external
function staffRange(staff, noteRange) {
  if (noteRange) {
    return [
      noteName(Math.max(noteRange[0], parseNote(staff.range[0]))),
      noteName(Math.min(noteRange[1], parseNote(staff.range[1])))
    ]
  } else {
    return staff.range
  }
}
github leafo / sightreading.training / static / js / components / sight_reading / settings_panel.es6 View on Github external
let currentValue = this.cachedSettings[input.name]
    let [min, max] = currentValue

    let possibleMin = []
    let possibleMax = []

    let staffMin, staffMax

    if (this.props.currentStaff) {
      let staff = this.props.currentStaff
      staffMin = parseNote(staff.range[0])
      staffMax = parseNote(staff.range[1])
    }

    for (let i=input.max; i &gt;= input.min; i--) {
      let iName = noteName(i)

      if (i &lt; staffMin) { continue }
      if (i &gt; staffMax) { continue }

      if (i &gt;= min) {
        possibleMax.push(iName)
      }

      if (i &lt;= max) {
        possibleMin.push(iName)
      }
    }

    return <div>
      <label>
        Min</label></div>
github leafo / sightreading.training / static / js / song_note_list.es6 View on Github external
let min = parseNote(this[0].note)
    let max = min

    for (let songNote of this) {
      let pitch = parseNote(songNote.note)
      if (pitch &lt; min) {
        min = pitch
      }

      if (pitch &gt; max) {
        max = pitch
      }
    }

    return [noteName(min), noteName(max)]
  }