TuningFork.Composer.Json (TuningForkComposer v0.1.3)

Copy Markdown View Source

A composition as string-keyed maps of JSON-safe values, and back.

project |> Json.to_map() |> Json.from_map()

Summary

Functions

A composition from plain maps.

A composition as string-keyed maps. Values are numbers, strings, booleans and lists. A step held over more than one step is %{"d" => degree, "n" => length}; a step one long is the bare degree.

Functions

from_map(attrs)

@spec from_map(map()) :: TuningFork.Composer.t()

A composition from plain maps.

Takes a map with the keys to_map/1 produces; anything not a map yields Composer.new/1. Missing keys fall back to the struct's defaults and unrecognisable values are dropped. Never raises. Only note names, scale names and track kinds the composer already knows become atoms; any other string falls back to the default.

to_map(project)

@spec to_map(TuningFork.Composer.t()) :: map()

A composition as string-keyed maps. Values are numbers, strings, booleans and lists. A step held over more than one step is %{"d" => degree, "n" => length}; a step one long is the bare degree.