MCPcopy Create free account
hub / github.com/NVIDIA/DALI / generate_waveforms

Function generate_waveforms

dali/test/python/test_audio_decoder_utils.py:20–34  ·  view source on GitHub ↗

generate sinewaves with given frequencies, add Hann envelope and store in channel-last layout

(length, frequencies)

Source from the content-addressed store, hash-verified

18
19
20def generate_waveforms(length, frequencies):
21 """
22 generate sinewaves with given frequencies,
23 add Hann envelope and store in channel-last layout
24 """
25 n = int(math.ceil(length))
26 X = np.arange(n, dtype=np.float32)
27
28 def window(x):
29 x = 2 * x / length - 1
30 np.clip(x, -1, 1, out=x)
31 return 0.5 * (1 + np.cos(x * math.pi))
32
33 wave = np.sin(X[:, np.newaxis] * (np.array(frequencies) * (2 * math.pi)))
34 return wave * window(X)[:, np.newaxis]
35
36
37def rosa_resample(input, in_rate, out_rate):

Callers 7

create_refFunction · 0.90
create_refFunction · 0.90
create_filesFunction · 0.90
create_refFunction · 0.90
create_test_filesFunction · 0.90

Calls 3

windowFunction · 0.85
ceilMethod · 0.80
sinMethod · 0.80

Tested by

no test coverage detected