Accidental

class pitchtools.Accidental(name='', arrow=None)

Accidental.

>>> import abjad
>>> abjad.Accidental('ff')
Accidental('double flat')
>>> abjad.Accidental('tqf')
Accidental('three-quarters flat')
>>> abjad.Accidental('f')
Accidental('flat')
>>> abjad.Accidental('')
Accidental('natural')
>>> abjad.Accidental('qs')
Accidental('quarter sharp')
>>> abjad.Accidental('s')
Accidental('sharp')
>>> abjad.Accidental('tqs')
Accidental('three-quarters sharp')
>>> abjad.Accidental('ss')
Accidental('double sharp')

Generalized accidentals are allowed:

>>> abjad.Accidental('ssss')
Accidental('ssss')

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.Accidental.Accidental" [color=black, fontcolor=white, group=2, label=<<B>Accidental</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.Accidental.Accidental"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Bases

Attribute summary

arrow Gets arrow of accidental.
name Gets name of accidental.
respell_with_flats(selection) Respells selection with flats.
respell_with_sharps(selection) Respells selection with sharps.
semitones Gets semitones of accidental.
symbol Gets symbol of accidental.
__add__(argument) Adds argument to accidental.
__call__(argument) Calls accidental on argument.
__copy__(*arguments) Copies Abjad value object.
__eq__(argument) Is true when all initialization values of Abjad value object equal the initialization values of argument.
__format__([format_specification]) Formats Abjad object.
__ge__(other[, NotImplemented]) Return a >= b.
__gt__(other[, NotImplemented]) Return a > b.
__hash__() Hashes Abjad value object.
__le__(other[, NotImplemented]) Return a <= b.
__lt__(argument) Is true when argument is an accidental with semitones greater than those of this accidental.
__ne__(argument) Is true when Abjad object does not equal argument.
__neg__() Negates accidental.
__radd__(argument) Raises not implemented error on accidental.
__repr__() Gets interpreter representation of Abjad object.
__str__() Gets string representation of accidental.
__sub__(argument) Subtracts argument from accidental.

Read-only properties

Accidental.arrow

Gets arrow of accidental.

Most accidentals carry no arrow:

>>> abjad.Accidental('sharp').arrow is None
True

Sharp with up-arrow:

>>> abjad.Accidental('sharp', arrow=Up).arrow
Up

Sharp with down-arrow:

>>> abjad.Accidental('sharp', arrow=Down).arrow
Down

ArrowLineSegment property is currently a stub in the object model. You can set the property but accidental math and formatting currently ignore the setting.

Returns up, down or none.

Accidental.name

Gets name of accidental.

>>> abjad.Accidental('ff').name
'double flat'
>>> abjad.Accidental('tqf').name
'three-quarters flat'
>>> abjad.Accidental('f').name
'flat'
>>> abjad.Accidental('').name
'natural'
>>> abjad.Accidental('qs').name
'quarter sharp'
>>> abjad.Accidental('s').name
'sharp'
>>> abjad.Accidental('tqs').name
'three-quarters sharp'
>>> abjad.Accidental('ss').name
'double sharp'

Returns string.

Accidental.semitones

Gets semitones of accidental.

>>> abjad.Accidental('ff').semitones
-2
>>> abjad.Accidental('tqf').semitones
-1.5
>>> abjad.Accidental('f').semitones
-1
>>> abjad.Accidental('').semitones
0
>>> abjad.Accidental('qs').semitones
0.5
>>> abjad.Accidental('s').semitones
1
>>> abjad.Accidental('tqs').semitones
1.5
>>> abjad.Accidental('ss').semitones
2

Returns number.

Accidental.symbol

Gets symbol of accidental.

>>> abjad.Accidental('ff').symbol
'bb'
>>> abjad.Accidental('tqf').symbol
'b~'
>>> abjad.Accidental('f').symbol
'b'
>>> abjad.Accidental('').symbol
''
>>> abjad.Accidental('qs').symbol
'+'
>>> abjad.Accidental('s').symbol
'#'
>>> abjad.Accidental('tqs').symbol
'#+'
>>> abjad.Accidental('ss').symbol
'##'

Returns string.

Class & static methods

static Accidental.respell_with_flats(selection)

Respells selection with flats.

Respells notes in staff:

>>> staff = abjad.Staff("c'8 cs'8 d'8 ef'8 e'8 f'8")
>>> show(staff) 
>>> abjad.Accidental.respell_with_flats(staff)
>>> show(staff) 

Returns none.

static Accidental.respell_with_sharps(selection)

Respells selection with sharps.

Respells notes in staff:

