纯 MoonBit 的交错 PCM 流式响度与峰值分析库
moon add hutingyu-nuist/moonloudness@0.1.3git clone https://github.com/hutingyu-nuist/moonloudness.git
cd moonloudness
moon check --target wasm-gc
moon test --target wasm-gclet layout = @moonloudness.ChannelLayout::mono()
let config = match @moonloudness.MeterConfig::new(48000, layout) {
Ok(value) => value
Err(_) => panic()
}
let meter = @moonloudness.Analyzer::new(config)
match meter.push(samples) { // Array[Double],完整交错帧
Ok(_) => ()
Err(_) => panic()
}
let report = meter.finish()
match report.integrated_lufs() {
Some(value) => println(value.to_string())
None => println("综合响度暂不可用")
}
match report.true_peak_dbtp() {
Some(value) => println(value.to_string())
None => println("真峰值暂不可用")
}moon run examples/mono --target wasm-gc
moon run examples/stereo --target wasm-gc
moon run examples/surround --target wasm-gc
moon run examples/batch --target wasm-gc
moon run examples/reference --target wasm-gcpython tools/check_toolchain.py
moon info
moon fmt --check
moon check --deny-warn --target wasm-gc
moon check --deny-warn --target js
moon test --deny-warn --target wasm-gc
moon test --deny-warn --target js
moon build --release --target wasm-gcpython -m unittest discover -s tools -p "test_*.py" -vpub struct AggregateReport {
// private fields
}fn AggregateReport::normalization_plan(self : AggregateReport, target_lufs : Double, ceiling_dbtp : Double) -> Result[NormalizationPlan, NormalizationPlanError]pub enum AggregationError {
UnsupportedAggregateSampleRate(Int)
ReportSampleRateMismatch(Int, Int)
AggregateCounterOverflow
InvalidAggregateCounters
InvalidAggregateDistribution
InvalidAggregatePeak
}pub struct Analyzer {
// private fields
}fn Analyzer::new_with_history_capacity(config : MeterConfig, capacity : Int) -> Result[Analyzer, MeterError]pub enum ChannelLayout {
Mono
Stereo
FivePointZero
}pub struct IntegratedGateReport {
// private fields
}pub struct LoudnessAggregator {
// private fields
}fn LoudnessAggregator::add(self : LoudnessAggregator, report : MeasurementReport) -> Result[Unit, AggregationError]fn LoudnessAggregator::merge(self : LoudnessAggregator, other : LoudnessAggregator) -> Result[Unit, AggregationError]pub struct LraGateReport {
// private fields
}pub struct MeasurementReport {
// private fields
}fn MeasurementReport::channel_sample_peak_linear(self : MeasurementReport, channel : Int) -> Double?fn MeasurementReport::normalization_plan(self : MeasurementReport, target_lufs : Double, ceiling_dbtp : Double) -> Result[NormalizationPlan, NormalizationPlanError]pub struct MeterConfig {
// private fields
}pub enum MeterError {
UnsupportedSampleRate(Int)
IncompleteFrame(Int, Int)
NonFiniteSample
SampleMagnitudeTooLarge(Double)
CounterOverflow
InvalidHistoryCapacity(Int)
AnalyzerFinished
}pub struct MeterSnapshot {
// private fields
}pub struct NormalizationPlan {
// private fields
}pub enum NormalizationPlanError {
MissingIntegratedLoudness
InvalidTargetLufs(Double)
InvalidTruePeakCeilingDbtp(Double)
InvalidMeasuredLevels
UnsafeNormalizationMath
}