MCPcopy Create free account
hub / github.com/bspaans/python-mingus / Note

Class Note

mingus/containers/note.py:32–352  ·  view source on GitHub ↗

A note object. In the mingus.core module, notes are generally represented by strings. Most of the times, this is not enough. We want to set the octave and maybe the amplitude, vibrato or other dynamics. Then we want to store the notes in bars, the bars in tracks, the tracks in compo

Source from the content-addressed store, hash-verified

30
31
32class Note(object):
33
34 """A note object.
35
36 In the mingus.core module, notes are generally represented by strings.
37 Most of the times, this is not enough. We want to set the octave and
38 maybe the amplitude, vibrato or other dynamics. Then we want to store
39 the notes in bars, the bars in tracks, the tracks in compositions, etc.
40
41 We could do this with a number of lists, but ultimately it is a lot
42 easier to use objects. The Note class provides an easy way to deal with
43 notes in an object oriented matter.
44
45 You can use the class NoteContainer to group Notes together in intervals
46 and chords.
47 """
48
49 name = _DEFAULT_NAME
50 octave = _DEFAULT_OCTAVE
51 channel = _DEFAULT_CHANNEL
52 velocity = _DEFAULT_VELOCITY
53
54 def __init__(self, name="C", octave=4, dynamics=None, velocity=None, channel=None):
55 """
56 :param name:
57 :param octave:
58 :param dynamics: Deprecated. Use `velocity` and `channel` directly.
59 :param int velocity: Integer (0-127)
60 :param int channel: Integer (0-15)
61 """
62 if dynamics is None:
63 dynamics = {}
64
65 if velocity is not None:
66 dynamics["velocity"] = velocity
67 if channel is not None:
68 dynamics["channel"] = channel
69
70 if isinstance(name, six.string_types):
71 self.set_note(name, octave, dynamics)
72 elif hasattr(name, "name"):
73 # Hardcopy Note object
74 self.set_note(name.name, name.octave, name.dynamics)
75 elif isinstance(name, int):
76 self.from_int(name)
77 else:
78 raise NoteFormatError("Don't know what to do with name object: %r" % name)
79
80 @property
81 def dynamics(self):
82 """
83 .. deprecated:: Provided only for compatibility with existing code.
84 """
85 return {
86 "channel": self.channel,
87 "velocity": self.velocity,
88 }
89

Callers 15

__init__Method · 0.90
find_fretsMethod · 0.90
get_NoteMethod · 0.90
fft.pyFile · 0.90
find_notesFunction · 0.90
from_BarFunction · 0.90
MIDI_to_CompositionMethod · 0.90
InstrumentClass · 0.90
set_rangeMethod · 0.90
note_in_rangeMethod · 0.90
PianoClass · 0.90
GuitarClass · 0.90

Calls

no outgoing calls

Tested by 15

test_from_NoteMethod · 0.72
test_get_NoteMethod · 0.72
test_get_rangeMethod · 0.72
test_set_itemMethod · 0.72
setUpMethod · 0.72
test_cmpMethod · 0.72
test_eqMethod · 0.72
test_to_intMethod · 0.72
test_set_noteMethod · 0.72
test_to_hertzMethod · 0.72
test_from_hertzMethod · 0.72