<jupyter_start><jupyter_text>Creating sin sweep<jupyter_code>s = np.linspace(0,t, fs*t)

x = chirp(s, f0, 1, f1, method='logarithmic')
x = x.astype(dtype=np.float32)<jupyter_output><empty_output><jupyter_text>Comparing CQT results<jupyter_code>r=2
bins_per_octave = 12*r
n_bins = 104*r-1

CQT2010_layer = Spectrogram.CQT2010(fs, fmin=fmin, n_bins=n_bins, bins_per_octave=bins_per_octave, pad_mode='constant')
fig , ax = plt.subplots(1,2, dpi=200, figsize=(10,4))
cqt_x = CQT2010_layer(torch.tensor(x[None, None, :]))
output_lib1 = cqt(x, sr=fs, fmin=fmin, n_bins=n_bins, bins_per_octave=bins_per_octave, pad_mode='constant')
im1 = ax[0].imshow(cqt_x[0], aspect='auto', origin='lower', cmap=cmap)
im2 = ax[1].imshow(abs(output_lib1), aspect='auto', origin='lower', cmap=cmap)
ax[1].set_yticks([])
# fig.colorbar(im1,ax=ax[0])
# fig.colorbar(im2,ax=ax[1])
ax[0].title.set_text("nnAudio")
ax[1].title.set_text("Librosa")<jupyter_output>Creating low pass filter ...
Low pass filter created, time used = 0.0019 seconds
Creating early downsampling filter ...
No early downsampling is required, downsample_factor =  1
Early downsampling filter created, time used = 0.0001 seconds
Creating CQT kernels ...
CQT kernels created, time used = 0.0051 seconds
Creating STFT kernels ...
STFT kernels created, time used = 0.0623 seconds<jupyter_text>Melspectrogram<jupyter_code>mel_layer = Spectrogram.MelSpectrogram(fs)
fig , ax = plt.subplots(1,2, dpi=200, figsize=(10,4))
mel_x_linear = mel_layer(torch.tensor(x[None, None, :]))
output_lib1 = melspectrogram(x, fs)
ax[0].imshow(mel_x_linear[0], aspect='auto', origin='lower', cmap=cmap)
ax[1].imshow(output_lib1, aspect='auto', origin='lower', cmap=cmap)
ax[1].set_yticks([])
ax[0].title.set_text("nnAudio")
ax[1].title.set_text("Librosa")
print("Linear sweep all close ", np.allclose(mel_x_linear[0].numpy(), output_lib1, rtol=1e-4, atol=1e-4))<jupyter_output>Linear sweep all close  True<jupyter_text>STFT linear freq<jupyter_code>stft_layer_no = Spectrogram.STFT()
stft_x_linear = stft_layer_no(torch.tensor(x[None, None, :]))
output_lib1 = abs(stft(x))

fig , ax = plt.subplots(1,2, dpi=200, figsize=(10,4))
ax[0].imshow(stft_x_linear[0], aspect='auto', origin='lower', cmap=cmap)
ax[1].imshow(output_lib1, aspect='auto', origin='lower', cmap=cmap)
ax[1].set_yticks([])
ax[0].title.set_text("nnAudio")
ax[1].title.set_text("Librosa")
print("Linear sweep all close ", np.allclose(stft_x_linear[0].numpy(), output_lib1, rtol=1e-4, atol=1e-4))<jupyter_output>Linear sweep all close  True<jupyter_text>STFT log-freq<jupyter_code>stft_layer = Spectrogram.STFT(freq_scale='log', fmin=55, fmax=22050, sr=44100)
stft_log_x_linear = stft_layer(torch.tensor(x[None, None, :]))

fig , ax = plt.subplots(1,2, dpi=200, figsize=(10,4))
ax[0].imshow(stft_log_x_linear[0], aspect='auto', origin='lower', cmap=cmap)
ax[1].set_yticks([])
ax[0].title.set_text("nnAudio")
ax[1].title.set_text("Librosa")<jupyter_output>sampling rate = 44100. Please make sure the sampling rate is correct in order to get a valid freq range
{'fraction_non_alphanumeric': 0.16825501150180744, 'fraction_numerical': 0.0466644758462044, 'mean_word_length': 8.05952380952381, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '617166', 'license': 'MIT', 'n_tokens_mistral': 1351, 'n_tokens_neox': 1263, 'n_words': 214, 'path': 'performance_test/log_sine_sweep.ipynb', 'repo_name': 'HudsonHuang/nnAudio', 'size': '3043'}