music.mix_with_offset¶
- music.mix_with_offset(first_sonic_vector, second_sonic_vector, duration=0, number_of_samples=0, sample_rate=44100)[source]¶
Mix two sonic vector by placing the beginning of the second one a specified number of seconds after the first one.
- Parameters:
- first_sonic_vector
numericarray A sequence of PCM samples.
- second_sonic_vector
numericarray Another sequence of PCM samples.
- duration
numeric The offset of the second sound in seconds: how far after the start of the first the second begins. Negative starts the second sound that many seconds before the first one ends.
- number_of_samples
int The offset in samples, taken instead of
durationwhen given.- sample_rate
int The sample rate in Hertz.
- first_sonic_vector
- Returns:
ndarrayThe two sounds summed at that offset, long enough to hold both.
- Parameters:
- Return type:
NDArray[float64]
See also
mix_many_with_offsetsthe same, for any number of sounds, each offset from the mix built so far.
mix_manya list of sounds aligned at their starts or their ends.
Notes
A negative
durationmust satisfy-duration * sample_rate < first_sonic_vector.shape[-1]: the second sound cannot begin before the first one does.The description of
durationabove was truncated mid-sentence, and its last line sat at column zero, so numpydoc read “s1 ends.” as a parameter of this function and rendered it as one.Examples
>>> late = mix_with_offset(note(220, 1), note(330, 1), duration=0.5) >>> len(late) / 44100 # the second note starts half a second in 1.5