def add_tone(self, sound): """Add a tone to the end of given Sound object instance. Arguments: sound -- Sound object tone should be added to """ for sample in self.__generate(sound): sound.add_sample(sample)
def combine_tone(self, sound, start_position): """Combine the tone with a Sound object. This method combines the tone with a given sound object instance, starting at the given time. This can be used to add tones to a sound without having to create an additional Sound object. If the tone is longer than the sound, it will extend past the end of the sound. Arguments: sound -- Sound object instance start_position -- start position in seconds """ index = sound.convert_secs_to_samples(start_position) for sample in self.__generate(sound): if index < len(sound.samples): sound.combine_sample_at_index(sample, index) else: sound.add_sample(sample) index += 1