예제 #1
0
파일: patBass.py 프로젝트: infojunkie/mma
    def getPgroup(self, ev):
        """ Get group for bass pattern.

            Fields - start, length, note, volume

        """

        if len(ev) != 4:
            error("There must be n groups of 4 in a pattern definition, "
                  "not <%s>" % ' '.join(ev))

        a = Pgroup()

        a.offset = self.setBarOffset(ev[0])
        a.duration = MMA.notelen.getNoteLen(ev[1])
        a.addoctave = 0

        # parse the offset (field 3) ... n[n][#s&b+-]
        offset = ev[2]
        point = 0

        while (offset[point:point + 1].isdigit()):  # grab digit(s) >1
            point += 1
        n = int(offset[0:point])
        if n < 1:
            error("Note offset in Bass must be greater that 0, not '%s'." % n)
        while n > 7:
            n -= 7
            a.addoctave += 12
        a.noteoffset = n - 1

        emsg = offset[point:]
        n = offset[point:point + 1]  # grab accidental
        if n == '#' or n == 'S':
            a.accidental = 1
            point += 1
        elif n == 'B' or n == '&':
            a.accidental = -1
            point += 1
        else:
            a.accidental = 0

        for n in ev[2][point:]:  # octave modifiers
            if n == '+':
                a.addoctave += 12
            elif n == '-':
                a.addoctave -= 12
            else:
                error(
                    "Only '- + # b &' are permitted after a noteoffset, not '%s'"
                    % emsg)

        # and, finally, the volume
        a.vol = stoi(ev[3], "Note volume in Bass definition not int")

        return a
예제 #2
0
    def getPgroup(self, ev):
        """ Get group for bass pattern.

            Fields - start, length, note, volume

        """

        if len(ev) != 4:
            error("There must be n groups of 4 in a pattern definition, "
                  "not <%s>" % ' '.join(ev))

        a = Pgroup()

        a.offset = self.setBarOffset(ev[0])
        a.duration = MMA.notelen.getNoteLen(ev[1])

        offset = ev[2]
        n = offset[0]
        if n in "1234567":
            a.noteoffset = int(n) - 1
        else:
            error("Note offset in Bass must be '1'...'7', not '%s'" % n)

        n = offset[1:2]
        if n == "#":
            a.accidental = 1
            ptr = 2
        elif n == 'B' or n == '&':
            a.accidental = -1
            ptr = 2
        else:
            a.accidental = 0
            ptr = 1

        a.addoctave = 0

        for n in ev[2][ptr:]:
            if n == '+':
                a.addoctave += 12
            elif n == '-':
                a.addoctave -= 12
            else:
                error(
                    "Only '- + # b &' are permitted after a noteoffset, not '%s'"
                    % n)

        a.vol = stoi(ev[3], "Note volume in Bass definition not int")

        return a
예제 #3
0
    def getPgroup(self, ev):
        """ Get group for scale patterns.

            Fields - start, length, volume
        """

        if len(ev) != 3:
            error("There must be at exactly 3 items in each group " "in a Scale definition, not <%s>." % " ".join(ev))

        a = Pgroup()

        a.offset = self.setBarOffset(ev[0])
        a.duration = MMA.notelen.getNoteLen(ev[1])
        a.vol = stoi(ev[2], "Type error in Scale definition")

        return a
예제 #4
0
    def getPgroup(self, ev):
        """ Get group for apreggio pattern.

            Fields - start, length, volume
        """

        a = Pgroup()
        if len(ev) != 3:
            error("There must be exactly 3 items in each group "
                  "for apreggio define, not '%s'" % ' '.join(ev))

        a.offset = self.setBarOffset(ev[0])
        a.duration = MMA.notelen.getNoteLen(ev[1])
        a.vol = stoi(ev[2], "Type error in Arpeggio definition")

        return a
    def getPgroup(self, ev):
        """ Get group for apreggio pattern.

            Fields - start, length, volume
        """

        a = Pgroup()
        if len(ev) != 3:
            error("There must be exactly 3 items in each group "
                  "for apreggio define, not '%s'" % ' '.join(ev))

        a.offset = self.setBarOffset(ev[0])
        a.duration = MMA.notelen.getNoteLen(ev[1])
        a.vol = stoi(ev[2], "Type error in Arpeggio definition")

        return a
