Encoding Pitch and Detune Channel

Pitch

The pitch channel maps a data variable to a perceived frequency (high and low). Note that a higher frequency value tends to be perceived as a higher note, but the pitch itself is not the only determinant of a frequency. A pitch value can be written as a frequency or a note. It is possible round to a note by setting roundToNote as true (default is false). For example, if a mapped pitch value is 130.6Hz, then the pitch sound is rounded to a closest note C3 (130.812Hz).

pitch usage pattern

JSON

{
  ...
  "encoding" : {
    "pitch": {
      "field": "Body Mass (g)",
      "type": "quantitative",
      "roundToNote": true, // default: `false`
      "scale": {
        "doamin": [0, 7000], // optional
        "range": ['C3', 'C5'] // optional
        "range": [130.812, 523.251] // optional, equivalent (unit: `Hz`)
      }
    }
  }
  ...
}

JavaScript

let stream = new Erie.Stream();
...
stream.encoding.pitch.field("Body Mass (g)", "quantitative");
stream.encoding.pitch.roundToNote(true); // optinal
stream.encoding.pitch.scale("domain", [0, 7000]); // optional
stream.encoding.pitch.scale("range", ['C3', 'C5']); // optional
stream.encoding.pitch.scale("range", [130.812, 523.251] ); // optional, equivalent (unit: `Hz`)
...

Using a note scale

Instead of frequency, one can use the name of note (conversion table).

A note name is formatted as NOS standing for note, octave, and semitone.

  • A note can be: either C/c, D/d, E/e, F/f, G/g, A/a, or B/b (both upper and lower cases work).
  • A octave can be: either 0, 1, 2, 3, 4, 5, 6, or 7.
  • A semitone can be skipped or either s/S/# for sharp or b/B/ for flat.

For example, b3# is the Si in Octave 3 with flat, equivalent to C4.

Detune

For noise tones, pitch can’t work because of the underlying structure (i.e., there is no absolute baseline pitch). Instead, we can use the detune channel (it only works for noise tones). Detune can range from -1200 to 1200, where each 100 is a distance between two notes.

detune usage pattern

JSON

{
  ...
  "tone": {
    "type": "whiteNoise"
  },
  "encoding" : {
    "detune": {
      "field": "Body Mass (g)",
      "type": "quantitative",
      "scale": {
        "doamin": [0, 7000], // optional
        "range": [0, 1200] // optional; this way each 1000 maps to one-note scaling
      }
    }
  }
  ...
}

JavaScript

let stream = new Erie.Stream();
...
stream.tone.set(new Tone('whiteNoise'))
stream.encoding.detune.field("Body Mass (g)", "quantitative");
stream.encoding.detune.scale("domain", [0, 7000]); // optional
stream.encoding.detune.scale("range", [0, 1200]); // optional; this way each 1000 maps to one-note scaling
...
© Hyeok Kim