mixing 0.0.74__tar.gz → 0.0.76__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. {mixing-0.0.74 → mixing-0.0.76}/.claude/skills/mixing-audio/SKILL.md +1 -1
  2. {mixing-0.0.74 → mixing-0.0.76}/PKG-INFO +1 -1
  3. {mixing-0.0.74 → mixing-0.0.76}/mixing/audio/leveling.py +0 -4
  4. {mixing-0.0.74 → mixing-0.0.76}/mixing/audio/voice.py +32 -1
  5. {mixing-0.0.74 → mixing-0.0.76}/mixing/loudness.py +12 -50
  6. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_loudness.py +0 -33
  7. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_voice.py +20 -6
  8. {mixing-0.0.74 → mixing-0.0.76}/pyproject.toml +1 -1
  9. {mixing-0.0.74 → mixing-0.0.76}/.claude/CLAUDE.md +0 -0
  10. {mixing-0.0.74 → mixing-0.0.76}/.claude/agents/mixing-dev.md +0 -0
  11. {mixing-0.0.74 → mixing-0.0.76}/.claude/agents/mixing-editor.md +0 -0
  12. {mixing-0.0.74 → mixing-0.0.76}/.claude/skills/mixing/SKILL.md +0 -0
  13. {mixing-0.0.74 → mixing-0.0.76}/.claude/skills/mixing-dubbing/SKILL.md +0 -0
  14. {mixing-0.0.74 → mixing-0.0.76}/.claude/skills/mixing-transcript/SKILL.md +0 -0
  15. {mixing-0.0.74 → mixing-0.0.76}/.claude/skills/mixing-video/SKILL.md +0 -0
  16. {mixing-0.0.74 → mixing-0.0.76}/.github/workflows/ci.yml +0 -0
  17. {mixing-0.0.74 → mixing-0.0.76}/.gitignore +0 -0
  18. {mixing-0.0.74 → mixing-0.0.76}/LICENSE +0 -0
  19. {mixing-0.0.74 → mixing-0.0.76}/README.md +0 -0
  20. {mixing-0.0.74 → mixing-0.0.76}/conftest.py +0 -0
  21. {mixing-0.0.74 → mixing-0.0.76}/misc/README_audio_widget.md +0 -0
  22. {mixing-0.0.74 → mixing-0.0.76}/misc/audio_widget_EXAMPLE_NOTEBOOK.md +0 -0
  23. {mixing-0.0.74 → mixing-0.0.76}/misc/discussion_media/video_editing/pair_bgremove_efficient.gif +0 -0
  24. {mixing-0.0.74 → mixing-0.0.76}/misc/discussion_media/video_editing/pair_bgremove_kodokan.gif +0 -0
  25. {mixing-0.0.74 → mixing-0.0.76}/misc/discussion_media/video_editing/pair_cartoon_C.gif +0 -0
  26. {mixing-0.0.74 → mixing-0.0.76}/misc/discussion_media/video_editing/pair_facexform_animegan.gif +0 -0
  27. {mixing-0.0.74 → mixing-0.0.76}/misc/discussion_media/video_editing/pair_facexform_sticker.gif +0 -0
  28. {mixing-0.0.74 → mixing-0.0.76}/misc/discussion_media/video_editing/pair_redact_blur.gif +0 -0
  29. {mixing-0.0.74 → mixing-0.0.76}/misc/discussion_media/video_editing/pair_stylize_B1.gif +0 -0
  30. {mixing-0.0.74 → mixing-0.0.76}/misc/examples/audio_offset_example.py +0 -0
  31. {mixing-0.0.74 → mixing-0.0.76}/misc/examples/demo_audio_widget.py +0 -0
  32. {mixing-0.0.74 → mixing-0.0.76}/mixing/__init__.py +0 -0
  33. {mixing-0.0.74 → mixing-0.0.76}/mixing/_cache.py +0 -0
  34. {mixing-0.0.74 → mixing-0.0.76}/mixing/_elevenlabs.py +0 -0
  35. {mixing-0.0.74 → mixing-0.0.76}/mixing/audio/__init__.py +0 -0
  36. {mixing-0.0.74 → mixing-0.0.76}/mixing/audio/_pcm.py +0 -0
  37. {mixing-0.0.74 → mixing-0.0.76}/mixing/audio/audio_ops.py +0 -0
  38. {mixing-0.0.74 → mixing-0.0.76}/mixing/audio/audio_util.py +0 -0
  39. {mixing-0.0.74 → mixing-0.0.76}/mixing/audio/audio_widget.py +0 -0
  40. {mixing-0.0.74 → mixing-0.0.76}/mixing/audio/beats.py +0 -0
  41. {mixing-0.0.74 → mixing-0.0.76}/mixing/audio/samples.py +0 -0
  42. {mixing-0.0.74 → mixing-0.0.76}/mixing/audio/segmentation.py +0 -0
  43. {mixing-0.0.74 → mixing-0.0.76}/mixing/audio/tagging.py +0 -0
  44. {mixing-0.0.74 → mixing-0.0.76}/mixing/audio/talk_edges.py +0 -0
  45. {mixing-0.0.74 → mixing-0.0.76}/mixing/audio/turns.py +0 -0
  46. {mixing-0.0.74 → mixing-0.0.76}/mixing/chapters.py +0 -0
  47. {mixing-0.0.74 → mixing-0.0.76}/mixing/dubbing/__init__.py +0 -0
  48. {mixing-0.0.74 → mixing-0.0.76}/mixing/dubbing/dub.py +0 -0
  49. {mixing-0.0.74 → mixing-0.0.76}/mixing/dubbing/srt.py +0 -0
  50. {mixing-0.0.74 → mixing-0.0.76}/mixing/dubbing/tts.py +0 -0
  51. {mixing-0.0.74 → mixing-0.0.76}/mixing/egress.py +0 -0
  52. {mixing-0.0.74 → mixing-0.0.76}/mixing/errors.py +0 -0
  53. {mixing-0.0.74 → mixing-0.0.76}/mixing/filtergraph.py +0 -0
  54. {mixing-0.0.74 → mixing-0.0.76}/mixing/srt.py +0 -0
  55. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/data/talk_edges_labels.json +0 -0
  56. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_adaptive_window.py +0 -0
  57. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_aligned_spans.py +0 -0
  58. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_alignment_features.py +0 -0
  59. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_alignment_ingest.py +0 -0
  60. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_alignment_margin.py +0 -0
  61. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_ambient_bed.py +0 -0
  62. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_audio_alignment.py +0 -0
  63. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_audio_ops.py +0 -0
  64. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_audio_widget.py +0 -0
  65. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_beats.py +0 -0
  66. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_chapters.py +0 -0
  67. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_collision_detection.py +0 -0
  68. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_cutaways.py +0 -0
  69. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_dubbing.py +0 -0
  70. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_egress.py +0 -0
  71. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_filtergraph.py +0 -0
  72. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_gif_and_crop_box.py +0 -0
  73. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_guard_audio_class.py +0 -0
  74. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_guard_audio_ops_more.py +0 -0
  75. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_guard_base_install.py +0 -0
  76. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_guard_chapters_more.py +0 -0
  77. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_guard_no_print.py +0 -0
  78. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_guard_srt_and_persist.py +0 -0
  79. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_guard_thumbnail.py +0 -0
  80. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_guard_video_class.py +0 -0
  81. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_guard_video_ops_more.py +0 -0
  82. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_guard_video_util.py +0 -0
  83. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_ken_burns.py +0 -0
  84. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_leveling.py +0 -0
  85. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_overlay_mix.py +0 -0
  86. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_scribe_cache.py +0 -0
  87. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_segmentation.py +0 -0
  88. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_segmentation_audioset.py +0 -0
  89. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_shots.py +0 -0
  90. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_srt_vtt.py +0 -0
  91. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_support_statistic.py +0 -0
  92. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_talk_edges.py +0 -0
  93. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_transcript.py +0 -0
  94. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_tts_api_key.py +0 -0
  95. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_tts_cache_status.py +0 -0
  96. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_util.py +0 -0
  97. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_video_audio_integration.py +0 -0
  98. {mixing-0.0.74 → mixing-0.0.76}/mixing/tests/test_video_transitions.py +0 -0
  99. {mixing-0.0.74 → mixing-0.0.76}/mixing/transcript/__init__.py +0 -0
  100. {mixing-0.0.74 → mixing-0.0.76}/mixing/transcript/fillers.py +0 -0
  101. {mixing-0.0.74 → mixing-0.0.76}/mixing/transcript/formats.py +0 -0
  102. {mixing-0.0.74 → mixing-0.0.76}/mixing/transcript/media.py +0 -0
  103. {mixing-0.0.74 → mixing-0.0.76}/mixing/transcript/persist.py +0 -0
  104. {mixing-0.0.74 → mixing-0.0.76}/mixing/transcript/pipeline.py +0 -0
  105. {mixing-0.0.74 → mixing-0.0.76}/mixing/transcript/scribe.py +0 -0
  106. {mixing-0.0.74 → mixing-0.0.76}/mixing/util.py +0 -0
  107. {mixing-0.0.74 → mixing-0.0.76}/mixing/video/README.md +0 -0
  108. {mixing-0.0.74 → mixing-0.0.76}/mixing/video/__init__.py +0 -0
  109. {mixing-0.0.74 → mixing-0.0.76}/mixing/video/_helpers.py +0 -0
  110. {mixing-0.0.74 → mixing-0.0.76}/mixing/video/cutaways.py +0 -0
  111. {mixing-0.0.74 → mixing-0.0.76}/mixing/video/genai.py +0 -0
  112. {mixing-0.0.74 → mixing-0.0.76}/mixing/video/gif.py +0 -0
  113. {mixing-0.0.74 → mixing-0.0.76}/mixing/video/shot_boundaries.py +0 -0
  114. {mixing-0.0.74 → mixing-0.0.76}/mixing/video/thumbnail.py +0 -0
  115. {mixing-0.0.74 → mixing-0.0.76}/mixing/video/video_concat.py +0 -0
  116. {mixing-0.0.74 → mixing-0.0.76}/mixing/video/video_ops.py +0 -0
  117. {mixing-0.0.74 → mixing-0.0.76}/mixing/video/video_subtitles.py +0 -0
  118. {mixing-0.0.74 → mixing-0.0.76}/mixing/video/video_util.py +0 -0
