示例#1
0
    def __init__(self):
        from athenaCL.libATH import osTools
        from athenaCL.libATH import rhythm
        import random

        partList = [
            {
                'part-name': 'Violoncello 1',
                'instrument-name': 'Cello',
                'midi-channel': '1',
                'midi-program': '1'
            },
            {
                'part-name': 'Violoncello 2',
                'instrument-name': 'Cello',
                'midi-channel': '2',
                'midi-program': '23'
            },
        ]

        measureList = []
        for partId in range(len(partList)):
            part = []

            mForm = [(1, 4)]

            pulseSeq = []
            pitchSeq = []
            for i in range(40):
                ps = random.choice([0, .5, 1, 1.5, None, 13])
                pitchSeq.append(ps)
                r = random.choice([[2, 1], [2, 3], [4, 1], [4, 3], [1, 3],
                                   [1, 2]])
                pulseSeq.append(r)

            a = rhythm.RhythmMeasure(pulseSeq, pitchSeq)
            a.setMeasureForm(mForm)
            postPulse, postEvent = a.partition()

            for mNumber in range(len(postPulse)):

                m = Measure()
                m.setAttributesArg()  # will provide defaults

                for eNumber in range(len(postPulse[mNumber])):

                    dur, tie = postPulse[mNumber][eNumber]
                    ps = postEvent[mNumber][eNumber]
                    m.addNote(ps, dur, tie)

                part.append(m)

            measureList.append(part)

        id = {'creator': 'Test Author', 'rights': 'Copyright 2008 Test Author'}

        a = Score()
        a.setPartList(partList)
        a.setWork('Test Composition')
        a.setIdentification(id)
        a.setMeasures(measureList)

        fp = drawer.tempFile('.xml')
        print(fp)
        a.write(fp)

        osTools.openMedia(fp)
示例#2
0
 def play(self):
     osTools.openMedia(self.absPath)
示例#3
0
 def play(self):
     osTools.openMedia(self.absPath)