# @coda/midi

# atodb

 atodb(source: Stream): Stream

The atob operator converts a stream of scalar or vector values from
amplitude to deciBels.

Parameter Type Default Description
source Stream Input stream (amplitude values)

Returns Stream Scaled stream (dB values)

Example

db = now([0, 0.5, 1])
  .tap(x => console.log(`Amplitude: [${x}]`))
  .atodb()
  .tap(x => console.log(`deciBels: [${x}]`));

# dbtoa

 dbtoa(source: Stream): Stream

The dbtoa operator converts a stream of scalar or vector values from
deciBels to amplitude.

Parameter Type Default Description
source Stream Input stream (dB values)

Returns Stream Scaled stream (amplitude values)

Example

a = now([0, -6, -Infinity])
  .tap(x => console.log(`deciBels: [${x}]`))
  .dbtoa()
  .tap(x => console.log(`Amplitude: [${x}]`));

# ftom

 ftom(source: Stream): Stream

The ftom operator converts a stream of scalar or vector values from frequency
to scale.

Parameter Type Default Description
source Stream Input stream (frequency values)

Returns Stream Scaled stream (midi values)

# mtof

 mtof(source: Stream): Stream

The mtof operator converts a stream of scalar or vector values from midi
to frequency scale.

Parameter Type Default Description
source Stream Input stream (midi values)

Returns Stream Scaled stream (frequency values)

# quantize

 quantize(options: Object, source: Stream): Stream

Quantize a scalar or vector stream to a given scale (chromatic by default).

see

https://github.com/danigb/tonal

Parameter Type Default Description
options Object {} WHAT ?????? ""
options.scale Number 'chromatic' Musical Scale (ex: 'C major')Available scales: aeolian, altered, augmented, augmented heptatonic,
balinese, bebop, bebop dominant, bebop locrian, bebop major, bebop minor,
chromatic, composite blues, diminished, dorian, dorian #4, double harmonic
lydian, double harmonic major, egyptian, enigmatic, flamenco, flat six
pentatonic, flat three pentatonic, harmonic major, harmonic minor,
hirajoshi, hungarian major, hungarian minor, ichikosucho, in-sen, ionian
augmented, ionian pentatonic, iwato, kafi raga, kumoijoshi, leading whole
tone, locrian, locrian #2, locrian major, locrian pentatonic, lydian,
lydian #5P pentatonic, lydian #9, lydian augmented, lydian diminished, lydian
dominant, lydian dominant pentatonic, lydian minor, lydian pentatonic,
major, major blues, major flat two pentatonic, major pentatonic, malkos
raga, melodic minor, melodic minor fifth mode, melodic minor second mode,
minor #7M pentatonic, minor bebop, minor blues, minor hexatonic, minor
pentatonic, minor six diminished, minor six pentatonic, mixolydian,
mixolydian pentatonic, mystery #1, neopolitan, neopolitan major, neopolitan
major pentatonic, neopolitan minor, oriental, pelog, persian, phrygian,
piongio, prometheus, prometheus neopolitan, purvi raga, ritusen, romanian
minor, scriabin, six tone symmetric, spanish, spanish heptatonic, super
locrian pentatonic, todi raga, vietnamese 1, vietnamese 2, whole tone, whole
tone pentatonic
options.mode Number 'round' Quantization mode: 'round' selects
the closest note, 'floor' the closest lower note, 'ceil' the closest higher
note.
options.octavemin Number 0 Minimum octave
options.octavemax Number 10 Maximum octave
source Stream Input stream (~midi notes)

Returns Stream Quantized stream