Zongzi.Score.Key behaviour (zongzi v0.3.0)

Copy Markdown

Domain model for pitch.

Uses an adapter pattern to support different tuning systems.

Handles conversion between two representations:

  • Staff notation data
  • MIDI / frequency data

Key values are stored and serialized in their internal type.

Summary

Types

key_struct()

@type key_struct() :: struct()

t()

@type t() :: key_struct()

Callbacks

from_midi(midi_note, ctx)

@callback from_midi(midi_note :: number(), ctx :: term()) ::
  {:ok, key_struct()} | {:error, term()}

from_score(score_data, type, ctx)

@callback from_score(score_data :: term(), type :: atom(), ctx :: term()) ::
  {:ok, key_struct()} | {:error, term()}

new(any)

@callback new(any()) :: {:ok, key_struct()} | {:error, term()}

Functions

from_midi(midi, ctx, module)

from_score(data, type, ctx, module)

new(attrs, module)

to_frequency(key, reference)

See Zongzi.Score.Key.Inner.to_frequency/2.

to_midi(key)

See Zongzi.Score.Key.Inner.to_midi/1.

to_score(key, type, ctx)

See Zongzi.Score.Key.Inner.to_score/3.