예제 #6
0
파일: patScale.py 프로젝트: rcook/mma
    def getPgroup(self, ev):
        """ Get group for scale patterns.

            Fields - start, length, volume
        """

        if len(ev) != 3:
            error("There must be at exactly 3 items in each group "
                  "in a Scale definition, not <%s>." % ' '.join(ev))

        a = Pgroup()

        a.offset = self.setBarOffset(ev[0])
        a.duration = MMA.notelen.getNoteLen(ev[1])
        a.vol = stoi(ev[2], "Type error in Scale definition")

        return a
예제 #7
0
    def getPgroup(self, ev):
        """ Get group for a drum pattern.

            Fields - start, length, volume
        """

        if len(ev) != 3:
            error("There must be at exactly 3 items in each "
                  "group of a drum define, not <%s>" % ' '.join(ev))

        a = Pgroup()

        a.offset = self.setBarOffset(ev[0])
        a.duration = MMA.notelen.getNoteLen(ev[1])
        a.vol = stoi(ev[2], "Type error in Drum volume")

        return a
예제 #8
0
    def getPgroup(self, ev):
        """ Get group for walking bass pattern.

            Fields - start, length, volume
        """

        if len(ev) != 3:
            error("There must be at exactly 3 items in each group in "
                  "a Walking Bass definition, not <%s>" % ' '.join(ev))

        a = Pgroup()

        a.offset = self.setBarOffset(ev[0])
        a.duration = MMA.notelen.getNoteLen(ev[1])
        a.vol = stoi(ev[2], "Type error in Walking Bass definition")

        return a
예제 #9
0
    def getPgroup(self, ev):
        """ Get group for chord pattern.

        Tuples: [start, length, volume (,volume ...) ]
        """

        if len(ev) < 3:
            error("There must be at least 3 items in each group "
                  "of a chord pattern definition, not <%s>" % ' '.join(ev))

        a = Pgroup()

        a.offset = self.setBarOffset(ev[0])
        a.duration = MMA.notelen.getNoteLen(ev[1])

        vv = ev[2:]
        if len(vv) > 8:
            error("Only 8 volumes are permitted in Chord definition, not %s" % len(vv))

        a.vol = [0] * 8
        for i, v in enumerate(vv):
            v = stoi(v, "Expecting integer in volume list for Chord definition")
            a.vol[i] = v

        for i in range(i + 1, 8):  # force remaining volumes
            a.vol[i] = v

        return a
예제 #10
0
    def getPgroup(self, ev):
        """ Get group for rawmid pattern.

            Fields - start, length, note, volume

        """

        if len(ev) < 3:  # we need offset, strum and at least one pattern
            error(
                "%s: There must be n groups of 3 or more in a pattern definition, "
                "not '%s'" % (self.name, ' '.join(ev)))

        a = Pgroup()
        a.vol = 0  # as is this
        a.offset = self.setBarOffset(ev[0])
        a.strum = stoi(ev[1], "%s: Expecting int value for strum" % self.name)

        self.decodePlectrumPatterns(a, ev[2:])
        """ For the doc generators ... we need a setting for duration, even
            though this track doesn't really have one. Using the value of 0
            pretty much matches the results for a drum track. The author of
            this file used "pluckVol" and the docs are expecting a "vol" variable
            so we just duplicate it ... easier than changing all the uses here.
        """

        a.duration = 0  # this is a dummy value to keep docs happy
        a.vol = a.pluckVol

        return a