@@ -519,7 +519,7 @@ shift_pitch(
519
519
  ) # +2 semitones, same duration and loudness
520
520
  ```
521
521
 
522
- - `voice_profile`: `f0_hz` is the median f0 over voiced frames of `f0_tracker` (default `pyin_tracker()`, needs `mixing[beats]`; `f0=False` skips it). Configure pyin through the tracker, `f0_tracker=pyin_tracker(fmin=50, fmax=400, min_voiced_prob=0.2)` (`voice_profile` itself no longer takes them). Default range 65-600 Hz; a voice above `fmax` reads as a subharmonic. Spans shorter than the tracker's `min_samples` (pyin: one 128 ms frame) give `f0_hz=None, voiced_fraction=None`. Any `(mono samples, rate) -> (f0 per frame, voiced flags)` callable is a tracker; it applies its own voicing threshold, e.g. over `denote`:
522
+ - `voice_profile`: `f0_hz` is the median f0 over voiced frames of `f0_tracker` (default `pyin_tracker()`, needs `mixing[beats]`; `f0=False` skips it). Configure pyin through the tracker, `f0_tracker=pyin_tracker(fmin=50, fmax=400, min_voiced_prob=0.2)` (the same arguments on `voice_profile` are deprecated). Default range 65-600 Hz; a voice above `fmax` reads as a subharmonic. Spans shorter than the tracker's `min_samples` (pyin: one 128 ms frame) give `f0_hz=None, voiced_fraction=None`. Any `(mono samples, rate) -> (f0 per frame, voiced flags)` callable is a tracker; it applies its own voicing threshold, e.g. over `denote`:
523
523
 
524
524
  ```python
