Python マスタリングの型
マスタリング、マスタリングアシスタント、ミキシングアシスタントの各呼び出しが返すレコードです。チェーン、プリセット、プロセッサの呼び出しは Python マスタリング API、単体のダイナミクスとリペアは Python ダイナミクスとリペア API、アシスタント、プロファイル、配信プレビューの呼び出しは Python マスタリング API、mixing_assistant_suggest は Python Mixer クラス API にあります。
StreamingPlatform(TypedDict)と MixAssistantTrack(NamedTuple)を除いて、すべて frozen dataclass です。samples、left、right は float32 配列です。
オフラインマスタリングの結果
mastering() とプリセットの呼び出しは、モノラルなら MasteringResult、ステレオなら MasteringStereoResult を返します。設定可能なチェーンは MasteringChainResult または MasteringChainStereoResult を返します。こちらにはステージ一覧、測定した出力のTrue Peakとラウドネスレンジ、ステージごとのゲインリダクション、任意の report が加わります。
applied_gain_dbはスタティックゲインだけの合計です。リミッターのゲインリダクションはstage_gain_reductionsに別に載ります。output_true_peak_dbtpは、チェーンが適用したピーク制限ステージのオーバーサンプル倍率(既定は 4 倍)で測ります。output_loudness_range_luは EBU R128 のラウドネスレンジ(LU)です。stage_gain_reductionsの各エントリは 0 か負の値(dB)です。
# Mastering loudness/true-peak processing result.
@dataclass(frozen=True, slots=True, eq=False)
class MasteringResult:
samples: npt.NDArray[np.float32]
sample_rate: int
input_lufs: float
output_lufs: float
applied_gain_db: float
latency_samples: int = 0
loudness_target_limited: bool = False
non_finite_substitution_count: int = 0
declip_unreconstructed_runs: int | None = None
quantize_clipped_samples: int | None = None
# Stereo mastering processing result.
@dataclass(frozen=True, slots=True, eq=False)
class MasteringStereoResult:
left: npt.NDArray[np.float32]
right: npt.NDArray[np.float32]
sample_rate: int
input_lufs: float
output_lufs: float
applied_gain_db: float
latency_samples: int = 0
loudness_target_limited: bool = False
non_finite_substitution_count: int = 0
declip_unreconstructed_runs: int | None = None
quantize_clipped_samples: int | None = None
# Result of running a configurable mastering chain on mono audio.
@dataclass(frozen=True, slots=True, eq=False)
class MasteringChainResult:
samples: npt.NDArray[np.float32]
sample_rate: int
input_lufs: float
output_lufs: float
applied_gain_db: float
stages: list[str]
output_true_peak_dbtp: float = 0.0
output_loudness_range_lu: float | None = None
loudness_target_limited: bool = False
stage_gain_reductions: list[StageGainReduction] = field(default_factory=list)
report: MasteringReport | None = None
non_finite_substitution_count: int = 0
loudness_gain_db: float | None = None
declip_unreconstructed_runs: int | None = None
# Result of running a configurable mastering chain on stereo audio.
@dataclass(frozen=True, slots=True, eq=False)
class MasteringChainStereoResult:
left: npt.NDArray[np.float32]
right: npt.NDArray[np.float32]
sample_rate: int
input_lufs: float
output_lufs: float
applied_gain_db: float
stages: list[str]
output_true_peak_dbtp: float = 0.0
output_loudness_range_lu: float | None = None
loudness_target_limited: bool = False
stage_gain_reductions: list[StageGainReduction] = field(default_factory=list)
report: MasteringReport | None = None
non_finite_substitution_count: int = 0
loudness_gain_db: float | None = None
declip_unreconstructed_runs: int | None = None
# Gain reduction reported by a single dynamics/maximizer chain stage.
@dataclass(frozen=True, slots=True)
class StageGainReduction:
stage: str
gain_reduction_db: floatレポート
MasteringChainResult.report は、チェーンがプログラムをどう変えたかを説明します。before と after は MasteringLoudnessSummary の測定値で、band_energy_delta_db は対数間隔 32 バンドのスペクトルエネルギーの変化です。
# Compact explanation of how an offline mastering chain changed a program.
@dataclass(frozen=True, slots=True, eq=False)
class MasteringReport:
before: MasteringLoudnessSummary
after: MasteringLoudnessSummary
applied_gain_db: float
max_gain_reduction_db: float
loudness_target_limited: bool
band_energy_delta_db: npt.NDArray[np.float32] = field(default_factory=_empty_float32)
loudness_gain_db: float | None = None
# Existing EBU R128 measurements captured before or after mastering.
@dataclass(frozen=True, slots=True)
class MasteringLoudnessSummary:
integrated_lufs: float
max_momentary_lufs: float | None
max_short_term_lufs: float | None
true_peak_dbtp: float
loudness_range_lu: float | Noneステージとストリーミングのヘルパー
単体のダイナミクスプロセッサは DynamicsProcessorResult を返し、latency_samples はプロセッサのレイテンシ(サンプル数)です。streaming_loudness_gain() とそのステレオ版は StreamingLoudnessGain を返します。loudness_static_gain_db と true_peak_dbtp を、StreamingMasteringChain のコンストラクタの loudness_static_gain_db と loudness_static_gain_peak_dbtp に渡します(Python ダイナミクスとリペア API を参照)。
# Result of a mastering dynamics processor.
@dataclass(frozen=True, slots=True, eq=False)
class DynamicsProcessorResult:
samples: npt.NDArray[np.float32]
latency_samples: int
# The loudness numbers a :class:`StreamingMasteringChain` is built with.
@dataclass(frozen=True, slots=True)
class StreamingLoudnessGain:
loudness_static_gain_db: float | None
true_peak_dbtp: float
integrated_lufs: floatリファレンスマッチング
mastering_ab_match_loudness() は、ラウドネスがリファレンスに合うよう、ソースに 1 つのスタティックゲインを掛けて返します。ステレオ版は両チャンネルに共通のゲインを掛け、シーリングは適用しません。reference_lufs と source_lufs は、無音またはゲート未満のテイクでは None です。
# Result of :func:`mastering_ab_match_loudness`: the matched take and the match.
@dataclass(frozen=True, slots=True, eq=False)
class LoudnessMatchResult:
samples: npt.NDArray[np.float32]
sample_rate: int
reference_lufs: float
source_lufs: float
applied_gain_db: float
matched_true_peak_dbtp: float
# Result of :func:`mastering_ab_match_loudness_stereo`; see :class:`LoudnessMatchResult`.
@dataclass(frozen=True, slots=True, eq=False)
class LoudnessMatchStereoResult:
left: npt.NDArray[np.float32]
right: npt.NDArray[np.float32]
sample_rate: int
reference_lufs: float
source_lufs: float
applied_gain_db: float
matched_true_peak_dbtp: floatペア解析
mastering_analyze_pair() は、解析名に応じて次のいずれかのレコードを返します。match.referenceLoudness、match.tonalBalance と match.tonalBalanceLogBands、match.matchEqCurve、match.estimateReferenceDelaySamples です。MatchEqCurveResult では、gain_db[i] が frequencies[i] での補正量です。MatchTonalBalanceBand は low_hz から high_hz までの帯域で、ソースとリファレンスのレベルとその偏差(dB)を持ちます。
# Result of the ``match.referenceLoudness`` pair analysis.
@dataclass(frozen=True, slots=True)
class MatchReferenceLoudnessResult:
source_lufs: float
reference_lufs: float
gain_to_match_db: float | None
# Result of the ``match.tonalBalance`` and ``match.tonalBalanceLogBands`` analyses.
@dataclass(frozen=True, slots=True)
class MatchTonalBalanceResult:
bands: list[MatchTonalBalanceBand]
# One band of the ``match.tonalBalance`` and ``match.tonalBalanceLogBands`` analyses.
@dataclass(frozen=True, slots=True)
class MatchTonalBalanceBand:
low_hz: float
high_hz: float
source_db: float | None
reference_db: float | None
deviation_db: float | None
# Result of the ``match.matchEqCurve`` pair analysis: ``gain_db[i]`` at ``frequencies[i]``.
@dataclass(frozen=True, slots=True, eq=False)
class MatchEqCurveResult:
frequencies: npt.NDArray[np.float32]
gain_db: npt.NDArray[np.float32]
# Result of the ``match.estimateReferenceDelaySamples`` pair analysis.
@dataclass(frozen=True, slots=True)
class MatchEstimateReferenceDelaySamplesResult:
delay_samples: intモノラル互換性
mastering_analyze_stereo() は、stereo.monoCompatCheck と stereo.monoCompatCheckLogBands に対して次のレコードを返します。correlation は [-1, 1] の範囲で、width は完全に逆相のペアでは None です。
# Result of the ``stereo.monoCompatCheck`` analysis.
@dataclass(frozen=True, slots=True)
class StereoMonoCompatCheckResult:
correlation: float | None
width: float | None
mono_peak: float
side_rms: float
likely_mono_compatible: bool
# One band of the ``stereo.monoCompatCheckLogBands`` analysis.
@dataclass(frozen=True, slots=True)
class StereoMonoCompatBand:
low_hz: float
high_hz: float
correlation: float | None
side_rms: float
# Result of the ``stereo.monoCompatCheckLogBands`` analysis.
@dataclass(frozen=True, slots=True)
class StereoMonoCompatCheckLogBandsResult:
bands: list[StereoMonoCompatBand]アシスタントとプロファイル
mastering_audio_profile() は MasteringAudioProfile を返します。ラウドネス、スペクトル、ダイナミクスの各グループと、任意の defects で構成されます。mastering_assistant_suggest() は MasteringAssistantResult を返します。提案された chain_config(フラットな MasteringChainConfig マッピング)、根拠を示す explanation の行、提案の元になった測定値をまとめたフラットな MasteringAssistantProfile です。ステレオ版も同じレコードを返します。integrated_lufs は、無音またはゲート未満のテイクでは None です。
# What :func:`mastering_audio_profile` and its stereo form return.
@dataclass(frozen=True, slots=True)
class MasteringAudioProfile:
duration_sec: float
bpm: float | None
bpm_confidence: float
loudness: MasteringAudioProfileLoudness
spectral: MasteringAudioProfileSpectral
dynamics: MasteringAudioProfileDynamics
defects: AudioDefects | None
# Loudness group of :class:`MasteringAudioProfile`.
@dataclass(frozen=True, slots=True)
class MasteringAudioProfileLoudness:
integrated_lufs: float
loudness_range_lu: float | None
true_peak_dbtp: float
crest_factor_db: float | None
# Spectral group of :class:`MasteringAudioProfile`.
@dataclass(frozen=True, slots=True)
class MasteringAudioProfileSpectral:
sub_rms_db: float | None
low_rms_db: float | None
low_mid_rms_db: float | None
mid_rms_db: float | None
high_mid_rms_db: float | None
high_rms_db: float | None
air_rms_db: float | None
centroid_hz: float | None
flatness: float | None
rolloff_hz: float | None
# Dynamics group of :class:`MasteringAudioProfile`.
@dataclass(frozen=True, slots=True)
class MasteringAudioProfileDynamics:
short_term_lufs_std: float | None
attack_per_second: float
sustain_ratio: float | None
# Measurements the assistant summarises its suggestion from (flat).
@dataclass(frozen=True, slots=True)
class MasteringAssistantProfile:
duration_sec: float
bpm: float | None
bpm_confidence: float
integrated_lufs: float
loudness_range_lu: float | None
true_peak_dbtp: float
crest_factor_db: float | None
spectral_centroid_hz: float | None
spectral_flatness: float | None
attack_per_second: float
sustain_ratio: float | None
# What :func:`mastering_assistant_suggest` and its stereo form return.
@dataclass(frozen=True, slots=True)
class MasteringAssistantResult:
chain_config: MasteringChainConfig
explanation: list[str]
profile: MasteringAssistantProfileストリーミングプレビュー
mastering_streaming_preview() とそのステレオ版は、配信先ごとに 1 エントリを持つ MasteringStreamingPreviewResult を返します。platforms= には StreamingPlatform のマッピングを渡し、省略すると組み込みの Spotify、Apple Music、YouTube の組が使われます。normalization_gain_db はテイクをプラットフォームの目標に合わせるゲインです(ラウドネスが None のときは 0)。ceiling_risk は、そのゲインでTrue Peakがプラットフォームのシーリングを超えるときに true になります。
# One delivery target a streaming preview or the assistant measures against.
class StreamingPlatform(TypedDict):
name: str
target_lufs: float
ceiling_dbtp: float
# One delivery target in a :class:`MasteringStreamingPreviewResult`.
@dataclass(frozen=True, slots=True)
class MasteringStreamingPreviewPlatform:
name: str
integrated_lufs: float
true_peak_dbtp: float
normalization_gain_db: float | None
ceiling_risk: bool
# What :func:`mastering_streaming_preview` and its stereo form return.
@dataclass(frozen=True, slots=True)
class MasteringStreamingPreviewResult:
platforms: list[MasteringStreamingPreviewPlatform]ミキシングアシスタントのレコード
mixing_assistant_suggest(tracks, *, sample_rate, ...) は MixAssistantTrack のリストを受け取り、MixAssistantResult を返します。別のサンプルレートのトラックは、呼び出しのレートにリサンプリングされます。劣化したトラックはエラーにならず、usable が false で exclusion_reason を持つ状態で tracks に載ります。source は MixSourceClass、band_occupancy は MixAnalysisBand("sub"、"low"、"lowMid"、"mid"、"highMid"、"high"、"air")をキーにします。ワークフローは ミキシングアシスタント にあります。
# One track handed to the mixing assistant.
class MixAssistantTrack(NamedTuple):
id: str
channels: Sequence[Sequence[float] | np.ndarray]
name: str | None = None
sample_rate: int | None = None
# What :func:`mixing_assistant_suggest` returns.
@dataclass(frozen=True, slots=True)
class MixAssistantResult:
scene: dict[str, Any]
tracks: list[MixAssistantTrackProfile]
mix: MixAssistantMixProfile
explanation: list[str]
# Per-track measurements and the class the track was resolved to.
@dataclass(frozen=True, slots=True)
class MixAssistantTrackProfile:
strip_id: str
name: str | None
source: MixSourceClass
source_confidence: float
usable: bool
exclusion_reason: str | None
num_channels: int
duration_sec: float
integrated_lufs: float | None
true_peak_dbtp: float | None
crest_factor_db: float | None
spectral_centroid_hz: float | None
spectral_flatness: float | None
attack_per_second: float
sustain_ratio: float | None
band_occupancy: dict[MixAnalysisBand, float]トラック間の測定
MixAssistantResult.mix は、複数のトラックにまたがる所見を保持します。
# Cross-track measurements the decisions were made from.
@dataclass(frozen=True, slots=True)
class MixAssistantMixProfile:
track_count: int
band_dominance: list[MixBandDominance]
alignment: list[MixTrackAlignment]
crowded_bands: list[MixCrowdedBand]
mono_risks: list[MixMonoRisk]
# One informative masker/maskee band pair.
@dataclass(frozen=True, slots=True)
class MixBandDominance:
masker: str
maskee: str
band: MixAnalysisBand
ratio: float
valid_frames: int
# A related track pair and the time/polarity relationship measured between them.
@dataclass(frozen=True, slots=True)
class MixTrackAlignment:
reference: str
target: str
lag_samples: int
correlation: float
polarity_opposed: bool
# A band carrying more simultaneous sources than the image comfortably holds.
@dataclass(frozen=True, slots=True)
class MixCrowdedBand:
band: MixAnalysisBand
crowding: float
# A track whose stereo image is likely to collapse in mono.
@dataclass(frozen=True, slots=True)
class MixMonoRisk:
strip_id: str
correlation: float
width: float
wide_low_end: bool