Exemplo n.º 1
0
    def temp_fill_with_rests(self):
        no = ["Synthesizer", "Piano lower", "Piano upper"]
        staves = [s for s in self.staves if s.name not in no]
        for staff in staves:

            for bar in self.bars:
                staff.append(get_rest_bar())
Exemplo n.º 2
0
    def make_drones(self):
        synth = self.score["Synthesizer"]

        # Drone 1
        bars = [get_one_note_bar(self.drones[0]) for _ in self.drone_sections[0]]
        tie(bars)
        synth.extend(bars)

        for rhythm in self.raw_harmonic_rhythm[:4]:
            self.harmonic_rhythm_drones.append([self.drones[0] for r in rhythm])

        # Rest 1
        rest_bars = [get_rest_bar() for _ in self.drone_sections[1]]
        synth.extend(rest_bars)

        for rhythm in self.raw_harmonic_rhythm[4:8]:
            self.harmonic_rhythm_drones.append([None for r in rhythm])

        # Drone 2
        bars = [get_one_note_bar(self.drones[1]) for _ in self.drone_sections[2]]
        tie(bars)
        synth.extend(bars)

        for rhythm in self.raw_harmonic_rhythm[8:12]:
            self.harmonic_rhythm_drones.append([self.drones[1] for r in rhythm])

        #######################################
        #### Rest 2 and Drone 3 A entrance ####
        #######################################

        # First two volume sections are resting
        rest_bars = []
        for section in self.volume_sections[12:14]:
            rest_bars.extend([get_rest_bar() for _ in section])

        for rhythm in self.raw_harmonic_rhythm[12:14]:
            self.harmonic_rhythm_drones.append([None for r in rhythm])

        # The drone comes in at a random point in the third volume section

        drone_3a = self.drones[2][0]

        entrance_section = self.raw_harmonic_rhythm[14]
        start = random.choice(range(len(entrance_section) - 1))

        rests = ["r" for duration in entrance_section[:start]]
        drones = [drone_3a for duration in entrance_section[start:]]

        pitches = rests + drones
        entrance_bars = parse_rhythm(entrance_section, pitches=pitches)

        rhythm = []
        for pitch in pitches:
            if pitch == "r":
                rhythm.append(None)
            else:
                rhythm.append(drone_3a)
        self.harmonic_rhythm_drones.append(rhythm)

        # Last volume section is droning
        drone_bars = [get_one_note_bar(drone_3a) for _ in self.volume_sections[15]]

        self.harmonic_rhythm_drones.append([drone_3a for dur in self.raw_harmonic_rhythm[15]])

        synth.extend(rest_bars + entrance_bars + drone_bars)

        to_tie = entrance_bars + drone_bars

        # TODO ties

        #######################
        #### Drone 3 A & B ####
        #######################

        # First volume section is drone 3 A
        bars_1 = [get_one_note_bar(drone_3a) for _ in self.volume_sections[16]]
        self.harmonic_rhythm_drones.append([drone_3a for dur in self.raw_harmonic_rhythm[16]])

        # Second volume section drone 3 B comes in
        entrance_section = self.raw_harmonic_rhythm[17]
        start = random.choice(range(1, len(entrance_section)))

        a = [drone_3a for duration in entrance_section[:start]]
        both = [self.drones[2] for duration in entrance_section[start:]]

        pitches = a + both
        bars_2 = parse_rhythm(entrance_section, pitches=pitches)

        self.harmonic_rhythm_drones.append(pitches)

        # Third and Fourth volume sections both drones
        bars_3_4 = []
        for section in self.volume_sections[18:20]:
            bars_3_4.extend([get_one_note_bar(self.drones[2]) for _ in section])

        for rhythm in self.raw_harmonic_rhythm[18:20]:
            self.harmonic_rhythm_drones.append([self.drones[2] for dur in rhythm])

        # Fifth volume section drone 3 A exits
        drone_3b = self.drones[2][1]

        exit_section = self.raw_harmonic_rhythm[20]
        start = random.choice(range(1, len(exit_section)))

        both = [self.drones[2] for duration in exit_section[:start]]
        b = [drone_3b for duration in exit_section[start:]]

        pitches = both + b
        bars_5 = parse_rhythm(exit_section, pitches=pitches)

        self.harmonic_rhythm_drones.append(pitches)

        # Sixth volume section is drone 3 B
        bars_6 = [get_one_note_bar(drone_3b) for _ in self.volume_sections[21]]
        self.harmonic_rhythm_drones.append([drone_3b for dur in self.raw_harmonic_rhythm[21]])

        # Seventh volume section drone 3 B exits
        exit_section = self.raw_harmonic_rhythm[22]
        start = random.choice(range(1, len(exit_section)))

        b = [drone_3b for duration in exit_section[:start]]
        rest = ["r" for duration in exit_section[start:]]

        pitches = b + rest
        bars_7 = parse_rhythm(exit_section, pitches=pitches)

        rhythm_drones = []
        for p in pitches:
            if p == "r":
                rhythm_drones.append(None)
            else:
                rhythm_drones.append(p)
        self.harmonic_rhythm_drones.append(rhythm_drones)

        # Eighth volume section is resting
        bars_8 = [get_rest_bar() for _ in self.volume_sections[23]]
        self.harmonic_rhythm_drones.append([None for dur in self.raw_harmonic_rhythm[23]])

        bars = bars_1 + bars_2 + bars_3_4 + bars_5 + bars_6 + bars_7 + bars_8
        synth.extend(bars)

        to_tie += bars
        tie(to_tie)

        # Drone 4
        bars = [get_one_note_bar(self.drones[3]) for _ in self.drone_sections[6]]
        tie(bars)
        synth.extend(bars)

        for rhythm in self.raw_harmonic_rhythm[24:28]:
            self.harmonic_rhythm_drones.append([self.drones[3] for r in rhythm])

        # Rest 4
        bars = [get_rest_bar() for _ in self.drone_sections[7]]
        synth.extend(bars)

        for rhythm in self.raw_harmonic_rhythm[28:]:
            self.harmonic_rhythm_drones.append([None for r in rhythm])