sample.sms.mm module

Sinusoidal model with added functionality for modal sounds

class sample.sms.mm.ModalModel(w: Optional[ndarray] = None, n: int = 2048, t: float = -90, tracker: SineTracker = None, intermediate: OptionalStorage = None, padded: bool = False, **kwargs)

Bases: SinusoidalModel

Sinusoidal model with a ModalTracker as sine tracker

Parameters:
w_

Effective analysis window

Type:

array

set_params(**kwargs)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters:

**params (dict) – Estimator parameters.

Returns:

self – Estimator instance.

Return type:

estimator instance

property tracker

Default fget function

class sample.sms.mm.ModalTracker(max_n_sines: int = 100, min_sine_dur: float = 0.04, freq_dev_offset: float = 20, freq_dev_slope: float = 0.01, reverse: bool = False, frequency_bounds: Tuple[Optional[float], Optional[float]] = (20, 16000), peak_threshold: float = -90, merge_strategy: str = 'average', strip_t: Optional[float] = None, fs: int = 44100, h: int = 500, **kwargs)

Bases: SineTracker

Sinusoidal tracker with added functionality for modal sounds:

  • check decreasing magnitude

  • check frequency constraints

  • check peak threshold

  • group non-contiguous tracks

Parameters:
  • fs (int) – Sampling frequency

  • h (int) – Hop size (in samples)

  • max_n_sines (int) – Maximum number of tracks per frame

  • min_sine_dur (float) – Minimum duration of a track in seconds

  • freq_dev_offset (float) – Frequency deviation threshold at 0Hz

  • freq_dev_slope (float) – Slope of frequency deviation threshold

  • frequency_bounds (float, float) – Minimum and maximum accepted mean frequency

  • peak_threshold (float) – Minimum peak magnitude in dB for modal tracks

  • reverse (bool) – Whether the input audio will be reversed

  • merge_strategy (str) – Track merging strategy. Supported strategies are: "single" (based on the frequency difference of the tail of older track and head of new track), "average" (based on frequency difference of average frequencies)

  • strip_t (int) – Strip time (in seconds). Tracks starting later than this time will be omitted from the track list. If None, don’t strip

  • **kwargs – Additional parameters for sub-models

property all_tracks_: Iterable[Dict[str, ndarray]]

All deactivated tracks in tracks_ and those active tracks that would pass the cleanliness check at the current state of the tracker

deactivate(track_index: int) dict

Remove track from list of active tracks and save it in tracks_ if it meets cleanliness criteria

Parameters:

track_index (int) – Index of track to deactivate

Returns:

Deactivated track

Return type:

dict

property freq_diff_function: Callable

Frequency difference function for current merge strategy

property strip_n

Strip time (in frames)

track_ok(track: dict) bool

Check if a deactivated track is ok to be saved

Parameters:

track (dict) – Track to check

Returns:

Whether the track is ok or not

Return type:

bool