Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EasyEffects GraphicEQ option and graphic-eq-bands option #703

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion autoeq/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from autoeq.constants import DEFAULT_MAX_GAIN, DEFAULT_TREBLE_F_LOWER, DEFAULT_TREBLE_F_UPPER, \
DEFAULT_TREBLE_GAIN_K, DEFAULT_FS, DEFAULT_BIT_DEPTH, DEFAULT_PHASE, DEFAULT_F_RES, DEFAULT_BASS_BOOST_FC, \
DEFAULT_BASS_BOOST_Q, DEFAULT_SMOOTHING_WINDOW_SIZE, DEFAULT_TREBLE_SMOOTHING_WINDOW_SIZE, DEFAULT_TREBLE_BOOST_FC, \
DEFAULT_TREBLE_BOOST_Q, DEFAULT_PREAMP, DEFAULT_SOUND_SIGNATURE_SMOOTHING_WINDOW_SIZE, DEFAULT_MAX_SLOPE
DEFAULT_TREBLE_BOOST_Q, DEFAULT_PREAMP, DEFAULT_SOUND_SIGNATURE_SMOOTHING_WINDOW_SIZE, DEFAULT_MAX_SLOPE, DEFAULT_GRAPHIC_EQ_BANDS
from autoeq.batch_processing import batch_processing


