Example #1
0
    def export(self, mark, exporter):
        """
        Export a mark.
        """

        time = [0] * len(self.channels)

        for channel, (marks, l) in enumerate(zip(self.marks, self.channels)):
            m = marks[mark]
            for t, data in l[m]:
                if t is INSTRUMENT:
                    exporter.pc(channel, time[channel], data)
                elif t is LYNE:
                    for pitch, velocity, begin, duration in data.scheduled:
                        if pitch == 0 and duration == 0:
                            # Hax'd pitch bend data.
                            exporter.bend(channel, time[channel] + begin,
                                    velocity)
                        else:
                            velocity = make_velocity(velocity)
                            exporter.note(channel, time[channel] + begin,
                                    duration, pitch, velocity)
                    time[channel] += len(data)
                elif t is TACET:
                    time[channel] += data

        return max(time), exporter.commit()
Example #2
0
    def export_to_channel(self, channel, exporter):
        notes, length = self.schedule()
        elapsed = 0

        for i in range(self.repeat):
            # Ignore all channels; drums are always on channel 9.
            for pitch, velocity, begin, duration in notes:
                begin += elapsed

                velocity = make_velocity(velocity)
                exporter.note(9, begin, duration, pitch, velocity)
            elapsed += length
        return elapsed
Example #3
0
    def export_to_channel(self, channel, exporter):
        notes, length = self.schedule()
        elapsed = 0

        exporter.pc(channel, self.begin(),
                numbered_instruments[self.instrument])

        for i in range(self.repeat):
            for pitch, velocity, begin, duration in notes:
                begin += elapsed

                if pitch == 0 and duration == 0:
                    # Hax'd pitch bend data.
                    exporter.bend(channel, begin, velocity)
                else:
                    velocity = make_velocity(velocity)
                    exporter.note(channel, begin, duration, pitch, velocity)
            elapsed += length
        return elapsed