Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
sig_B = sph.soundfield_to_b(sig)
F_nm = sph.sht(sig, N, azi, colat, SH_type='real')
F_nm_t = sph.sht(sig_t, N, azi, colat, SH_type='real')
# %%
F_nm_c = sph.sht(sig, N, azi, colat, SH_type='complex')
F_nm_c_t = sph.sht(sig_t, N, azi, colat, SH_type='complex')
# %%
F_nm_lst = sph.sht_lstsq(sig, N, azi, colat, SH_type='complex')
F_nm_lst_t = sph.sht_lstsq(sig_t, N, azi, colat, SH_type='real')
# %% inverse SHT
f = sph.inverse_sht(F_nm, azi, colat, SH_type='real')
f_c_t = sph.inverse_sht(F_nm_c_t, azi, colat, SH_type='complex')
f_lst_t = sph.inverse_sht(F_nm_lst_t, azi, colat, SH_type='real')
# %% Checks
print("Single dimension signal:")
utils.test_diff(sig, f)
print("Complex valued SHT of time signal:")
utils.test_diff(sig_t, f_c_t)
print("Real valued least-squares SHT of time signal:")
utils.test_diff(sig_t, f_lst_t)
# %%
# Check B format conversion
B_sig = np.array([1, 1, 0, 0]) # W, X, Y, Z
F_B = sph.b_to_sh(B_sig)
B_sig_re = sph.sh_to_b(F_B)
print("B format to SH conversion:")
utils.test_diff(B_sig, B_sig_re)
zip_ref.extractall(os.path.join(current_file_dir, '../data/'))
file = loadmat(filename)
# CTF already compensated in DIR
# Extracting the data is a bit ugly here...
SamplingRate = int(file['SamplingRate'])
SH_l = file['SH'][0][0][0]
SH_r = file['SH'][0][0][1]
f = np.squeeze(file['SH'][0][0][5])
# default grid:
if (grid_azi is None) and (grid_colat is None):
grid_azi, grid_colat, _ = grids.gauss(35) # grid positions
# %% Inverse SHT
HRTF_l = sph.inverse_sht(SH_l, grid_azi, grid_colat, 'complex')
HRTF_r = sph.inverse_sht(SH_r, grid_azi, grid_colat, 'complex')
assert HRTF_l.shape == HRTF_r.shape
# %%
hrir_l = np.fft.irfft(HRTF_l) # creates 256 samples(t)
hrir_r = np.fft.irfft(HRTF_r) # creates 256 samples(t)
assert hrir_l.shape == hrir_r.shape
# %% Resample
fs_target = 48000
hrir_l_48k, hrir_r_48k, _ = process.resample_hrirs(hrir_l, hrir_r,
SamplingRate,
fs_target)
fs_target = 96000
hrir_l_96k, hrir_r_96k, _ = process.resample_hrirs(hrir_l, hrir_r,
SamplingRate,
fs_target)
with zipfile.ZipFile(io.BytesIO(r.content)) as zip_ref:
zip_ref.extractall(os.path.join(current_file_dir, '../data/'))
file = loadmat(filename)
# CTF already compensated in DIR
# Extracting the data is a bit ugly here...
SamplingRate = int(file['SamplingRate'])
SH_l = file['SH'][0][0][0]
SH_r = file['SH'][0][0][1]
f = np.squeeze(file['SH'][0][0][5])
# default grid:
if (grid_azi is None) and (grid_colat is None):
grid_azi, grid_colat, _ = grids.gauss(35) # grid positions
# %% Inverse SHT
HRTF_l = sph.inverse_sht(SH_l, grid_azi, grid_colat, 'complex')
HRTF_r = sph.inverse_sht(SH_r, grid_azi, grid_colat, 'complex')
assert HRTF_l.shape == HRTF_r.shape
# %%
hrir_l = np.fft.irfft(HRTF_l) # creates 256 samples(t)
hrir_r = np.fft.irfft(HRTF_r) # creates 256 samples(t)
assert hrir_l.shape == hrir_r.shape
# %% Resample
fs_target = 48000
hrir_l_48k, hrir_r_48k, _ = process.resample_hrirs(hrir_l, hrir_r,
SamplingRate,
fs_target)
fs_target = 96000
hrir_l_96k, hrir_r_96k, _ = process.resample_hrirs(hrir_l, hrir_r,
SamplingRate,
fs_target)