mingus.containers.note_container

class mingus.containers.note_container.NoteContainer[source]
__add__(self, notes)[source]

Enable the use of the ‘+’ operator on NoteContainers.

Example:

>>> n = NoteContainer(['C', 'E', 'G'])
>>> n + 'B'
['C-4', 'E-4', 'G-4', 'B-4']
__eq__(self, other)[source]

Enable the ‘==’ operator for NoteContainer instances.

__getitem__(self, item)[source]

Enable the use of the container as a simple array.

Example:

>>> n = NoteContainer(['C', 'E', 'G'])
>>> n[0]
'C-4'
__init__(self, notes=[])[source]
__len__(self)[source]

Return the number of notes in the container.

__repr__(self)[source]

Return a nice and clean string representing the note container.

__setitem__(self, item, value)[source]

Enable the use of the [] notation on NoteContainers.

This function accepts Notes and notes as string.

Example:

>>> n = NoteContainer(['C', 'E', 'G'])
>>> n[0] = 'B'
>>> n
['B-4', 'E-4', 'G-4']
__sub__(self, notes)[source]

Enable the use of the ‘-‘ operator on NoteContainers.

Example:

>>> n = NoteContainer(['C', 'E', 'G'])
>>> n - 'E'
['C-4', 'G-4']
_consonance_test(self, testfunc, param=None)[source]

Private function used for testing consonance/dissonance.

add_note(self, note, octave=None, dynamics={})[source]

Add a note to the container and sorts the notes from low to high.

The note can either be a string, in which case you could also use the octave and dynamics arguments, or a Note object.

add_notes(self, notes)[source]

Feed notes to self.add_note.

The notes can either be an other NoteContainer, a list of Note objects or strings or a list of lists formatted like this:

>>> notes = [['C', 5], ['E', 5], ['G', 6]]

or even: >>> notes = [[‘C’, 5, {‘volume’: 20}], [‘E’, 6, {‘volume’: 20}]]

augment(self)[source]

Augment all the notes in the NoteContainer.

determine(self, shorthand=False)[source]

Determine the type of chord or interval currently in the container.

diminish(self)[source]

Diminish all the notes in the NoteContainer.

empty(self)[source]

Empty the container.

from_chord(self, shorthand)[source]

Shortcut to from_chord_shorthand.

from_chord_shorthand(self, shorthand)[source]

Empty the container and add the notes in the shorthand.

See mingus.core.chords.from_shorthand for an up to date list of recognized format.

Example:

>>> NoteContainer().from_chord_shorthand('Am')
['A-4', 'C-5', 'E-5']
from_interval(self, startnote, shorthand, up=True)[source]

Shortcut to from_interval_shorthand.

from_interval_shorthand(self, startnote, shorthand, up=True)[source]

Empty the container and add the note described in the startnote and shorthand.

See core.intervals for the recognized format.

Examples:

>>> nc = NoteContainer()
>>> nc.from_interval_shorthand('C', '5')
['C-4', 'G-4']
>>> nc.from_interval_shorthand('C', '5', False)
['F-3', 'C-4']
from_progression(self, shorthand, key=C)[source]

Shortcut to from_progression_shorthand.

from_progression_shorthand(self, shorthand, key=C)[source]

Empty the container and add the notes described in the progressions shorthand (eg. ‘IIm6’, ‘V7’, etc).

See mingus.core.progressions for all the recognized format.

Example:

>>> NoteContainer().from_progression_shorthand('VI')
['A-4', 'C-5', 'E-5']
get_note_names(self)[source]

Return a list with all the note names in the current container.

Every name will only be mentioned once.

is_consonant(self, include_fourths=True)[source]

Test whether the notes are consonants.

See the core.intervals module for a longer description on consonance.

is_dissonant(self, include_fourths=False)[source]

Test whether the notes are dissonants.

See the core.intervals module for a longer description.

is_imperfect_consonant(self)[source]

Test whether the notes are imperfect consonants.

See the core.intervals module for a longer description on consonance.

is_perfect_consonant(self, include_fourths=True)[source]

Test whether the notes are perfect consonants.

See the core.intervals module for a longer description on consonance.

notes

Attribute of type: list []

remove_duplicate_notes(self)[source]

Remove duplicate and enharmonic notes from the container.

remove_note(self, note, octave=-1)[source]

Remove note from container.

The note can either be a Note object or a string representing the note’s name. If no specific octave is given, the note gets removed in every octave.

remove_notes(self, notes)[source]

Remove notes from the containers.

This function accepts a list of Note objects or notes as strings and also single strings or Note objects.

sort(self)[source]

Sort the notes in the container from low to high.

transpose(self, interval, up=True)[source]

Transpose all the notes in the container up or down the given interval.


Back to Index