>>> staff = abjad.Staff("c'8 cs'8 d'8 ef'8 e'8 f'8")
>>> show(staff) 
>>> abjad.Accidental.respell_with_sharps(staff)
>>> show(staff) 

Returns none.

Special methods

Accidental.__add__(argument)

Adds argument to accidental.

>>> accidental = abjad.Accidental('qs')
>>> accidental + accidental
Accidental('sharp')
>>> accidental + accidental + accidental
Accidental('three-quarters sharp')

Returns new accidental.

Accidental.__call__(argument)

Calls accidental on argument.

>>> accidental = abjad.Accidental('s')

Calls accidental on pitches:

>>> accidental(abjad.NamedPitch("c''"))
NamedPitch("cs''")
>>> accidental(abjad.NamedPitch("cqs''"))
NamedPitch("ctqs''")
>>> accidental(abjad.NumberedPitch(12))
NumberedPitch(13)
>>> accidental(abjad.NumberedPitch(12.5))
NumberedPitch(13.5)

Calls accidental on pitch-classes:

>>> accidental(abjad.NamedPitchClass('c'))
NamedPitchClass('cs')
>>> accidental(abjad.NamedPitchClass('cqs'))
NamedPitchClass('ctqs')
>>> accidental(abjad.NumberedPitchClass(0))
NumberedPitchClass(1)
>>> accidental(abjad.NumberedPitchClass(0.5))
NumberedPitchClass(1.5)

Returns new object of argument type.

(AbjadValueObject).__copy__(*arguments)

Copies Abjad value object.

Returns new Abjad value object.

(AbjadValueObject).__eq__(argument)

Is true when all initialization values of Abjad value object equal the initialization values of argument.

Returns true or false.

(AbjadObject).__format__(format_specification='')

Formats Abjad object.

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

Returns string.

Accidental.__ge__(other, NotImplemented=NotImplemented)

Return a >= b. Computed by @total_ordering from (not a < b).

Accidental.__gt__(other, NotImplemented=NotImplemented)

Return a > b. Computed by @total_ordering from (not a < b) and (a != b).

(AbjadValueObject).__hash__()

Hashes Abjad value object.

Returns integer.

Accidental.__le__(other, NotImplemented=NotImplemented)

Return a <= b. Computed by @total_ordering from (a < b) or (a == b).

Accidental.__lt__(argument)

Is true when argument is an accidental with semitones greater than those of this accidental. Otherwise false.

>>> accidental_1 = abjad.Accidental('f')
>>> accidental_2 = abjad.Accidental('f')
>>> accidental_3 = abjad.Accidental('s')
>>> accidental_1 < accidental_1
False
>>> accidental_1 < accidental_2
False
>>> accidental_1 < accidental_3
True
>>> accidental_2 < accidental_1
False
>>> accidental_2 < accidental_2
False
>>> accidental_2 < accidental_3
True
>>> accidental_3 < accidental_1
False
>>> accidental_3 < accidental_2
False
>>> accidental_3 < accidental_3
False

Returns true or false.

(AbjadObject).__ne__(argument)

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

Returns true or false.

Accidental.__neg__()

Negates accidental.

>>> -abjad.Accidental('ff')
Accidental('double sharp')
>>> -abjad.Accidental('tqf')
Accidental('three-quarters sharp')
>>> -abjad.Accidental('f')
Accidental('sharp')
>>> -abjad.Accidental('')
Accidental('natural')
>>> -abjad.Accidental('qs')
Accidental('quarter flat')
>>> -abjad.Accidental('s')
Accidental('flat')
>>> -abjad.Accidental('tqs')
Accidental('three-quarters flat')
>>> -abjad.Accidental('ss')
Accidental('double flat')

Returns new accidental.

Accidental.__radd__(argument)

Raises not implemented error on accidental.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

Accidental.__str__()

Gets string representation of accidental.

>>> str(abjad.Accidental('ff'))
'ff'
>>> str(abjad.Accidental('tqf'))
'tqf'
>>> str(abjad.Accidental('f'))
'f'
>>> str(abjad.Accidental(''))
''
>>> str(abjad.Accidental('qs'))
'qs'
>>> str(abjad.Accidental('s'))
's'
>>> str(abjad.Accidental('tqs'))
'tqs'
>>> str(abjad.Accidental('ss'))
'ss'

Returns string.

Accidental.__sub__(argument)

Subtracts argument from accidental.

>>> accidental = abjad.Accidental('qs')
>>> accidental - accidental
Accidental('natural')
>>> accidental - accidental - accidental
Accidental('quarter flat')

Returns new accidental.