Skip to content

Feat/audio trimming waveform selector#22

Merged
NewComer00 merged 4 commits into
mainfrom
feat/audio-trimming-waveform-selector
Mar 13, 2026
Merged

Feat/audio trimming waveform selector#22
NewComer00 merged 4 commits into
mainfrom
feat/audio-trimming-waveform-selector

Conversation

@NewComer00

Copy link
Copy Markdown
Owner

No description provided.

Introduce ClampedWav to trim ref/UTAU audio to user-specified ranges;
expose offset_sec/duration_sec on ExpressionLoader. Shift extracted
ticks by UTAU trim offset to fix silent MIDI misalignment. Add
WaveSurferRangeSelector UI component with two-way timestamp bindings.
Wire ref_start/ref_end/utau_start/utau_end through GUI, CLI, and
process_expressions(). Fix time_to_ticks to output rounded integer
ticks. Vendor WaveSurfer.js 7.8.10 via hatch build hook.
WaveSurfer's enableDragSelection misinterprets a mousedown at scrollLeft=0
as a drag gesture, creating a zero-width region at t=0. This then propagates
through the Python binding where `end=0` collapses to None, causing a
full-width region to be drawn. Fix by clamping scrollLeft to a minimum of 2
whenever the scroll container reaches the leftmost position.
- Remove scroll-clamp workaround for spurious drag regions
- Sync zoom slider value on ws 'zoom' event
- Emit 'ready' event with duration and trigger range change on load
- Clear regions and reset zoom before loading new wav
- Guard apply() with duration > 0.001 to avoid premature execution
Add a `trim_silence` bool arg (default: True) to DynLoader and TencLoader.
When enabled, extract_wav_rms masks silent edge frames with NaN, and any
tick positions where the UTAU signal is silent are subsequently masked in
the aligned reference RMS before expression computation. zscore calls are
updated to use nan_policy='omit' to handle the new NaN values correctly.

feat(wavtool): move extract_wav_mfcc, extract_wav_frequency, extract_wav_rms to utils/wavtool

Consolidate the three audio feature extraction helpers that were duplicated
across expressions/pitd.py, expressions/dyn.py and expressions/tenc.py into
utils/wavtool.py. extract_wav_rms gains a mask_silence parameter backed by
Otsu thresholding (skimage). Add scikit-image to pyproject.toml dependencies.
Downstream expression modules now import from utils.wavtool.

feat(cli): extract add_expression_args_group and str2bool into utils/cli

Move the argument-group building logic from expressive.py into a reusable
add_expression_args_group() helper. Bool-typed args are wired through a new
str2bool() converter with [True, False] as choices, replacing plain type=bool
which argparse cannot deserialise from command-line strings.

feat(gui): add Trim Silence toggle to dyn and tenc expression cards

fix(log): mark __main__ block as pragma: no cover

style(ui): increase waveform scrollbar height from 6px to 10px

test(wavtool): add tests for extract_wav_mfcc, extract_wav_rms, extract_wav_frequency, get_wav_end_ts, ClampedWav

test(cli): add tests for str2bool and add_expression_args_group; expand formatter coverage

test: add test_worker.py covering WorkerContext dataclass and setup_worker_context

i18n: update pot/po files for trim_silence strings and wavtool cache messages
@codecov

codecov Bot commented Mar 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 59.31759% with 155 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
utils/ui.py 21.14% 138 Missing ⚠️
expressions/tenc.py 33.33% 6 Missing ⚠️
expressive.py 25.00% 6 Missing ⚠️
expressions/pitd.py 25.00% 3 Missing ⚠️
utils/wavtool.py 98.62% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@NewComer00 NewComer00 merged commit b58722a into main Mar 13, 2026
3 of 4 checks passed
@NewComer00 NewComer00 deleted the feat/audio-trimming-waveform-selector branch March 13, 2026 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant