-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimized min_std param for different PEQ configurations. Removed ten…
…sorflow from requirements.txt. Added example PEQ config file and improved usage instructions about it.
- Loading branch information
1 parent
6c7abce
commit 2b7386c
Showing
10 changed files
with
577 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
optimizer: | ||
min_f: 20 | ||
max_f: 20000 # Only optimizing up to 10 kHz because of we only have 6 filters | ||
max_time: null # Letting optimizer finish since this is probably for a one-off custom optimization, not for API | ||
min_change_rate: null # Letting optimizer finish | ||
min_std: null # Letting optimizer finish | ||
filter_defaults: | ||
min_fc: 20 | ||
max_fc: 10000 | ||
min_q: 0.18248 | ||
max_q: 6 | ||
min_gain: -20 | ||
max_gain: 20 | ||
filters: | ||
- type: PEAKING | ||
- type: PEAKING | ||
- type: PEAKING | ||
- type: PEAKING | ||
- type: PEAKING | ||
- type: PEAKING | ||
- type: PEAKING | ||
- type: PEAKING | ||
- type: LOW_SHELF | ||
fc: 105 # Fixed center frequency at 105 Hz | ||
q: 0.7 # Fixed quality of 0.7 | ||
- type: HIGH_SHELF | ||
fc: 10000 | ||
min_fc: 5000 # Letting the optimizer adjust high shelf between 5 kHz and... | ||
max_fc: 12000 # ...12 kHz | ||
min_q: 0.4 # Shelf filters start to overshoot below 0.4 | ||
max_q: 0.7 # Shelf filters start to overshoot after 0.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import sys | ||
from pathlib import Path | ||
from time import time | ||
from copy import deepcopy | ||
import yaml | ||
import numpy as np | ||
import pandas as pd | ||
import matplotlib.pyplot as plt | ||
from matplotlib.animation import FuncAnimation, FFMpegWriter | ||
ROOT_PATH = Path().absolute().parent.parent | ||
if str(ROOT_PATH) not in sys.path: | ||
sys.path.insert(1, str(ROOT_PATH)) | ||
from frequency_response import FrequencyResponse | ||
from constants import DEFAULT_FS, PEQ_CONFIGS | ||
|
||
with open(ROOT_PATH.joinpath('peq.yaml')) as fh: | ||
config = yaml.safe_load(fh) | ||
fr = FrequencyResponse.read_from_csv(ROOT_PATH.joinpath('my_results/F3/Custom Art FIBAE 3 (CIEM).csv')) | ||
config = PEQ_CONFIGS['4_PEAKING_WITH_LOW_SHELF'] | ||
config['optimizer']['min_std'] = 0.0 | ||
peqs = fr.optimize_parametric_eq(config, DEFAULT_FS) | ||
peq = peqs[0] | ||
#peq.plot() | ||
#plt.show() | ||
|
||
|
||
def interpolate(current, previous, ratio): | ||
return previous + ratio * (current - previous) | ||
|
||
|
||
param_history = [] | ||
time_history = [] | ||
times = [] | ||
for i in range(1, len(peq.history.params)): | ||
for j in range(10): | ||
param_history.append(interpolate(np.array(peq.history.params[i]), np.array(peq.history.params[i - 1]), j / 10)) | ||
time_history.append(interpolate(np.array(peq.history.time[i]), np.array(peq.history.time[i - 1]), j / 10)) | ||
|
||
fig, ax = FrequencyResponse.init_plot() | ||
fills = [ax.fill_between([], [], []) for _ in peq.filters] | ||
lines = [ax.plot([], [], linewidth=1, color=f'C{i}')[0] for i in range(len(peq.filters))] | ||
lines.append(ax.plot([], [], color='black', linestyle='--')[0]) | ||
lines.append(ax.plot([], [], color='black')[0]) | ||
ax.set_ylim([-10, 15]) | ||
|
||
|
||
def animate(i): | ||
peq._parse_optimizer_params(param_history[i]) | ||
ax.collections.clear() | ||
for j, filt in enumerate(peq.filters): | ||
ax.fill_between(filt.f, np.zeros(filt.fr.shape), filt.fr, alpha=0.3, color=f'C{j}') | ||
lines[j].set_data(filt.f, filt.fr) | ||
lines[-2].set_data(peq.f, peq.target) | ||
lines[-1].set_data(peq.f, peq.fr) | ||
ax.set_title(f't={time_history[i] * 1000:.0f} ms') | ||
return lines | ||
|
||
|
||
ani = FuncAnimation(fig, animate, frames=len(param_history), interval=3, repeat=False) | ||
ani.save('peq.mp4', writer=FFMpegWriter(fps=60)) | ||
plt.show() |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.