TuningFork.Gm (TuningFork v0.1.11)

Copy Markdown View Source

Voices for General MIDI's instrument and drum numbers.

Gm.for_program(33, base)

Summary

Functions

The percussion note numbers drums/1 answers to, ascending.

A drum kit, as a map from General MIDI note number to voice.

Which family a program number belongs to. Programs 96 to 127 are :other.

A voice for a General MIDI program number, derived from base.

A whole MIDI file as a score, with an instrument chosen for every channel.

Types

family()

@type family() ::
  :struck
  | :organ
  | :guitar
  | :bass
  | :strings
  | :brass
  | :reed
  | :pipe
  | :lead
  | :pad
  | :other

Functions

drum_notes()

@spec drum_notes() :: [0..127]

The percussion note numbers drums/1 answers to, ascending.

drums(gain \\ 1.0)

@spec drums(number()) :: %{required(0..127) => TuningFork.Voice.t()}

A drum kit, as a map from General MIDI note number to voice.

gain scales the whole kit; no voice exceeds a gain of 1.0. drum_notes/0 lists the numbers covered.

family(program)

@spec family(0..127) :: family()

Which family a program number belongs to. Programs 96 to 127 are :other.

for_program(program, base)

@spec for_program(0..127, TuningFork.Voice.t()) :: TuningFork.Voice.t()

A voice for a General MIDI program number, derived from base.

The shape, cutoff and envelope are set from the program's family/1; every other field of base is kept. A program in the :other family returns base unchanged.

score(midi, opts \\ [])

A whole MIDI file as a score, with an instrument chosen for every channel.

A channel is played with the voice for the last program it selected. Channels named as percussion by :drum_channels are played from drums/1 by note number, and are guessed unless stated.

"song.mid" |> TuningFork.Midi.read!() |> Gm.score() |> Score.render(44_100)

Options

  • :base — the voice every instrument is derived from, and what an unnamed channel plays. Default a filtered saw
  • :gain — level per note, default 0.2. Used only when :base is not given
  • :drum_gain — the kit's level against everything else, default 1.0
  • :plain — one voice for everything, ignoring the program changes, default false
  • anything TuningFork.Midi.to_score/2 takes — :bpm, :drum_channels, :quantize, :bend_range, :bend_points, :beats