Exemplo n.º 1
0
    def generate_memory_flush(
        self,
        lowest_pitch:Pitch,
        highest_pitch:Pitch,
        min_sounds=8,
        max_sounds=12,
        sound_play_time=0.2
    ) -> np.array:
        """
        Generate series of random frequencies and random length.

        :lowest_pitch: The lowest pitch
        :highest_pitch: The highest pitch
        :min_sounds: Minimal number of sounds in a series.
        :max_sounds: Maximal number of sounds in a series.
        :sound_play_time: Length of every sound in seconds.

        :returns: Output signal.
        """
        output = np.zeros(0)
        for i in range(random.randint(min_sounds, max_sounds)):
            output = np.concatenate([
                output,
                self.generate_frequency(
                    random.uniform(
                        lowest_pitch.get_frequency(),
                        highest_pitch.get_frequency()
                    ),
                    sound_play_time
                )
            ])
        return output
Exemplo n.º 2
0
    def generate_pitch(self, pitch:Pitch, time:float) -> np.array:
        """
        Generate signal of given length and pitch.

        :pitch: Pitch of output sound.
        :time: Length of sound in seconds.

        :returns: Output signal.
        """
        return self.generate_frequency(pitch.get_frequency(), time)