mingus.containers.note

class mingus.containers.note.Note[source]
__eq__(self, other)[source]

Compare Notes for equality by comparing their note values.

__ge__(self, other)[source]
__gt__(self, other)[source]
__init__(self, name=C, octave=4, dynamics={})[source]
__int__(self)[source]

Return the current octave multiplied by twelve and add notes.note_to_int to it.

This means a C-0 returns 0, C-1 returns 12, etc. This method allows you to use int() on Notes.

__le__(self, other)[source]
__lt__(self, other)[source]

Enable the comparing operators on Notes (>, <, ==, !=, >= and <=).

So we can sort() Intervals, etc.

Examples:

>>> Note('C', 4) < Note('B', 4)
True
>>> Note('C', 4) > Note('B', 4)
False
__ne__(self, other)[source]
__repr__(self)[source]

Return a helpful representation for printing Note classes.

augment(self)[source]

Call notes.augment with this note as argument.

change_octave(self, diff)[source]

Change the octave of the note to the current octave + diff.

diminish(self)[source]

Call notes.diminish with this note as argument.

dynamics

Attribute of type: dict {}

empty(self)[source]

Remove the data in the instance.

from_hertz(self, hertz, standard_pitch=440)[source]

Set the Note name and pitch, calculated from the hertz value.

The standard_pitch argument can be used to set the pitch of A-4, from which the rest is calculated.

from_int(self, integer)[source]

Set the Note corresponding to the integer.

0 is a C on octave 0, 12 is a C on octave 1, etc.

Example:

>>> Note().from_int(12)
'C-1'
from_shorthand(self, shorthand)[source]

Convert from traditional Helmhotz pitch notation.

Examples:

>>> Note().from_shorthand("C,,")
'C-0'
>>> Note().from_shorthand("C")
'C-2'
>>> Note().from_shorthand("c'")
'C-4'
measure(self, other)[source]

Return the number of semitones between this Note and the other.

Examples:

>>> Note('C').measure(Note('D'))
2
>>> Note('D').measure(Note('C'))
-2
name

Attribute of type: str 'C'

octave

Attribute of type: int 4

octave_down(self)[source]

Decrement the current octave with 1.

octave_up(self)[source]

Increment the current octave with 1.

remove_redundant_accidentals(self)[source]

Call notes.remove_redundant_accidentals on this note’s name.

set_note(self, name=C, octave=4, dynamics={})[source]

Set the note to name in octave with dynamics.

Return the objects if it succeeded, raise an NoteFormatError otherwise.

to_hertz(self, standard_pitch=440)[source]

Return the Note in Hz.

The standard_pitch argument can be used to set the pitch of A-4, from which the rest is calculated.

to_shorthand(self)[source]

Give the traditional Helmhotz pitch notation.

Examples:

>>> Note('C-4').to_shorthand()
"c'"
>>> Note('C-3').to_shorthand()
'c'
>>> Note('C-2').to_shorthand()
'C'
>>> Note('C-1').to_shorthand()
'C,'
transpose(self, interval, up=True)[source]

Transpose the note up or down the interval.

Examples:

>>> a = Note('A')
>>> a.transpose('3')
>>> a
'C#-5'
>>> a.transpose('3', False)
>>> a
'A-4'

Back to Index