525
525
  def denote_tracker(*, threshold=0.5, **kwargs):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: mixing
3
- Version: 0.0.74
3
+ Version: 0.0.76
4
4
  Summary: Tools for video and audio editing
5
5
  Project-URL: Homepage, https://github.com/thorwhalen/mixing
6
6
  Author: Thor Whalen
@@ -8,10 +8,6 @@ every speaker turn of a recording to the same loudness, which whole-track peak
8
8
  normalisation (:meth:`Audio.normalize`) cannot do. ``loudness_range`` (EBU
9
9
  Tech 3342 LRA) and ``true_peak_db`` (4x oversampled) sit beside it.
10
10
 
11
- This module is the :class:`Audio` layer. The array-level pieces (the BS.1770
12
- constants, ``numpy_lufs``, ``level_group``, ``limit_peaks``) live in
13
- :mod:`mixing.loudness` and are not re-exported here: import them from there.
14
-
15
11
  ``level_turns`` is :func:`mixing.audio.turns.process_turns` with a chain of
16
12
  stages per turn, all run on the turn padded by ``pad_s`` (so filters settle):
17
13
  the speaker's EQ -> pre-gain to a common level -> compressor -> gain to
@@ -268,6 +268,20 @@ def _voiced_f0(
268
268
  return (float(np.median(values)) if len(values) else None), len(values) / n_frames
269
269
 
270
270
 
271
+ def _deprecated_pyin_args(**kwargs) -> dict:
272
+ """The pyin arguments ``voice_profile`` was given (``None`` = not given),
273
+ with a ``DeprecationWarning`` when there are any."""
274
+ given = {k: v for k, v in kwargs.items() if v is not None}
275
+ if given:
276
+ warnings.warn(
277
+ f"voice_profile({', '.join(given)}=...) is deprecated and will be "
278
+ "removed (reeleehq/mixing#99); pass f0_tracker=pyin_tracker(...) instead",
279
+ DeprecationWarning,
280
+ stacklevel=3,
281
+ )
282
+ return given
283
+
284
+
271
285
  def voice_profile(
272
286
  audio: Union[str, Path, Audio],
273
287
  spans: Optional[Spans] = None,
@@ -277,6 +291,10 @@ def voice_profile(
277
291
  f0_sample_rate: int = DEFAULT_F0_SAMPLE_RATE,
278
292
  low_band: Span = DEFAULT_LOW_BAND_HZ,
279
293
  welch_nperseg: int = DEFAULT_WELCH_NPERSEG,
294
+ fmin: Optional[float] = None,
295
+ fmax: Optional[float] = None,
296
+ f0_frame_length: Optional[int] = None,
297
+ min_voiced_prob: Optional[float] = None,
280
298
  ) -> dict:
281
299
  """Pitch, loudness and timbre of each labelled part of ``audio``.
282
300
 
@@ -300,6 +318,8 @@ def voice_profile(
300
318
  f0_sample_rate: the rate spans are resampled to before tracking.
301
319
  low_band: ``(lo_hz, hi_hz)`` of the band reported by ``low_band_db``.
302
320
  welch_nperseg: Welch segment length for centroid and low-band ratio.
321
+ fmin, fmax, f0_frame_length, min_voiced_prob: deprecated; pass them to
322
+ :func:`pyin_tracker` as ``f0_tracker``.
303
323
 
304
324
  Returns:
305
325
  ``{label: {...}}`` of plain JSON-able dicts with keys
@@ -323,8 +343,19 @@ def voice_profile(
323
343
  fs = segment.frame_rate
324
344
  data = segment_samples(segment)
325
345
  grouped = _spans_by_label(spans, len(data) / fs)
346
+ pyin_args = _deprecated_pyin_args(
347
+ fmin=fmin,
348
+ fmax=fmax,
349
+ frame_length=f0_frame_length,
350
+ min_voiced_prob=min_voiced_prob,
351
+ )
326
352
  if f0_tracker is None:
327
- f0_tracker = pyin_tracker()
353
+ f0_tracker = pyin_tracker(**pyin_args)
354
+ elif f0 and pyin_args:
355
+ raise ValueError(
356
+ "fmin, fmax, f0_frame_length and min_voiced_prob configure the default "
357
+ "pyin tracker only; pass them to pyin_tracker() as f0_tracker"
358
+ )
328
359
 
329
360
  def profile(ranges) -> dict:
330
361
  frames = [
@@ -88,10 +88,6 @@ MIN_MEASURE_S = 1.0
88
88
  #: and back out over this much on each side, so nothing below ~20 Hz is
89
89
  #: modulated within a cycle.
90
90
  DEFAULT_LIMITER_WINDOW_S = 0.05
91
- #: Frames the limiter works on at a time (~5.5 s at 48 kHz). Memory is the
92
- #: output plus a fixed per-chunk overhead (tens of MB; more for a true peak,
93
- #: whose envelope oversamples the chunk), however long the signal.
94
- LIMITER_CHUNK_FRAMES = 1 << 18
95
91
  _EBUR128_I = re.compile(r"I:\s*(-?\d+(?:\.\d+)?|-inf)\s*LUFS")
96
92
  _FFMPEG_FLOAT = "f32le"
97
93
 
@@ -426,10 +422,7 @@ def limit_peaks(
426
422
  a peak. Every sample's gain is at most what that sample needs, so the
427
423
  ceiling holds exactly; nothing moves in time. ``window`` is in samples;
428
424
  by default ``DEFAULT_LIMITER_WINDOW_S`` * ``fs`` when ``fs`` is given, else 1.
429
- Returned unchanged (the same object, for 2-D input) when nothing exceeds
430
- the ceiling.
431
- Works in ``LIMITER_CHUNK_FRAMES`` chunks sharing the context each gain
432
- depends on, so the result is the whole-signal one at a bounded memory.
425
+ Returned unchanged (the same object) when nothing exceeds the ceiling.
433
426
 
434
427
  With ``true_peak=True`` (needs ``fs``) the need comes from the oversampled
435
428
  peak (see :func:`true_peak_envelope`) of each sample and the gap before it,
@@ -453,57 +446,26 @@ def limit_peaks(
453
446
  """
454
447
  if not 0 < ceiling <= 1:
455
448
  raise ValueError(f"ceiling is linear, in (0, 1]; got {ceiling} (not dB)")
456
- if oversampling is not None and not true_peak:
457
- raise ValueError("oversampling applies to true_peak=True only")
458
- if true_peak and fs is None:
459
- raise ValueError("true_peak=True needs fs")
460
449
  data = _as_2d(data)
450
+ if not len(data):
451
+ return data
461
452
  if window is None:
462
453
  window = round(DEFAULT_LIMITER_WINDOW_S * fs) if fs else 1
463
- w = max(1, int(window))
464
- # a gain sees the need up to ~1.5w samples away on each side (sliding
465
- # minimum, then moving average); a true peak, the interpolation filter's
466
- # length of samples and the one before
467
- margin = 2 * w + 1 + (TRUE_PEAK_FILTER_HALF_SAMPLES + 1 if true_peak else 0)
468
- n, out = len(data), None
469
- for start in range(0, n, LIMITER_CHUNK_FRAMES):
470
- stop = min(n, start + LIMITER_CHUNK_FRAMES)
471
- lo, hi = max(0, start - margin), min(n, stop + margin)
472
- need = _peak_need(
473
- data[lo:hi],
474
- ceiling=ceiling,
475
- true_peak=true_peak,
476
- fs=fs,
477
- oversampling=oversampling,
478
- )
479
- gain = _smoothed_gain(need, w)[start - lo : stop - lo]
480
- if out is None:
481
- if gain.min() >= 1.0:
482
- continue # untouched so far
483
- out = data.astype(np.result_type(data.dtype, np.float64))
484
- out[start:stop] = data[start:stop] * gain[:, None]
485
- return data if out is None else out
486
-
487
-
488
- def _peak_need(
489
- data: np.ndarray, *, ceiling: float, true_peak: bool, fs, oversampling
490
- ) -> np.ndarray:
491
- """The gain each sample needs, ``ceiling / peak`` at most 1 ``(n,)``: by its
492
- sample peak, or by the true peak of it and the gap before it."""
454
+ if oversampling is not None and not true_peak:
455
+ raise ValueError("oversampling applies to true_peak=True only")
493
456
  if true_peak:
457
+ if fs is None:
458
+ raise ValueError("true_peak=True needs fs")
494
459
  peak = true_peak_envelope(data, fs, oversampling=oversampling)
495
460
  peak = np.maximum(peak, np.concatenate([[0.0], peak[:-1]])) # the gap before
496
461
  else:
497
462
  peak = np.abs(data).max(axis=1)
498
- return np.minimum(1.0, ceiling / np.maximum(peak, 1e-12))
499
-
500
-
501
- def _smoothed_gain(need: np.ndarray, w: int) -> np.ndarray:
502
- """``need`` eased in and out over ``w`` samples (sliding minimum over
503
- ``2w + 1``, then a moving average over ``w``), never above ``need``."""
463
+ need = np.minimum(1.0, ceiling / np.maximum(peak, 1e-12))
504
464
  if need.min() >= 1.0:
505
- return need
465
+ return data
466
+ w = max(1, int(window))
506
467
  lows = _sliding_min(np.pad(need, (w, w), constant_values=1.0), 2 * w + 1)
507
468
  padded = np.pad(lows, (w // 2, w - 1 - w // 2), mode="edge")
508
469
  gain = np.convolve(padded, np.ones(w) / w, mode="valid")
509
- return np.minimum(gain, need) # float rounding never lets a peak through
470
+ gain = np.minimum(gain, need) # float rounding never lets a peak through
471
+ return data * gain[:, None]
@@ -298,36 +298,3 @@ def test_oversampling_is_validated():
298
298
  true_peak_envelope(x, FS, oversampling=bad)
299
299
  with pytest.raises(ValueError, match="true_peak=True only"):
300
300
  limit_peaks(x, ceiling=0.5, oversampling=8)
301
-
302
-
303
- @pytest.mark.parametrize("window, chunk", [(4, FS // 3), (3000, 1000), (None, FS // 3)])
304
- def test_chunked_limiter_matches_the_whole_signal(monkeypatch, window, chunk):
305
- # small windows make the true-peak part of the chunk margin the one that
306
- # matters; a chunk shorter than the window makes the window part matter
307
- import mixing.loudness as loudness
308
-
309
- rng = np.random.default_rng(9)
310
- data = rng.standard_normal((FS * 2, 2)) * 0.4
311
- data[FS // 3 + 7] = 2.5 # a peak near a chunk join
312
- for true_peak in (False, True):
313
- kwargs = dict(ceiling=0.8, window=window, true_peak=true_peak, fs=FS)
314
- whole = limit_peaks(data, **kwargs)
315
- monkeypatch.setattr(loudness, "LIMITER_CHUNK_FRAMES", chunk)
316
- chunked = limit_peaks(data, **kwargs)
317
- monkeypatch.setattr(loudness, "LIMITER_CHUNK_FRAMES", 1 << 30)
318
- np.testing.assert_allclose(chunked, whole, rtol=0, atol=1e-12)
319
-
320
-
321
- def test_limiter_memory_stays_near_the_output(monkeypatch):
322
- import tracemalloc
323
-
324
- import mixing.loudness as loudness
325
-
326
- monkeypatch.setattr(loudness, "LIMITER_CHUNK_FRAMES", FS)
327
- data = np.random.default_rng(2).standard_normal((FS * 20, 2)) * 0.5
328
- tracemalloc.start()
329
- limit_peaks(data, ceiling=0.5, fs=FS)
330
- _, peak = tracemalloc.get_traced_memory()
331
- tracemalloc.stop()
332
- # the output (one input's worth) plus one chunk's temporaries; whole it was ~5x
333
- assert peak < 2 * data.nbytes
@@ -481,10 +481,24 @@ def test_tracker_min_samples_sets_the_shortest_span_tracked():
481
481
  assert out["a"]["f0_hz"] is None
482
482
 
483
483
 
484
- def test_pyin_arguments_belong_to_pyin_tracker():
485
- # removed from voice_profile (#99): configure pyin through its tracker
484
+ def test_pyin_arguments_on_voice_profile_are_deprecated(monkeypatch):
485
+ built = []
486
+ real = voice_module.pyin_tracker
487
+ monkeypatch.setattr(
488
+ voice_module, "pyin_tracker", lambda **kw: built.append(kw) or real(**kw)
489
+ )
486
490
  audio = Audio(AudioSegment.silent(1000, frame_rate=16000))
487
- with pytest.raises(TypeError, match="fmin"):
488
- voice_profile(audio, fmin=80.0)
489
- out = voice_profile(audio, f0_tracker=voice_module.pyin_tracker(fmin=80.0))
490
- assert out["all"]["f0_hz"] is None # silence: no voiced frame
491
+ with pytest.warns(DeprecationWarning, match="pyin_tracker"):
492
+ voice_profile(audio, fmin=80.0, min_voiced_prob=0.3)
493
+ assert built[-1] == {"fmin": 80.0, "min_voiced_prob": 0.3}
494
+ with warnings.catch_warnings():
495
+ warnings.simplefilter("error")
496
+ voice_profile(audio)
497
+ with (
498
+ pytest.warns(DeprecationWarning),
499
+ pytest.raises(ValueError, match="pyin_tracker"),
500
+ ):
501
+ voice_profile(audio, fmax=300.0, f0_tracker=lambda y, fs: ([1.0], [True]))
502
+ with pytest.warns(DeprecationWarning, match="mixing#99") as caught: # f0 off
503
+ voice_profile(audio, f0=False, fmax=300.0, f0_tracker=lambda y, fs: ([], []))
504
+ assert caught[0].filename == __file__ # attributed to the caller
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
6
6
 
7
7
  [project]
8
8
  name = "mixing"
9
- version = "0.0.74"
9
+ version = "0.0.76"
10
10
  description = "Tools for video and audio editing"
11
11
  readme = "README.md"
12
12
  requires-python = ">=3.10"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes