bgr / mingus

Automatically exported from code.google.com/p/mingus
GNU General Public License v3.0
1 stars 1 forks source link

change_note_duration(): NameError: global name 'valid_beat_duration' is not defined #122

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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):

Original issue reported on code.google.com by OrtalisM...@gmail.com on 23 Apr 2013 at 9:57

GoogleCodeExporter commented 9 years ago
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

Original comment by OrtalisM...@gmail.com on 23 Apr 2013 at 10:17

GoogleCodeExporter commented 9 years ago
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

Original comment by OrtalisM...@gmail.com on 23 Apr 2013 at 11:21

Attachments:

GoogleCodeExporter commented 9 years ago
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

Original comment by OrtalisM...@gmail.com on 1 May 2013 at 12:01

Attachments: