Merge pull request #421 from corrscope/reorder-trigger-cfg

pull/422/head
nyanpasu64 2022-03-19 12:46:57 -07:00 zatwierdzone przez GitHub
commit c683120457
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
4 zmienionych plików z 50 dodań i 34 usunięć

Wyświetl plik

@ -20,6 +20,7 @@
- Fix passing absolute .wav paths into corrscope CLI (#398) - Fix passing absolute .wav paths into corrscope CLI (#398)
- Fix preview error when clearing "Trigger/Render Width" table cells (#407) - Fix preview error when clearing "Trigger/Render Width" table cells (#407)
- Reorganize GUI with edge triggering options before buffer (#416) - Reorganize GUI with edge triggering options before buffer (#416)
- Reorganize YAML field order based on GUI (#421)
## 0.7.1 ## 0.7.1

Wyświetl plik

@ -120,8 +120,8 @@ def template_config(**kwargs) -> Config:
trigger=CorrelationTriggerConfig( trigger=CorrelationTriggerConfig(
mean_responsiveness=0.0, mean_responsiveness=0.0,
edge_strength=1.0, edge_strength=1.0,
reset_below=0.3,
responsiveness=0.5, responsiveness=0.5,
reset_below=0.3,
pitch_tracking=SpectrumConfig(), pitch_tracking=SpectrumConfig(),
# post_trigger=ZeroCrossingTriggerConfig(), # post_trigger=ZeroCrossingTriggerConfig(),
), ),

Wyświetl plik

@ -275,46 +275,58 @@ class CorrelationTriggerConfig(
MainTriggerConfig, MainTriggerConfig,
always_dump=""" always_dump="""
mean_responsiveness mean_responsiveness
pitch_tracking
slope_width slope_width
pitch_tracking
""" """
# deprecated # deprecated
" buffer_falloff ", " buffer_falloff ",
): ):
# get_trigger() ## General parameters ##
# Edge/area finding
sign_strength: float = 0 # Whether to subtract the mean from each frame
mean_responsiveness: float = 1.0 mean_responsiveness: float = 1.0
# Sign enhancement
sign_strength: float = 0
# Maximum distance to move, in terms of trigger_ms/trigger_samp (not in GUI)
trigger_diameter: float = 0.5
# Maximum distance to move, in terms of estimated wave period (not in GUI)
trigger_radius_periods: Optional[float] = 1.5
## Period/frequency estimation (not in GUI) ##
# Minimum pitch change to recalculate _prev_slope_finder (not in GUI)
recalc_semitones: float = 1.0
# (not in GUI)
max_freq: float = with_units("Hz", default=4000)
## Edge triggering ##
# Competes against buffer_strength.
edge_strength: float edge_strength: float
# Slope detection
slope_width: float = with_units("period", default=0.25) slope_width: float = with_units("period", default=0.25)
# Correlation detection ## Correlation ##
# Competes against edge_strength.
buffer_strength: float = 1 buffer_strength: float = 1
# How much to update the buffer *after* each frame.
responsiveness: float
# Standard deviation of buffer window, in terms of estimated wave period. Used by
# _update_buffer() *after* each frame. (not in GUI)
buffer_falloff: float = 0.5
# Below a specific correlation quality, discard the buffer entirely. # Below a specific correlation quality, discard the buffer entirely.
reset_below: float = 0 reset_below: float = 0
# _update_buffer() (not in GUI) # Whether to compute a spectrum to rescale correlation buffer in response to pitch
buffer_falloff: float = 0.5 # changes. (GUI only has a checkbox)
# Maximum distance to move (in terms of trigger_ms/trigger_samp) (not in GUI)
trigger_diameter: float = 0.5
# Maximum distance to move (in terms of estimated wave period) (not in GUI)
trigger_radius_periods: Optional[float] = 1.5
# (not in GUI)
recalc_semitones: float = 1.0
# _update_buffer
responsiveness: float
# Period/frequency estimation (not in GUI)
max_freq: float = with_units("Hz", default=4000)
# Pitch tracking = compute spectrum. (GUI only has a checkbox)
pitch_tracking: Optional[SpectrumConfig] = None pitch_tracking: Optional[SpectrumConfig] = None
# region Legacy Aliases # region Legacy Aliases

Wyświetl plik

@ -27,24 +27,27 @@ triggers.SHOW_TRIGGER = False
def trigger_template(**kwargs) -> CorrelationTriggerConfig: def trigger_template(**kwargs) -> CorrelationTriggerConfig:
cfg = CorrelationTriggerConfig( cfg = CorrelationTriggerConfig(edge_strength=2, responsiveness=1)
edge_strength=2, responsiveness=1, buffer_falloff=0.5
)
return attr.evolve(cfg, **kwargs) return attr.evolve(cfg, **kwargs)
# Ideally I'd test mean_responsiveness as well, but that makes the test suite too slow.
# Perhaps I could change 1-3 parameters at a time, rather than the cross product of all
# parameters (https://smarie.github.io/python-pytest-cases/pytest_goodies/#fixture_union)?
@fixture @fixture
@parametrize("trigger_diameter", [0.5, 1.0])
@parametrize("pitch_tracking", [None, SpectrumConfig()])
@parametrize("sign_strength", [0, 1]) @parametrize("sign_strength", [0, 1])
@parametrize("buffer_strength", [0, 1])
@parametrize("reset_below", [0, 1])
@parametrize("pitch_tracking", [None, SpectrumConfig()])
def trigger_cfg( def trigger_cfg(
trigger_diameter, pitch_tracking, sign_strength sign_strength, buffer_strength, reset_below, pitch_tracking
) -> CorrelationTriggerConfig: ) -> CorrelationTriggerConfig:
return trigger_template( return trigger_template(
trigger_diameter=trigger_diameter,
pitch_tracking=pitch_tracking,
sign_strength=sign_strength, sign_strength=sign_strength,
slope_width=0.14, slope_width=0.14,
buffer_strength=buffer_strength,
reset_below=reset_below,
pitch_tracking=pitch_tracking,
) )