Webern v0.1.0 Webern.Row View Source
Models a tone row built from pitches from the 12 semitone chromatic scale.
N.B. Although the main functionality for row creation/transformation
is defined in this module, the Webern module provides a more user-friendly
interface, and it is recommended to use the functions defined there for
your own work.
Webern.Row implements the String.Chars protocol, so that
Kernel.to_string/1 returns a tab-separated string represenation of the row
converted to pitch class names, where 0 == c
Example
iex> Webern.Row.new([0, 2, 1, 3, 4, 6, 5, 7, 8, 10, 9, 11])
...> |> to_string
"c d cs ef e fs f g af bf a b"
Webern.Row also implements the Webern.Lilypond protocol, whose
to_lily/1 function embeds the result of to_string/1 inside
a Lilypond document that can be saved to a file and compiled.
Link to this section Summary
Functions
Transposes row to begin at pitch class start and returns the inverse form
Transposes row to begin at pitch class start and returns the
inverted retrograde form
Accepts pitch_classes, a list of integers between 0 and 11, and returns
a Webern.Row struct
Returns the prime form of row transposed to begin at pitch class start
Transposes row to begin at pitch class start and returns the retrograde
form
Transposes row to begin at pitch class start and returns the
retrograded inverse form
Converts row to a list of pitch class indices or strings
Link to this section Types
Link to this section Functions
inverse(Webern.Row.t, integer) :: Webern.Row.t
Transposes row to begin at pitch class start and returns the inverse form
Example
iex> Webern.Row.new([0, 2, 1, 3, 4, 6, 5, 7, 8, 10, 9, 11])
...> |> Row.inverse(1)
%Webern.Row{
pitch_classes: [1, 11, 0, 10, 9, 7, 8, 6, 5, 3, 4, 2]
}
inverse_retrograde(Webern.Row.t, integer) :: Webern.Row.t
Transposes row to begin at pitch class start and returns the
inverted retrograde form
Example
iex> Webern.Row.new([0, 2, 1, 3, 4, 6, 5, 7, 8, 10, 9, 11])
...> |> Row.inverse_retrograde(8)
%Webern.Row{
pitch_classes: [7, 9, 8, 10, 11, 1, 0, 2, 3, 5, 4, 6]
}
Accepts pitch_classes, a list of integers between 0 and 11, and returns
a Webern.Row struct.
Example
iex> Webern.Row.new([0, 2, 1, 3, 4, 6, 5, 7, 8, 10, 9, 11])
%Webern.Row{
pitch_classes: [0, 2, 1, 3, 4, 6, 5, 7, 8, 10, 9, 11]
}
Returns the prime form of row transposed to begin at pitch class start
Example
iex> Webern.Row.new([0, 2, 1, 3, 4, 6, 5, 7, 8, 10, 9, 11])
...> |> Row.prime(3)
%Webern.Row{
pitch_classes: [3, 5, 4, 6, 7, 9, 8, 10, 11, 1, 0, 2]
}
retrograde(Webern.Row.t, integer) :: Webern.Row.t
Transposes row to begin at pitch class start and returns the retrograde
form
Example
iex> Webern.Row.new([0, 2, 1, 3, 4, 6, 5, 7, 8, 10, 9, 11])
...> |> Row.retrograde(4)
%Webern.Row{
pitch_classes: [3, 1, 2, 0, 11, 9, 10, 8, 7, 5, 6, 4]
}
retrograde_inverse(Webern.Row.t, integer) :: Webern.Row.t
Transposes row to begin at pitch class start and returns the
retrograded inverse form
Example
iex> Webern.Row.new([0, 2, 1, 3, 4, 6, 5, 7, 8, 10, 9, 11])
...> |> Row.retrograde_inverse(5)
%Webern.Row{
pitch_classes: [6, 8, 7, 9, 10, 0, 11, 1, 2, 4, 3, 5]
}
to_list(Webern.Row.t, Keyword.t | nil) :: [integer] | [String.t]
Converts row to a list of pitch class indices or strings.
When passed only a Webern.Row, to_list/2 will return row.pitch_classes.
Example
iex> Webern.Row.new([0, 2, 1, 3, 4, 6, 5, 7, 8, 10, 9, 11])
...> |> Row.to_list
[0, 2, 1, 3, 4, 6, 5, 7, 8, 10, 9, 11]
When passed an optional keyword list including [to_pitches: true],
to_list/2 will convert the pitch classes to their lilypond pitch names,
using 0 == c.
Example
iex> Webern.Row.new([0, 2, 1, 3, 4, 6, 5, 7, 8, 10, 9, 11])
...> |> Row.to_list(to_pitches: true)
["c", "d", "cs", "ef", "e", "fs", "f", "g", "af", "bf", "a", "b"]
A different value for :zero_pitch can be passed in the
keyword list.
Example
iex> Webern.Row.new([0, 2, 1, 3, 4, 6, 5, 7, 8, 10, 9, 11])
...> |> Row.to_list(to_pitches: true, zero_pitch: "ef")
["ef", "f", "e", "fs", "g", "a", "af", "bf", "b", "cs", "c", "d"]