def cycle(self):
     """
     A single cycle that allows all agents to perform.
     """
     agents = self.agents
     random.shuffle(agents)
     for agent in agents:
         # make the agent perform
         output = agent.perform()
         group_structure = getNoteGroups(output)
         nominal_tempo = self.defaultTempo
         nominal_volume = self.defaultVolume
         tempo_events = [(event.time, event.tempo) for event in output.tracks[0].eventList if event.type == "tempo"]
         notes = [event for event in output.tracks[0].eventList if event.type == "note"]
         metrical_hierarchy,metrical_scores = getMetricStructure(output)
         keys = key_change.analyze_key_change(output)
         accentuation = accentuation_curve(analyze_melodic_accent(output), metrical_scores, keys, notes)
         r1_tempo, r1_loudness, r2, r3, r4_tempo, r4_loudness, r5 = \
             rule1_tempo(group_structure, nominal_tempo, tempo_events), \
             rule1_loudness(group_structure, nominal_volume), \
             rule2(group_structure, nominal_tempo, tempo_events), \
             rule3(notes, nominal_volume, accentuation), \
             rule4_tempo(notes, accentuation, nominal_tempo, tempo_events), \
             rule4_loudness(notes, accentuation, nominal_volume), \
             rule5(group_structure, nominal_tempo, tempo_events)
         # let all other agents evaluate the performance
         for a in agents:
             if a is not agent:
                 a.listen(output, r1_tempo, r1_loudness, r2, r3, r4_tempo, r4_loudness, r5)
 def __listen_own(self, nominal_tempo, nominal_volume):
     self.__logger.debug("Listening to self")
     performance = self.performance
     group_structure = getNoteGroups(performance)
     tempo_events = [(event.time, event.tempo)
                     for event in performance.tracks[0].eventList
                     if event.type == "tempo"]
     notes = [
         event for event in performance.tracks[0].eventList
         if event.type == "note"
     ]
     metrical_hierarchy, metrical_scores = getMetricStructure(performance)
     keys = key_change.analyze_key_change(performance)
     accentuation = accentuation_curve(analyze_melodic_accent(performance),
                                       metrical_scores, keys, notes)
     r1_tempo, r1_loudness, r2, r3, r4_tempo, r4_loudness, r5 = \
         rule1_tempo(group_structure, nominal_tempo, tempo_events), \
         rule1_loudness(group_structure, nominal_volume), \
         rule2(group_structure, nominal_tempo, tempo_events), \
         rule3(notes, nominal_volume, accentuation), \
         rule4_tempo(notes, accentuation, nominal_tempo, tempo_events), \
         rule4_loudness(notes, accentuation, nominal_volume), \
         rule5(group_structure, nominal_tempo, tempo_events)
     return self.evaluate(r1_tempo, r1_loudness, r2, r3, r4_tempo,
                          r4_loudness, r5)
 def __listen_own(self, nominal_tempo, nominal_volume):
     self.__logger.debug("Listening to self")
     performance = self.performance
     group_structure = getNoteGroups(performance)
     tempo_events = [(event.time, event.tempo) for event in performance.tracks[0].eventList if event.type == "tempo"]
     notes = [event for event in performance.tracks[0].eventList if event.type == "note"]
     metrical_hierarchy,metrical_scores = getMetricStructure(performance)
     keys = key_change.analyze_key_change(performance)
     accentuation = accentuation_curve(analyze_melodic_accent(performance), metrical_scores, keys, notes)
     r1_tempo, r1_loudness, r2, r3, r4_tempo, r4_loudness, r5 = \
         rule1_tempo(group_structure, nominal_tempo, tempo_events), \
         rule1_loudness(group_structure, nominal_volume), \
         rule2(group_structure, nominal_tempo, tempo_events), \
         rule3(notes, nominal_volume, accentuation), \
         rule4_tempo(notes, accentuation, nominal_tempo, tempo_events), \
         rule4_loudness(notes, accentuation, nominal_volume), \
         rule5(group_structure, nominal_tempo, tempo_events)
     return self.evaluate(r1_tempo, r1_loudness, r2, r3, r4_tempo, r4_loudness, r5)
Beispiel #4
0
 def cycle(self):
     """
     A single cycle that allows all agents to perform.
     """
     agents = self.agents
     random.shuffle(agents)
     for agent in agents:
         # make the agent perform
         output = agent.perform()
         group_structure = getNoteGroups(output)
         nominal_tempo = self.defaultTempo
         nominal_volume = self.defaultVolume
         tempo_events = [(event.time, event.tempo)
                         for event in output.tracks[0].eventList
                         if event.type == "tempo"]
         notes = [
             event for event in output.tracks[0].eventList
             if event.type == "note"
         ]
         metrical_hierarchy, metrical_scores = getMetricStructure(output)
         keys = key_change.analyze_key_change(output)
         accentuation = accentuation_curve(analyze_melodic_accent(output),
                                           metrical_scores, keys, notes)
         r1_tempo, r1_loudness, r2, r3, r4_tempo, r4_loudness, r5 = \
             rule1_tempo(group_structure, nominal_tempo, tempo_events), \
             rule1_loudness(group_structure, nominal_volume), \
             rule2(group_structure, nominal_tempo, tempo_events), \
             rule3(notes, nominal_volume, accentuation), \
             rule4_tempo(notes, accentuation, nominal_tempo, tempo_events), \
             rule4_loudness(notes, accentuation, nominal_volume), \
             rule5(group_structure, nominal_tempo, tempo_events)
         # let all other agents evaluate the performance
         for a in agents:
             if a is not agent:
                 a.listen(output, r1_tempo, r1_loudness, r2, r3, r4_tempo,
                          r4_loudness, r5)