Octave

class pitchtools.Octave(octave_number=None)

Octave.

Example 1. Initializes octave from integer:

>>> pitchtools.Octave(4)
Octave(4)

Example 2. Initializes octave from octave-tick string:

>>> pitchtools.Octave(",,")
Octave(1)

Example 3. Initializes octave from named pitch:

>>> pitchtools.Octave(NamedPitch("cs''"))
Octave(5)

Example 4. Initializes octave from other octave:

>>> pitchtools.Octave(pitchtools.Octave(2))
Octave(2)

Lineage

digraph InheritanceGraph { graph [background=transparent, bgcolor=transparent, color=lightslategrey, fontname=Arial, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, root="__builtin__.object", splines=spline, style="dotted, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=12, penwidth=2, style="filled, rounded"]; edge [color=lightsteelblue2, penwidth=2]; subgraph cluster_abctools { graph [label=abctools]; "abjad.tools.abctools.AbjadObject.AbjadObject" [color=1, group=0, label=AbjadObject, shape=box]; "abjad.tools.abctools.AbjadObject.AbstractBase" [color=1, group=0, label=AbstractBase, shape=box]; "abjad.tools.abctools.AbjadValueObject.AbjadValueObject" [color=1, group=0, label=AbjadValueObject, shape=box]; "abjad.tools.abctools.AbjadObject.AbjadObject" -> "abjad.tools.abctools.AbjadValueObject.AbjadValueObject"; "abjad.tools.abctools.AbjadObject.AbstractBase" -> "abjad.tools.abctools.AbjadObject.AbjadObject"; } subgraph cluster_pitchtools { graph [label=pitchtools]; "abjad.tools.pitchtools.Octave.Octave" [color=black, fontcolor=white, group=2, label=<<B>Octave</B>>, shape=box, style="filled, rounded"]; } subgraph cluster_builtins { graph [label=builtins]; "builtins.object" [color=2, group=1, label=object, shape=box]; } "abjad.tools.abctools.AbjadValueObject.AbjadValueObject" -> "abjad.tools.pitchtools.Octave.Octave"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Bases

Attribute summary

from_pitch_name(class_, pitch_name) Makes octave from pitch_name.
from_pitch_number(class_, pitch_number) Makes octave from pitch_number.
is_octave_tick_string(class_, expr) Is true when expr is an octave tick string.
octave_number Gets octave number of octave.
octave_tick_string Gets LilyPond octave tick representation of octave.
pitch_number Gets pitch number of first note in octave.
pitch_range Gets pitch range of octave.
__copy__(\*args) Copies Abjad value object.
__eq__(other) Is true when other is octave with same octave number.
__float__() Casts octave as floating-point number.
__format__([format_specification]) Formats Abjad object.
__hash__() Hashes octave.
__int__() Changes octave to integer.
__ne__(expr) Is true when Abjad object does not equal expr.
__repr__() Gets interpreter representation of Abjad object.
__str__() Gets string representation of octave.

Read-only properties

Octave.octave_number

Gets octave number of octave.

>>> pitchtools.Octave(5).octave_number
5

Returns integer.

Octave.octave_tick_string

Gets LilyPond octave tick representation of octave.

>>> for i in range(-1, 9):
...     print(i, pitchtools.Octave(i).octave_tick_string)
-1 ,,,,
0  ,,,
1  ,,
2  ,
3
4  '
5  ''
6  '''
7  ''''
8  '''''

Returns string.

Octave.pitch_number

Gets pitch number of first note in octave.

>>> pitchtools.Octave(4).pitch_number
0
>>> pitchtools.Octave(5).pitch_number
12
>>> pitchtools.Octave(3).pitch_number
-12

Returns integer.

Octave.pitch_range

Gets pitch range of octave.

>>> pitchtools.Octave(5).pitch_range
PitchRange(range_string='[C5, C6)')

Returns pitch range.

Class & static methods

classmethod Octave.from_pitch_name(class_, pitch_name)

Makes octave from pitch_name.

>>> pitchtools.Octave.from_pitch_name('cs')
Octave(3)

Returns integer.

classmethod Octave.from_pitch_number(class_, pitch_number)

Makes octave from pitch_number.

>>> pitchtools.Octave.from_pitch_number(13)
Octave(5)

Returns octave.

classmethod Octave.is_octave_tick_string(class_, expr)

Is true when expr is an octave tick string. Otherwise false.

>>> pitchtools.Octave.is_octave_tick_string(',,,')
True

The regex ^,+|'+|$ underlies this predicate.

Returns true or false.

Special methods

(AbjadValueObject).__copy__(*args)

Copies Abjad value object.

Returns new Abjad value object.

Octave.__eq__(other)

Is true when other is octave with same octave number. Otherwise False.

>>> octave = pitchtools.Octave(4)
>>> octave == pitchtools.Octave(4)
True
>>> octave == pitchtools.Octave(3)
False
>>> octave == 'foo'
False

Returns true or false.

Octave.__float__()

Casts octave as floating-point number.

>>> float(pitchtools.Octave(3))
3.0

Returns floating-point number.

(AbjadObject).__format__(format_specification='')

Formats Abjad object.

Set format_specification to ‘’ or ‘storage’. Interprets ‘’ equal to ‘storage’.

Returns string.

Octave.__hash__()

Hashes octave.

Returns integer.

Octave.__int__()

Changes octave to integer.

>>> int(pitchtools.Octave(3))
3

Returns integer.

(AbjadObject).__ne__(expr)

Is true when Abjad object does not equal expr. Otherwise false.

Returns true or false.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

Octave.__str__()

Gets string representation of octave.

Defined equal to LilyPond octave / tick representation of octave.

>>> str(pitchtools.Octave(4))
"'"
>>> str(pitchtools.Octave(1))
',,'
>>> str(pitchtools.Octave(3))
''

Returns string.