Issue 122 in mingus: change_note_duration(): NameError: global name 'valid_beat_duration' is not defined

5 views
Skip to first unread message

min...@googlecode.com

unread,
Apr 23, 2013, 5:57:21 PM4/23/13
to mingus...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 122 by OrtalisM...@gmail.com: change_note_duration(): NameError:
global name 'valid_beat_duration' is not defined
http://code.google.com/p/mingus/issues/detail?id=122

What steps will reproduce the problem?
1. calling change_note_duration()

...
cur_beat = track.bars[-1].current_beat
track.bars[-1].place_notes(note, value_left)
track.bars[-1].change_note_duration(cur_beat, unit.get_value())
...

2. run script
3. track.bars[-1].change_note_duration(cur_beat, unit.get_value())
File "/Library/Python/2.7/site-packages/mingus/containers/Bar.py", line
135, in change_note_duration
if valid_beat_duration(to):
NameError: global name 'valid_beat_duration' is not defined


Please provide any additional information below.

line 135 of Bar.y is:
if valid_beat_duration(to):
it chould be:
if _meter.valid_beat_duration(to):

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

min...@googlecode.com

unread,
Apr 23, 2013, 6:17:18 PM4/23/13
to mingus...@googlegroups.com

Comment #1 on issue 122 by OrtalisM...@gmail.com: change_note_duration():
NameError: global name 'valid_beat_duration' is not defined
http://code.google.com/p/mingus/issues/detail?id=122

There seem to be some other issues with the function too.

File "/Library/Python/2.7/site-packages/mingus/containers/Bar.py", line
141, in change_note_duration
cur = x[0][1]
TypeError: 'float' object is not subscriptable

min...@googlecode.com

unread,
Apr 23, 2013, 7:21:23 PM4/23/13
to mingus...@googlegroups.com

Comment #2 on issue 122 by OrtalisM...@gmail.com: change_note_duration():
NameError: global name 'valid_beat_duration' is not defined
http://code.google.com/p/mingus/issues/detail?id=122

This fixes the issue:

def change_note_duration(self, at, to):
"""Changes the note duration at index `at` to duration `to`"""
if _meter.valid_beat_duration(to):
diff = 0
for x in self.bar:
if diff != 0:
x[0] -= diff
if x[0] == at:
cur = x[1]
x[1] = to
diff = 1/cur - 1/to

Attachments:
Bar.py 7.6 KB

min...@googlecode.com

unread,
Apr 30, 2013, 8:01:56 PM4/30/13
to mingus...@googlegroups.com

Comment #3 on issue 122 by OrtalisM...@gmail.com: change_note_duration():
NameError: global name 'valid_beat_duration' is not defined
http://code.google.com/p/mingus/issues/detail?id=122

This seems more useful:

def change_note_duration(self, at, to):
"""Change the note duration at the given index to the given
duration."""
if _meter.valid_beat_duration(to):
diff = 0
for x in self.bar:
if diff != 0:
x[0] -= diff
if x[0] == at:
cur = x[1]
x[1] = to
diff = 1/cur - 1/to
return True
else:
return False
Reply all
Reply to author
Forward
0 new messages