Expand All @@ -31,6 +31,9 @@ def cli_args():
'"compensation", "innerfidelity/resources" and "headphonecom/resources".')
arg_parser.add_argument('--equalize', action='store_true',
help='Will run equalization if this parameter exists, no value needed.')
arg_parser.add_argument('--graphic-eq-bands', type=int, default=DEFAULT_GRAPHIC_EQ_BANDS,
help='Number of bands to use for graphic eq preset generation.'
f'Defaults to {DEFAULT_GRAPHIC_EQ_BANDS}.')
arg_parser.add_argument('--parametric-eq', action='store_true',
help='Will produce parametric eq settings if this parameter exists, no value needed.')
arg_parser.add_argument('--fixed-band-eq', action='store_true',
Expand Down
12 changes: 6 additions & 6 deletions autoeq/batch_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@

from autoeq.constants import DEFAULT_MAX_GAIN, DEFAULT_TREBLE_F_LOWER, DEFAULT_TREBLE_F_UPPER, \
DEFAULT_TREBLE_GAIN_K, DEFAULT_FS, DEFAULT_BIT_DEPTH, DEFAULT_PHASE, DEFAULT_F_RES, DEFAULT_BASS_BOOST_GAIN, \
DEFAULT_BASS_BOOST_FC, DEFAULT_BASS_BOOST_Q, DEFAULT_SMOOTHING_WINDOW_SIZE, \
DEFAULT_BASS_BOOST_FC, DEFAULT_BASS_BOOST_Q, DEFAULT_SMOOTHING_WINDOW_SIZE, DEFAULT_GRAPHIC_EQ_BANDS, \
DEFAULT_TREBLE_SMOOTHING_WINDOW_SIZE, PEQ_CONFIGS, DEFAULT_TREBLE_BOOST_GAIN, DEFAULT_TREBLE_BOOST_Q, \
DEFAULT_TREBLE_BOOST_FC, DEFAULT_PREAMP, DEFAULT_SOUND_SIGNATURE_SMOOTHING_WINDOW_SIZE, DEFAULT_MAX_SLOPE
from autoeq.frequency_response import FrequencyResponse


def batch_processing(input_file=None, input_dir=None, output_dir=None, new_only=False, standardize_input=False,
compensation=None, parametric_eq=False, fixed_band_eq=False, rockbox=False,
ten_band_eq=False, parametric_eq_config=None, fixed_band_eq_config=None, convolution_eq=False,
fs=DEFAULT_FS, bit_depth=DEFAULT_BIT_DEPTH, phase=DEFAULT_PHASE, f_res=DEFAULT_F_RES,
ten_band_eq=False, graphic_eq_bands=DEFAULT_GRAPHIC_EQ_BANDS, parametric_eq_config=None, fixed_band_eq_config=None,
convolution_eq=False, fs=DEFAULT_FS, bit_depth=DEFAULT_BIT_DEPTH, phase=DEFAULT_PHASE, f_res=DEFAULT_F_RES,
bass_boost_gain=DEFAULT_BASS_BOOST_GAIN, bass_boost_fc=DEFAULT_BASS_BOOST_FC,
bass_boost_q=DEFAULT_BASS_BOOST_Q, treble_boost_gain=DEFAULT_TREBLE_BOOST_GAIN,
treble_boost_fc=DEFAULT_TREBLE_BOOST_FC, treble_boost_q=DEFAULT_TREBLE_BOOST_Q,
Expand Down Expand Up @@ -109,7 +109,7 @@ def batch_processing(input_file=None, input_dir=None, output_dir=None, new_only=
n_total += 1
args = (input_file_path, output_file_path, bass_boost_fc, bass_boost_gain, bass_boost_q,
treble_boost_fc, treble_boost_gain, treble_boost_q,
bit_depth, compensation, convolution_eq, f_res, fixed_band_eq, fs, parametric_eq_config,
bit_depth, compensation, convolution_eq, f_res, fixed_band_eq, fs, graphic_eq_bands, parametric_eq_config,
fixed_band_eq_config, max_gain, max_slope, window_size, treble_window_size,
parametric_eq, phase, rockbox, sound_signature, sound_signature_smoothing_window_size,
standardize_input, ten_band_eq, tilt, treble_f_lower, treble_f_upper, treble_gain_k, preamp)
Expand All @@ -132,7 +132,7 @@ def process_file_wrapper(params):

def process_file(input_file_path, output_file_path, bass_boost_fc, bass_boost_gain, bass_boost_q,
treble_boost_fc, treble_boost_gain, treble_boost_q, bit_depth,
compensation, convolution_eq, f_res, fixed_band_eq, fs, parametric_eq_config,
compensation, convolution_eq, f_res, fixed_band_eq, fs, graphic_eq_bands, parametric_eq_config,
fixed_band_eq_config, max_gain, max_slope, window_size, treble_window_size, parametric_eq, phase,
rockbox, sound_signature, sound_signature_smoothing_window_size, standardize_input, ten_band_eq, tilt,
treble_f_lower, treble_f_upper, treble_gain_k, preamp):
Expand Down Expand Up @@ -185,7 +185,7 @@ def process_file(input_file_path, output_file_path, bass_boost_fc, bass_boost_ga
treble_f_upper=treble_f_upper,
treble_gain_k=treble_gain_k,)

fr.write_eqapo_graphic_eq(output_file_path.replace('.csv', ' GraphicEQ.txt'), normalize=True, preamp=preamp)
fr.write_eqapo_graphic_eq(output_file_path.replace('.csv', ' GraphicEQ.txt'), normalize=True, preamp=preamp, graphic_eq_bands=graphic_eq_bands)

if parametric_eq:
parametric_peqs = fr.optimize_parametric_eq(
Expand Down
2 changes: 1 addition & 1 deletion autoeq/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
DEFAULT_MAX_SLOPE = 18.0
DEFAULT_PREAMP = 0.0

DEFAULT_GRAPHIC_EQ_STEP = 1.0563 # Produces 127 samples with greatest frequency of 19871
DEFAULT_GRAPHIC_EQ_BANDS = 127

ROOT_DIR = os.path.abspath(os.path.dirname(os.path.abspath(__file__)))
MOD_REGEX = r' \((sample|serial number) [a-zA-Z0-9\-]+\)$'
Expand Down
10 changes: 5 additions & 5 deletions autoeq/frequency_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
DEFAULT_SMOOTHING_ITERATIONS, DEFAULT_TREBLE_SMOOTHING_F_LOWER, DEFAULT_TREBLE_SMOOTHING_F_UPPER, \
DEFAULT_TREBLE_SMOOTHING_WINDOW_SIZE, DEFAULT_TREBLE_SMOOTHING_ITERATIONS, DEFAULT_TILT, DEFAULT_FS, \
DEFAULT_F_RES, DEFAULT_BASS_BOOST_GAIN, DEFAULT_BASS_BOOST_FC, \
DEFAULT_BASS_BOOST_Q, DEFAULT_GRAPHIC_EQ_STEP, HARMAN_INEAR_PREFENCE_FREQUENCIES, \
DEFAULT_BASS_BOOST_Q, DEFAULT_GRAPHIC_EQ_BANDS, HARMAN_INEAR_PREFENCE_FREQUENCIES, \
HARMAN_OVEREAR_PREFERENCE_FREQUENCIES, PREAMP_HEADROOM, DEFAULT_MAX_SLOPE, \
DEFAULT_BIQUAD_OPTIMIZATION_F_STEP, DEFAULT_TREBLE_BOOST_GAIN, DEFAULT_TREBLE_BOOST_FC, DEFAULT_TREBLE_BOOST_Q, \
DEFAULT_PREAMP, DEFAULT_SOUND_SIGNATURE_SMOOTHING_WINDOW_SIZE
Expand Down Expand Up @@ -247,10 +247,10 @@ def write_to_csv(self, file_path=None):
df = pd.DataFrame(self.to_dict())
df.to_csv(file_path, header=True, index=False, float_format='%.2f')

def eqapo_graphic_eq(self, normalize=True, preamp=DEFAULT_PREAMP, f_step=DEFAULT_GRAPHIC_EQ_STEP):
def eqapo_graphic_eq(self, normalize=True, preamp=DEFAULT_PREAMP, n=DEFAULT_GRAPHIC_EQ_BANDS):
"""Generates EqualizerAPO GraphicEQ string from equalization curve."""
fr = self.__class__(name='hack', frequency=self.frequency, raw=self.equalization)
n = np.ceil(np.log(20000 / 20) / np.log(f_step))
f_step = np.e ** (np.log(20000 / 20) / (n - 0.8821745695985186))
f = 20 * f_step ** np.arange(n)
f = np.sort(np.unique(f.astype('int')))
fr.interpolate(f=f)
Expand All @@ -265,10 +265,10 @@ def eqapo_graphic_eq(self, normalize=True, preamp=DEFAULT_PREAMP, f_step=DEFAULT
s = 'GraphicEQ: ' + s
return s

def write_eqapo_graphic_eq(self, file_path, normalize=True, preamp=DEFAULT_PREAMP):
def write_eqapo_graphic_eq(self, file_path, normalize=True, preamp=DEFAULT_PREAMP, n=DEFAULT_GRAPHIC_EQ_BANDS):
"""Writes equalization graph to a file as Equalizer APO config."""
file_path = os.path.abspath(file_path)
s = self.eqapo_graphic_eq(normalize=normalize, preamp=preamp)
s = self.eqapo_graphic_eq(normalize=normalize, preamp=preamp, n=n)
with open(file_path, 'w', encoding='utf-8') as f:
f.write(s)
return s
Expand Down
6 changes: 4 additions & 2 deletions webapp/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
DEFAULT_TREBLE_BOOST_GAIN, DEFAULT_TREBLE_BOOST_FC, DEFAULT_TREBLE_BOOST_Q, DEFAULT_TILT, DEFAULT_FS, \
DEFAULT_MAX_GAIN, DEFAULT_SMOOTHING_WINDOW_SIZE, DEFAULT_TREBLE_SMOOTHING_WINDOW_SIZE, DEFAULT_TREBLE_F_LOWER, \
DEFAULT_TREBLE_F_UPPER, DEFAULT_TREBLE_GAIN_K, DEFAULT_PHASE, DEFAULT_PREAMP, DEFAULT_F_RES, \
PEQ_CONFIGS, DEFAULT_BIT_DEPTH, DEFAULT_STEP, DEFAULT_SOUND_SIGNATURE_SMOOTHING_WINDOW_SIZE, DEFAULT_MAX_SLOPE
PEQ_CONFIGS, DEFAULT_BIT_DEPTH, DEFAULT_STEP, DEFAULT_SOUND_SIGNATURE_SMOOTHING_WINDOW_SIZE, DEFAULT_MAX_SLOPE, \
DEFAULT_GRAPHIC_EQ_BANDS
from autoeq.frequency_response import FrequencyResponse

ROOT_DIR = Path().resolve()
Expand Down Expand Up @@ -139,6 +140,7 @@ class EqualizeRequest(BaseModel):
treble_f_lower = DEFAULT_TREBLE_F_LOWER
treble_f_upper = DEFAULT_TREBLE_F_UPPER
treble_gain_k = DEFAULT_TREBLE_GAIN_K
graphic_eq_bands = DEFAULT_GRAPHIC_EQ_BANDS
parametric_eq = False
parametric_eq_config: Optional[Union[str, PEQConfig, list[Union[str, PEQConfig]]]] = '8_PEAKING_WITH_SHELVES'
fixed_band_eq = False
Expand Down Expand Up @@ -309,7 +311,7 @@ def equalize(req: EqualizeRequest):
res['fr']['fixed_band_eq'] = fbpeq_fr.raw.tolist()

if req.graphic_eq:
graphic_eq = fr.eqapo_graphic_eq(normalize=True, preamp=req.preamp)
graphic_eq = fr.eqapo_graphic_eq(normalize=True, preamp=req.preamp, n=req.graphic_eq_bands)
res['graphic_eq'] = graphic_eq

if req.convolution_eq:
Expand Down
2 changes: 2 additions & 0 deletions webapp/ui/src/ApiClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ class ApiClient {
}
} else if (params.equalizer?.type === 'fixedBand') {
body.fixed_band_eq_config = params.equalizer.config;
} else if (params.equalizer?.type === 'graphic') {
body.graphic_eq_bands = params.equalizer.config;
}

const apiRes = await fetch('/equalize', {
Expand Down
10 changes: 9 additions & 1 deletion webapp/ui/src/equalizers.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,16 @@ export default [
</div>
},
{
label: 'EasyEffects / PulseEffects',
label: 'EasyEffects / PulseEffects Convolver',
type: 'convolution',
instructions: 'Download file, add Convolver plugin on plugins tab and click "Import impulse" in "Impulses".'
},
{
label: 'EasyEffects / PulseEffects GraphicEQ',
type: 'graphic',
config: 32,
instructions: 'Download file, add Equalizer plugin on plugins tab and click "GraphicEQ" in "Import Preset".'
},
{
label: 'eqMac (Advanced Equalizer)',
type: 'fixedBand',
Expand All @@ -70,6 +76,7 @@ export default [
{
label: 'EqualizerAPO GraphicEq',
type: 'graphic',
config: 127,
instructions: 'Download the file to "C:\\Program Files\\EqualizerAPO\\config\\", open "Configuration Editor" app, add a filter "Control > Include" and select the file with 📁.'
},
{
Expand Down Expand Up @@ -186,6 +193,7 @@ export default [
{
label: 'Wavelet',
type: 'graphic',
config: 127,
instructions: 'Download the file on your phone and import to Wavelet by selecting AutoEq, clicking the headphone name and then Import button'
},
];