예제 #11
0
    def getPgroup(self, ev):
        """ Get group for aria pattern.

            Fields - start, length, velocity

        """

        if len(ev) != 3:
            error("%s: There must be n groups of 3 in a pattern definition, "
                  "not <%s>" % (self.name, ' '.join(ev)))

        a = Pgroup()

        a.offset = self.setBarOffset(ev[0])
        a.duration = MMA.notelen.getNoteLen(ev[1])
        a.vol = stoi(ev[2], "Note volume in Aria definition not int")

        return a
예제 #12
0
    def getPgroup(self, ev):
        """ Get group for aria pattern.

            Fields - start, length, velocity

        """

        if len(ev) != 3:
            error("%s: There must be n groups of 3 in a pattern definition, "
                  "not <%s>" % (self.name, ' '.join(ev)))

        a = Pgroup()

        a.offset = self.setBarOffset(ev[0])
        a.duration = MMA.notelen.getNoteLen(ev[1])
        a.vol = stoi(ev[2], "Note volume in Aria definition not int")

        return a
예제 #13
0
    def getPgroup(self, ev):
        """ Get group for bass pattern.

            Fields - start, length, note, volume

        """

        if len(ev) != 4:
            error("There must be n groups of 4 in a pattern definition, "
                  "not <%s>" % ' '.join(ev))

        a = Pgroup()

        a.offset = self.setBarOffset(ev[0])
        a.duration = MMA.notelen.getNoteLen(ev[1])

        offset = ev[2]
        n = offset[0]
        if n in "1234567":
            a.noteoffset = int(n) - 1
        else:
            error("Note offset in Bass must be '1'...'7', not '%s'" % n)

        n = offset[1:2]
        if n == "#":
            a.accidental = 1
            ptr = 2
        elif n == 'B' or n == '&':
            a.accidental = -1
            ptr = 2
        else:
            a.accidental = 0
            ptr = 1

        a.addoctave = 0

        for n in ev[2][ptr:]:
            if n == '+':
                a.addoctave += 12
            elif n == '-':
                a.addoctave -= 12
            else:
                error("Only '- + # b &' are permitted after a noteoffset, not '%s'" % n)

        a.vol = stoi(ev[3], "Note volume in Bass definition not int")

        return a
예제 #14
0
    def getPgroup(self, ev):
        """ Get group for rawmid pattern.

            Fields - start, length, note, volume

        """

        if len(ev) < 3:  # we need offset, strum and at least one pattern
            error("%s: There must be n groups of 3 or more in a pattern definition, "
                  "not '%s'" % (self.name, ' '.join(ev)))

        a = Pgroup()
        a.vol = 0        # as is this
        a.offset = self.setBarOffset(ev[0])
        a.strum = stoi(ev[1], "%s: Expecting int value for strum" % self.name)

        self.decodePlectrumPatterns(a, ev[2:])

        """ For the doc generators ... we need a setting for duration, even
            though this track doesn't really have one. Using the value of 0
            pretty much matches the results for a drum track. The author of
            this file used "pluckVol" and the docs are expecting a "vol" variable
            so we just duplicate it ... easier than changing all the uses here.
        """

        a.duration = 0   # this is a dummy value to keep docs happy
        a.vol = a.pluckVol

        return a
예제 #15
0
    def getPgroup(self, ev):
        """ Get group for chord pattern.

        Tuples: [start, length, volume (,volume ...) ]
        """

        if len(ev) < 3:
            error("There must be at least 3 items in each group "
                  "of a chord pattern definition, not <%s>" % ' '.join(ev))

        a = Pgroup()

        a.offset = self.setBarOffset(ev[0])
        a.duration = MMA.notelen.getNoteLen(ev[1])

        vv = ev[2:]
        if len(vv) > 8:
            error("Only 8 volumes are permitted in Chord definition, not %s" % len(vv))

        a.vol = [0] * 8
        for i, v in enumerate(vv):
            v = stoi(v, "Expecting integer in volume list for Chord definition")
            a.vol[i] = v

        for i in range(i + 1, 8):  # force remaining volumes
            a.vol[i] = v

        return a