Files
Lyrebird/Sources/Lyrebird/Generators/Analysis/LoudnessModel.swift
T
2026-06-21 11:45:58 -07:00

39 lines
1.5 KiB
Swift

// LoudnessModel.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import Foundation
/// Selects the loudness-estimation model for ``Loudness`` (the implementation
/// flag, mirroring the `Balance` `logDomain:` and `BeatTrack` `BeatTrackODF`
/// folds). The cases carry different parameters, so the selector is an enum.
///
/// All models output total loudness in **sones** from the same third-octave band
/// powers; they differ in how specific loudness is derived.
public enum LoudnessModel {
/// Cheapest: third-octave band intensity → Stevens power law
/// (`N ∝ I^0.3`) → sum. No equal-loudness contour or masking. Rough but
/// stable; no SC parity claim.
case barkEstimate
/// SC `Loudness` ergonomics: critical-band specific loudness via the Zwicker
/// law with a spectral-masking constant, summed, then temporally masked.
///
/// - Parameters:
/// - smask: Spectral-masking constant `s` (`[0, 1]`); `0.25` is the
/// standard value. Higher widens masking.
/// - tmask: Temporal-mask release time (seconds); larger = slower decay,
/// more masking of transients.
case realtimeZwicker(smask: Double, tmask: Double)
/// Full ISO 532 B / DIN 45631 stationary Zwicker loudness: third-octave core
/// loudness → upper-slope spreading → integrate the specific-loudness
/// function.
///
/// - Parameter field: Sound-field assumption (`.free` default, `.diffuse`).
case iso532b(field: LoudnessField)
}