Ejemplo n.º 1
0
class TrackScheduler(object):
    """
    Schedules notes and tempo events into a track
    """
    def __init__(self, meta_track, instrument=0, channel=0):
        self.meta_track = meta_track
        self.time = 0
        self.scheduled_track = NotesAndEventsScheduledTrack(instrument=instrument, channel=channel)

    def schedule_frame_components(self, components):
        """
        Schedules the notes and tempo events from each component in the list of components
        :param components: list of components from the frame
        :return:
        """
        for component in components:
            sound_event = component.get_sound_event()
            # add tempo and other events
            for note in sound_event.get_notes():
                self.scheduled_track.schedule_note(note, self.time)
                self.meta_track.schedule_event(component.get_tempo_event(), self.time)
            self.time += component.get_pause_to_next_component()

    def get_duration(self):
        return self.scheduled_track.get_duration()

    def get_scheduled_track(self):
        return self.scheduled_track
Ejemplo n.º 2
0
 def __init__(self, meta_track, instrument=0, channel=0):
     self.meta_track = meta_track
     self.time = 0
     self.scheduled_track = NotesAndEventsScheduledTrack(instrument=instrument, channel=channel)