hum.gen.sine_mix¶
Utils to mix sine waves
-
hum.gen.sine_mix.
freq_based_stationary_wf
(freqs=(200, 400, 600, 800), weights=None, n_samples: int = 43008, sr: int = 44100) → numpy.ndarray[source]¶ Makes a stationary waveform by mixing a number of freqs together, possibly with different weights.
- Parameters
freqs – List(-like) of frequencies (in Hz)
weights – The weights these frequencies should have (all weights will be normalized
n_samples – The number of samples of waveform you want
sr – Sample rate
- Returns
Waveform. A numpy array of samples of the specified sine wave
>>> n_samples = random.randint(2,5) >>> wf = freq_based_stationary_wf(n_samples=n_samples) >>> assert len(wf) == n_samples >>> wf = freq_based_stationary_wf(n_samples = 3, weights = [1,2,3,4]) >>> assert all(wf == [0.0, 0.08534908048813569, 0.16988139234280178])
-
hum.gen.sine_mix.
mk_sine_wf
(freq=5, n_samples=43008, sr=44100, phase=0, gain=1)[source]¶ Make a sine waveform
- Parameters
freq – Frequency (in Hz)
n_samples – The number of samples of waveform you want
sr – Sample rate
phase – Phase (in radians)
gain – (A number to multiply the base sine wave by)
- Returns
Waveform. A numpy array of samples of the specified sine wave
>>> n_samples = random.randint(2,5) >>> wf = mk_sine_wf(n_samples=n_samples) >>> assert len(wf) == n_samples >>> wf = mk_sine_wf(n_samples=3) >>> assert all(wf == [0.0, 0.000712379226274755, 0.0014247580910282892])