# %% Analysis loop # Iterate over IRs for ir_idx in range(I): print('--------------------------------------------') print('ITER: ', ir_idx) # Get IR ir_file_name = str(ir_idx) + '.wav' ir_file_path = os.path.join(IR_folder_path, ir_file_name) ir, sr = sf.read(ir_file_path) assert sr == fs # Compute real groundtruth RT60 rt60_true[ir_idx] = compute_t60(ir[:, 0], fs, rt60_f)[0, rt_method_idx] # Iterate over audio files for af_idx, af_path in enumerate(audio_files): print(af_idx, af_path) # Build result file name result_file_name = str(ir_idx) + '_' + str(af_idx) + '.npy' result_file_path = os.path.join(result_folder_path, result_file_name) # %% Perform computation only if file does not exist if not os.path.exists(result_file_path): # Get dry audio signal s_t = librosa.core.load(af_path, sr=fs, mono=True)[0][af_start:af_end]
# %% Analysis loop # Iterate over IRs for ir_idx in range(I): print('INSTRUMENT: ', instrument) print('--------------------------------------------') print('ITER: ', ir_idx) # Get IR ir_file_name = str(ir_idx) + '.wav' ir_file_path = os.path.join(IR_folder_path, ir_file_name) ir, sr = sf.read(ir_file_path) assert sr == fs # Compute real groundtruth RT60 rt60_true[ir_idx] = compute_t60(ir[:, 0], fs, rt60_f)[0, rt_method_idx] # Iterate over audio files for af_idx, af_path in enumerate(audio_files): print(af_idx, af_path) # Build result file name result_file_name = str(ir_idx) + '_' + str(af_idx) + '.npy' result_file_path = os.path.join(result_folder_path, result_file_name) # %% Perform computation only if file does not exist if not os.path.exists(result_file_path): # Get dry audio signal s_t = librosa.core.load(af_path, sr=fs, mono=True)[0][af_start:af_end]
# Iterate over IRs for ir_idx in range(3, 4): print('--------------------------------------------') print('ITER: ', ir_idx) # Get IR ir_file_name = str(ir_idx) + '.wav' ir_file_path = os.path.join(IR_folder_path, ir_file_name) ir, sr = sf.read(ir_file_path) assert sr == fs # early IR early_IR = ir[:window_overlap * tau] # Compute real groundtruth RT60 rt60_true = compute_t60(ir[:, 0], fs, rt60_f)[0, 1] # rt10 # Iterate over audio files for af_idx, af_path in enumerate(audio_files[:1]): print(af_idx, af_path) # Build result file name # result_file_name = str(ir_idx) + '_' + str(af_idx) + '.npy' # result_file_path = os.path.join(result_folder_path, result_file_name) # dry signal s_t = librosa.core.load(af_path, sr=fs, mono=True)[0][af_start:af_end] # Ensure there is audio if np.allclose(s_t, 0): warnings.warn('No audio content') continue
filtersize) # plt.figure() # plt.plot(ir_true[iter]) # plt.plot(ir_est_true[iter], linestyle='--', label='true') # plt.plot(ir_est_derv[iter], linestyle='--', label='derv') # # plt.plot(np.abs(ir_est-ir), linestyle=':') # plt.title('SID with non-overlapped STFT - true signal') # plt.show() # %% t60 estimation plot = False true = compute_t60(ir_true[iter], fs, band_centerfreqs, plot=plot, title='True IR') est_true = compute_t60(ir_est_true[iter], fs, band_centerfreqs, plot=plot, title='Estimated IR, true signal') est_derv = compute_t60(ir_est_derv[iter], fs, band_centerfreqs, plot=plot, title='Estimated IR, derv signal') # Report values print('--true rt60, true IR--')
rec_orders) irs = srs.render_rirs_sh(abs_echograms, band_centerfreqs, fs).squeeze().T if irs.ndim == 1: irs = irs[np.newaxis, :] # Normalize as SN3D irs *= np.sqrt(4 * np.pi) # %% ir = irs[0] for t_i, t in enumerate(rt60_types): results_acoustics[i, :, t_i] = compute_t60_acoustics(ir, fs, band_centerfreqs, rt=t) results_mine[i, :, t_i] = compute_t60(ir, fs, band_centerfreqs, rt=t) # %% col = plt.rcParams['axes.prop_cycle'].by_key()['color'] for f_idx in range(nBands): f = band_centerfreqs[f_idx] plt.figure() plt.title('all rt60 estimations, f=' + str(f)) plt.grid() plt.plot(rt60_true[:, f_idx]) # true rt6 at 1k for all iterations plt.plot(results_acoustics[:, f_idx], linestyle='--') plt.plot(results_mine[:, f_idx], linestyle=':')