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

Method set_note

mingus/containers/note.py:100–143  ·  view source on GitHub ↗

Set the note to name in octave with dynamics. Return the objects if it succeeded, raise an NoteFormatError otherwise. :param name: :param octave: :param dynamics: Deprecated. Use `velocity` and `channel` directly. :param int velocity: Integer (0-127)

(self, name="C", octave=4, dynamics=None, velocity=None, channel=None)

Source from the content-addressed store, hash-verified

98 self.velocity = velocity
99
100 def set_note(self, name="C", octave=4, dynamics=None, velocity=None, channel=None):
101 """Set the note to name in octave with dynamics.
102
103 Return the objects if it succeeded, raise an NoteFormatError
104 otherwise.
105
106 :param name:
107 :param octave:
108 :param dynamics: Deprecated. Use `velocity` and `channel` directly.
109 :param int velocity: Integer (0-127)
110 :param int channel: Integer (0-15)
111 :return:
112 """
113 if dynamics is None:
114 dynamics = {}
115
116 if velocity is not None:
117 self.set_velocity(velocity)
118 elif "velocity" in dynamics:
119 self.set_velocity(dynamics["velocity"])
120
121 if channel is not None:
122 self.set_channel(channel)
123 if "channel" in dynamics:
124 self.set_channel(dynamics["channel"])
125
126 dash_index = name.split("-")
127 if len(dash_index) == 1:
128 if notes.is_valid_note(name):
129 self.name = name
130 self.octave = octave
131 return self
132 else:
133 raise NoteFormatError("Invalid note representation: %r" % name)
134 elif len(dash_index) == 2:
135 note, octave = dash_index
136 if notes.is_valid_note(note):
137 self.name = note
138 self.octave = int(octave)
139 return self
140 else:
141 raise NoteFormatError("Invalid note representation: %r" % name)
142 else:
143 raise NoteFormatError("Invalid note representation: %r" % name)
144
145 def empty(self):
146 """Remove the data in the instance."""

Callers 3

__init__Method · 0.95
from_shorthandMethod · 0.95
test_set_noteMethod · 0.95

Calls 3

set_velocityMethod · 0.95
set_channelMethod · 0.95
NoteFormatErrorClass · 0.90

Tested by 1

test_set_noteMethod · 0.76