This is a bit weird I have been experimenting a little and found that with Impulcifer already including the headphone equalization I have good localization on my 5.1/7.1 games and movies. I then extracted my Headphone EQ from Impulcifer by using the script below as given earlier, and also included that into hesuvi virtualization. I know having double EQ should be bad but the localization and surround effect is so much more pronounced I'm having a hard time not using it. Can someone else try it and give their views?
import os
import numpy as np
import soundfile as sf
from matplotlib import pyplot as plt
from autoeq.frequency_response import FrequencyResponse
from impulse_response import ImpulseResponse
from impulse_response_estimator import ImpulseResponseEstimator
def equalize(dir_path,
sweep_duration=5,
target=('flat',),
record='headphones.wav',
fig='fig.png',
geq='geq.txt',
channel_balance=True,
max_gain=40, treble_f_lower=10000, treble_f_upper=20000):
record_path = os.path.join(dir_path, record)
record_data, sr = sf.read(record_path)
ire = ImpulseResponseEstimator(min_duration=sweep_duration, fs=sr)
frs = []
for ch in range(record_data.shape[1]):
ir = ImpulseResponse(ire.estimate(record_data[:, ch]), sr)
fr = ir.frequency_response()
fr.interpolate()
if ch >= len(target):
target_index = 0
else:
target_index = ch
if target[target_index] == 'flat':
target_fr = FrequencyResponse(name='flat', frequency=fr.frequency, raw=np.zeros(len(fr.frequency)))
else:
target_fr = FrequencyResponse.read_from_csv(target[target_index])
target_fr.interpolate()
fr.compensate(target_fr)
fr.equalize(max_gain=max_gain, treble_f_lower=treble_f_lower, treble_f_upper=treble_f_upper)
frs.append(fr)
if channel_balance:
ref = np.mean(frs[0].equalized_raw[np.logical_and(frs[0].frequency >= 100, frs[0].frequency <= 3000)])
gains = []
for fr in frs:
gain = ref - np.mean(fr.equalized_raw[np.logical_and(fr.frequency >= 100, fr.frequency <= 3000)])
gains.append(gain)
if geq:
channel_names = 'L R C LFE BL BR SL SR'.split()
geq_full = ''
max_raw = 0
for ch in range(len(frs)):
geq_full += f'Channel: {channel_names[ch]}\n'
if channel_balance:
geq_full += f'Preamp: {gains[ch]} dB\n'
max_raw = np.max(frs[ch].equalization)
geq_full += frs[ch].eqapo_graphic_eq(normalize=False) + '\n'
geq_full += f'\nChannel: ALL\nPreamp: {-max_raw} dB'
geq_path = os.path.join(dir_path, geq)
with open(geq_path, 'w') as geq_file:
geq_file.write(geq_full)
if fig:
fig_path = os.path.join(dir_path, fig)
figure = plt.figure()
ax = plt.gca()
figure.set_size_inches(10, 5)
a_min = np.median(frs[0].raw[:10000]) - 30
frs[0].plot_graph(fig=figure, ax=ax,
show=False, error=False, equalization=False, equalized=True, target=False,
raw_plot_kwargs={"label": "Left", "color": "red", "linewidth": 1})
frs[1].plot_graph(fig=figure, ax=ax,
show=False, error=False, equalization=False, equalized=True, target=False,
raw_plot_kwargs={"label": "Right", "color": "blue", "linewidth": 1})
plt.savefig(fig_path)
equalize(dir_path=r"C:\Windows\System32\Impulcifer\data\demo")