def main(): stock = FrequencyResponse.read_from_csv('data/HE400S stock.csv') focus = FrequencyResponse.read_from_csv('data/HE400S focus.csv') base = FrequencyResponse.read_from_csv( 'innerfidelity/data/HiFiMAN HE400S/HiFiMAN HE400S.csv') stock.interpolate(f_min=20, f_max=20000) stock.center() focus.interpolate(f_min=20, f_max=20000) focus.center() base.interpolate(f=stock.frequency) base.center() diff = FrequencyResponse(name='Diff', frequency=stock.frequency, raw=focus.raw - stock.raw) fr = FrequencyResponse(name='HE400S with Focus Pads', frequency=stock.frequency, raw=base.raw + diff.raw) _fr = FrequencyResponse(name='debug', frequency=stock.frequency, raw=base.raw, smoothed=diff.raw, equalization=fr.raw) _fr.plot_graph() fr.smoothen(window_size=1 / 5, iterations=10, treble_window_size=1 / 2, treble_iterations=100) #stock.plot_graph() #focus.plot_graph() #diff.plot_graph() #base.plot_graph() #fr.plot_graph() os.makedirs('innerfidelity/data/HiFiMAN HE400S with Focus Pads', exist_ok=True) fr.write_to_csv( file_path= 'innerfidelity/data/HiFiMAN HE400S with Focus Pads/HiFiMAN HE400S with Focus Pads ORIG.csv' ) fr.equalize(max_gain=12, smoothen=True, window_size=1 / 5, bass_target=4) fr.write_to_csv( file_path= 'innerfidelity/data/HiFiMAN HE400S with Focus Pads/HiFiMAN HE400S with Focus Pads.csv' ) fig, ax = fr.plot_graph( show=False, file_path= 'innerfidelity/data/HiFiMAN HE400S with Focus Pads/HiFiMAN HE400S with Focus Pads.png' ) plt.close(fig) fr.write_eqapo_graphic_eq( 'innerfidelity/data/HiFiMAN HE400S with Focus Pads/HiFiMAN HE400S with Focus Pads EqAPO.txt' )
def main(): fig, ax = plt.subplots() diffs = [] # Calculate differences for all models for file in glob(os.path.join('compensation', 'compensated', '**', '*.csv'), recursive=True): file = os.path.abspath(file) comp = FrequencyResponse.read_from_csv(file) comp.interpolate() comp.center() raw_data_path = file.replace('compensated', 'raw') raw = FrequencyResponse.read_from_csv(raw_data_path) raw.interpolate() raw.center() diff = FrequencyResponse(name=comp.name, frequency=comp.frequency, raw=raw.raw - comp.raw) plt.plot(diff.frequency, diff.raw) diffs.append(diff.raw) # Average and smoothen difference f = FrequencyResponse.generate_frequencies() diffs = np.vstack(diffs) diff = np.mean(diffs, axis=0) diff = FrequencyResponse(name='Headphone.com Compensation', frequency=f, raw=diff) diff.smoothen(window_size=1 / 9, iterations=10) diff.raw = diff.smoothed diff.smoothed = np.array([]) plt.xlabel('Frequency (Hz)') plt.semilogx() plt.xlim([20, 20000]) plt.ylabel('Amplitude (dBr)') plt.ylim([-15, 15]) plt.grid(which='major') plt.grid(which='minor') plt.title('Headphone.com Compensation Function') ax.xaxis.set_major_formatter(ticker.StrMethodFormatter('{x:.0f}')) plt.show() diff.write_to_csv('headphonecom_compensation.csv') diff.plot_graph(f_min=10, f_max=20000, file_path='headphonecom_compensation.png')
def main(): dt770 = FrequencyResponse.read_from_csv('headphonecom/data/onear/Beyerdynamic DT770/Beyerdynamic DT770.csv') dt770.interpolate() he400s = FrequencyResponse.read_from_csv('innerfidelity/data/onear/HiFiMAN HE400S/HiFiMAN HE400S.csv') he400s.interpolate() calibration = FrequencyResponse.read_from_csv('calibration/headphonecom_raw_to_innerfidelity_raw.csv') calibration.interpolate() compensation = FrequencyResponse.read_from_csv('innerfidelity/resources/innerfidelity_compensation_2017.csv') compensation.interpolate() dt770_calibrated = FrequencyResponse(name='DT 770 calibrated', frequency=dt770.frequency, raw=dt770.raw) dt770_calibrated.calibrate(calibration) dt770_calibrated.compensate(he400s) #dt770_calibrated.compensate(compensation) dt770_calibrated.center() dt770_calibrated.smoothen() dt770_calibrated.equalize(smoothen=True) dt770_calibrated.plot_graph(a_min=-20, a_max=20)
def main(): # Filenames if_files = list( glob(os.path.join('innerfidelity', 'data', '**', '*.csv'), recursive=True)) if_file_names = [os.path.split(os.path.abspath(f))[-1] for f in if_files] normalized_if_files = [normalize(s) for s in if_file_names] hp_files = list( glob(os.path.join('headphonecom', 'data', '**', '*.csv'), recursive=True)) # Find matching files matching_if_files = [] matching_hp_files = [] for hp_file in hp_files: file_name = os.path.split(os.path.abspath(hp_file))[-1] for i in range(len(normalized_if_files)): if normalized_if_files[i] == normalize(file_name): matching_hp_files.append(hp_file) matching_if_files.append(if_files[i]) # Write mathces to file for manual inspection df = pd.DataFrame( np.array([matching_hp_files, matching_if_files]).transpose()) df.to_csv('matches.csv', index=False, header=False) fig, ax = plt.subplots() diffs = [] # Calculate differences for all models if_compensation = FrequencyResponse.read_from_csv( os.path.join('innerfidelity', 'resources', 'innerfidelity_compensation_2017.csv')) if_compensation.interpolate() hp_compensation = FrequencyResponse.read_from_csv( os.path.join('headphonecom', 'resources', 'headphonecom_compensation.csv')) hp_compensation.interpolate() for i in range(len(matching_if_files)): if_fr = FrequencyResponse.read_from_csv(matching_if_files[i]) if_fr.interpolate() if_fr.center() #if_fr.compensate(if_compensation) hp_fr = FrequencyResponse.read_from_csv(matching_hp_files[i]) hp_fr.interpolate() hp_fr.center() #hp_fr.compensate(hp_compensation) #diff = FrequencyResponse(name=if_fr.name, frequency=if_fr.frequency, raw=hp_fr.error - if_fr.error) diff = FrequencyResponse(name=if_fr.name, frequency=if_fr.frequency, raw=hp_fr.raw - if_fr.raw) plt.plot(diff.frequency, diff.raw) diffs.append(diff.raw) # Average and smoothen difference f = FrequencyResponse.generate_frequencies() diffs = np.vstack(diffs) diff = np.mean(diffs, axis=0) std = np.std(diffs, axis=0) diff = FrequencyResponse(name='Headphone.com Raw to Innerfidelity Raw', frequency=f, raw=diff) diff.smoothen(window_size=1 / 9, iterations=10) diff.raw = diff.smoothed diff.smoothed = np.array([]) plt.xlabel('Frequency (Hz)') plt.semilogx() plt.xlim([20, 20000]) plt.ylabel('Amplitude (dBr)') plt.ylim([-15, 15]) plt.grid(which='major') plt.grid(which='minor') plt.title('Headphone.com Raw to Innerfidelity Raw') ax.xaxis.set_major_formatter(ticker.StrMethodFormatter('{x:.0f}')) plt.show() fig, ax = diff.plot_graph(f_min=10, f_max=20000, show=False) ax.fill_between(diff.frequency, diff.raw + std, diff.raw - std, facecolor='lightblue') plt.legend( ['Headphone.com Raw to Innerfidelity Raw', 'Standard Deviation']) fig.savefig(os.path.join('calibration', 'headphonecom_raw_to_innerfidelity_raq.png'), dpi=240) plt.show() diff.write_to_csv( os.path.join('calibration', 'headphonecom_raw_to_innerfidelity_raw.csv')) diff.raw *= -1 diff.name = 'Innerfidelity Raw to Headphone.com Raw' fig, ax = diff.plot_graph(f_min=10, f_max=20000, show=False) ax.fill_between(diff.frequency, diff.raw + std, diff.raw - std, facecolor='lightblue') plt.legend( ['Innerfidelity Raw to Headphone.com Raw', 'Standard Deviation']) fig.savefig(os.path.join('calibration', 'innerfidelity_raw_to_headphonecom_raw.png'), dpi=240) plt.show() diff.write_to_csv( os.path.join('calibration', 'innerfidelity_raw_to_headphonecom_raw.csv'))