Example #1
0
 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][0] -= diff
             if x[0] == at:
                 cur = x[0][1]
                 x[0][1] = to
                 diff = 1 / cur - 1 / to
Example #2
0
	def set_meter(self, meter):
		"""Meters in mingus are represented by a single tuple. \
This function will set the meter of this bar. If the format \
of the meter is not recognised, a !MeterFormatError will \
be raised."""
		#warning should raise exception
		if _meter.valid_beat_duration(meter[1]):
			self.meter = (meter[0], meter[1])
			self.length = meter[0] * (1.0 / meter[1])
		elif meter == (0, 0):
			self.meter = (0, 0)
			self.length = 0.0
		else:
			raise MeterFormatError, "The meter argument '%s' is not an understood representation of a meter. Expecting a tuple." % meter
Example #3
0
 def test_valid_beat_duration(self):
     for x in [
         1,
         2,
         4,
         8,
         16,
         32,
         64,
         128,
         256,
         512,
         1024,
         2048,
     ]:
         self.assertTrue(meter.valid_beat_duration(x), "%d should be a valid beat duration" % x)
Example #4
0
    def set_meter(self, meter):
        """Meters in mingus are represented by a single tuple. This function will \
set the meter of this bar. If the format of the meter is not recognised, \
a !MeterFormatError will be raised."""

        # warning should raise exception

        if _meter.valid_beat_duration(meter[1]):
            self.meter = (meter[0], meter[1])
            self.length = meter[0] * (1.0 / meter[1])
        elif meter == (0, 0):
            self.meter = (0, 0)
            self.length = 0.0
        else:
            raise MeterFormatError("The meter argument '%s' is not an understood representation of a meter. Expecting a tuple."\
                 % meter)
Example #5
0
 def test_invalid_beat_duration(self):
     for x in [
         0,
         3,
         5,
         6,
         7,
         9,
         10,
         11,
         12,
         13,
         14,
         15,
         ] + list(range(17, 31)):
         self.assert_(not meter.valid_beat_duration(x),
                      '%d should not be a valid beat duration' % x)
Example #6
0
 def test_valid_beat_duration(self):
     for x in [
         1,
         2,
         4,
         8,
         16,
         32,
         64,
         128,
         256,
         512,
         1024,
         2048,
         ]:
         self.assert_(meter.valid_beat_duration(x),
                      '%d should be a valid beat duration' % x)
Example #7
0
 def test_invalid_beat_duration(self):
     for x in [
         0,
         3,
         5,
         6,
         7,
         9,
         10,
         11,
         12,
         13,
         14,
         15,
         ] + list(range(17, 31)):
         self.assertTrue(not meter.valid_beat_duration(x),
                      '%d should not be a valid beat duration' % x)
Example #8
0
	def test_invalid_beat_duration(self):
		for x in [0, 3, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15] + range(17, 31):
			self.assert_(not(meter.valid_beat_duration(x)),\
					"%d should not be a valid beat duration" % x)