Skip to content

Commit 475bb05

Browse files
committed
Update Calibration parameters
Added Calibration Low and High Cutoff Freq. (Hz) options to advanced settings to control the frequency range of diffuse field calibration
1 parent 8178e07 commit 475bb05

5 files changed

Lines changed: 27 additions & 3 deletions

File tree

ash_toolset/__main__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2634,6 +2634,22 @@ def get_screen_size(default_width=1722, default_height=717):
26342634
with dpg.tooltip("octave_smoothing_n"):
26352635
dpg.add_text("Sets the fractional octave smoothing for calibration filters (e.g., 3 = 1/3 octave). Higher values result in more detail; lower values result in a smoother curve.")
26362636

2637+
2638+
# Low Cutoff Frequency
2639+
with dpg.table_row():
2640+
dpg.add_text("Binaural Sim.")
2641+
dpg.add_text("Calibration Low Cutoff Freq. (Hz)")
2642+
dpg.add_input_int(label="", width=190, tag='brir_df_cal_low_f', min_value=1, max_value=500,default_value=loaded_values["brir_df_cal_low_f"],min_clamped=True, max_clamped=True)
2643+
with dpg.tooltip("brir_df_cal_low_f"):
2644+
dpg.add_text("The lower frequency limit for inversion. Below this point, the correction magnitude is clamped to the value at this limit to avoid over-excursion.")
2645+
2646+
# High Cutoff Frequency
2647+
with dpg.table_row():
2648+
dpg.add_text("Binaural Sim.")
2649+
dpg.add_text("Calibration High Cutoff Freq. (Hz)")
2650+
dpg.add_input_int(label="", width=190, tag='brir_df_cal_high_f', min_value=5000, max_value=22050,default_value=loaded_values["brir_df_cal_high_f"],min_clamped=True, max_clamped=True)
2651+
with dpg.tooltip("brir_df_cal_high_f"):
2652+
dpg.add_text("The upper frequency limit for inversion. Above this point, the magnitude is extended (clamped) to prevent sharp high-frequency rises or artifacts.")
26372653

26382654
with dpg.table_row():
26392655
dpg.add_text("Binaural Sim.")

ash_toolset/brir_generation.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ def generate_integrated_brir(brir_name, spatial_res=1, report_progress=0, gui_l
8585
octave_smoothing_n=brir_meta_dict.get("octave_smoothing_n")
8686
brir_df_cal_factor=brir_meta_dict.get("brir_df_cal_factor")
8787
gen_fir_length=brir_meta_dict.get("gen_fir_length")
88+
brir_df_cal_low_f=brir_meta_dict.get("brir_df_cal_low_f")
89+
brir_df_cal_high_f=brir_meta_dict.get("brir_df_cal_high_f")
8890
else:
8991
raise ValueError('brir_meta_dict not populated')
9092

@@ -725,7 +727,7 @@ def generate_integrated_brir(brir_name, spatial_res=1, report_progress=0, gui_l
725727
#convert to mag
726728
brir_fft_avg_mag = hf.db2mag(brir_fft_avg_db)
727729
#level ends of spectrum
728-
brir_fft_avg_mag_sm = hf.level_spectrum_ends(brir_fft_avg_mag, 15, 18500, smooth_win = octave_smoothing_n, n_fft=CN.N_FFT)#40, 19000, smooth_win = 7
730+
brir_fft_avg_mag_sm = hf.level_spectrum_ends(brir_fft_avg_mag, brir_df_cal_low_f, brir_df_cal_high_f, smooth_win = octave_smoothing_n, n_fft=CN.N_FFT)#40, 19000, smooth_win = 7
729731
#octave smoothing
730732
brir_fft_avg_mag_sm = hf.smooth_gaussian_octave(data=brir_fft_avg_mag_sm, n_fft=CN.N_FFT, fraction=octave_smoothing_n)
731733

@@ -757,7 +759,7 @@ def generate_integrated_brir(brir_name, spatial_res=1, report_progress=0, gui_l
757759
# 2. Run your function with the override
758760
# This will return the EQ-IR as a (1, 1, n_fft) array
759761
eq_ir_dataset = hf.equalize_brirs_parametric(brir_dataset=impulse, diff_db_override=hf.mag2db(brir_fft_avg_mag_inv), override_n_fft=CN.N_FFT,
760-
num_filters=50,low_freq_cut = 12.0, high_freq_cut = 18000.0)
762+
num_filters=50,low_freq_cut = brir_df_cal_low_f, high_freq_cut = brir_df_cal_high_f)
761763
# 3. Extract the 1D array for easy convolution later
762764
brir_df_inv_fir = eq_ir_dataset.flatten()
763765
else:

ash_toolset/callbacks.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3172,6 +3172,8 @@ def get_brir_dict():
31723172
hp_rolloff_comp = dpg.get_value('hp_rolloff_comp')
31733173
fb_filtering = dpg.get_value('fb_filtering')
31743174
brir_max_length = dpg.get_value('brir_max_length')
3175+
brir_df_cal_low_f = dpg.get_value('brir_df_cal_low_f')
3176+
brir_df_cal_high_f = dpg.get_value('brir_df_cal_high_f')
31753177

31763178

31773179
brir_meta_dict = {
@@ -3226,7 +3228,7 @@ def get_brir_dict():
32263228
'room_target': room_target, 'room_target_int': room_target_int, 'direct_gain_db': direct_gain_db,
32273229
'ac_space_short': ac_space_short, 'ac_space_gui': ac_space_gui, 'brir_hp_comp': brir_hp_comp, 'brir_elf':brir_elf,
32283230
'samp_freq_int': samp_freq_int, 'samp_freq_str': samp_freq_str,
3229-
'bit_depth': bit_depth, 'bit_depth_str': bit_depth_str,
3231+
'bit_depth': bit_depth, 'bit_depth_str': bit_depth_str, 'brir_df_cal_low_f': brir_df_cal_low_f, 'brir_df_cal_high_f': brir_df_cal_high_f,
32303232

32313233
# Additional variables
32323234
'hrtf_symmetry': hrtf_symmetry, 'er_delay_time': er_delay_time, 'reverb_tail_crop_db': reverb_tail_crop_db, 'brir_df_cal_mode':brir_df_cal_mode, 'brir_max_length':brir_max_length,

ash_toolset/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,6 +1589,8 @@ def to_circular(angle):
15891589
"octave_smoothing_n": 6,
15901590
"brir_df_cal_factor":1.0,
15911591
"gen_fir_length":4096,
1592+
"brir_df_cal_low_f":10,
1593+
"brir_df_cal_high_f":19500,
15921594

15931595
# AS Import tool
15941596
"as_reverb_tail_mode": AS_TAIL_MODE_LIST[0],

ash_toolset/helper_functions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1963,6 +1963,8 @@ def equalize_brirs_parametric(
19631963
and applies filtering via FFT convolution for massive speed gains.
19641964
"""
19651965
# --- 1. Preparation ---
1966+
low_freq_cut = float(low_freq_cut)
1967+
high_freq_cut = float(high_freq_cut)
19661968
brir_dataset = np.asarray(brir_dataset, dtype=np.float64)
19671969
orig_shape = brir_dataset.shape
19681970
n_samples = orig_shape[-1]

0 commit comments

Comments
 (0)