Pure MoonBit bounded streaming sample rate conversion with anti-alias FIR filtering.
| 维度 | 0.2.0 功能 |
|---|---|
| 速率 | 整数 8000..192000 Hz;最多 4096 精确相位、1,048,576 个系数,超预算返回 ResourceLimit |
| 声道 | 1..8,交错排列,各声道独立;不做声道重映射 |
| 质量 | LowLatency / Balanced(默认)/ HighQuality |
| 样本 | 有限 Double;核心不截幅,拒绝 NaN/Infinity |
| 核心后端 | native、JavaScript、wasm-gc,三个后端均实际构建和测试 |
| WAV | PCM16LE / IEEE float32;多声道 extensible;native 文件 CLI |
| 边界 | 两端零延拓;同速率精确直通、零前瞻 |
moon fmt --check
moon check --target native --deny-warn --warn-list +73
moon build --target native --deny-warn
moon test --target native --deny-warn
moon test --target js --deny-warn
moon test --target wasm-gc --deny-warn
python scripts/e2e.py
python scripts/quality.py
python scripts/run_examples.py
python scripts/bounded_stream.py
python scripts/consumer.py///|
import {
"Ag108/MoonSRC",
}///|
test "readme/minimal stereo conversion" {
let config = @MoonSRC.Config::new(44100, 48000, 2).unwrap()
let input = Array::make(882, 0.25) // 441 stereo frames
let output = @MoonSRC.resample(config, input[:]).unwrap()
assert_eq(output.length(), 960) // 480 stereo frames
}moon run --target native cmd/main -- --help
moon run --target native cmd/main -- fixture _build/input.wav --rate 44100 --channels 6 --frames 441 --format float32
moon run --target native cmd/main -- convert _build/input.wav _build/output.wav --rate 48000 --quality high --format float32moon run --target native examples/memory_44100_to_48000
moon run --target native examples/speech_48000_to_16000
moon run --target native examples/chunked_equivalence
moon run --target native examples/channel_isolation
moon run --target native examples/wav_convert -- _build/example_input.wav _build/example_output.wav
moon run --target native examples/multichannel_6ch
moon run --target native examples/quality_tradeoff
moon run --target native examples/bounded_stream
moon run --target native examples/consumer_from_mooncakes| 档位 | 1 kHz 幅度误差,dB | 12 kHz 混叠相对值,dB | 混叠上限,dB |
|---|---|---|---|
| low | +9.084903752e-06 | -91.785047 | -45 |
| balanced | +1.247659545e-06 | -110.608188 | -50 |
| high | +1.336351203e-07 | -127.051823 | -70 |
fn Config::new(input_rate : Int, output_rate : Int, channels : Int) -> Result[Config, ResampleError]fn Config::with_quality(input_rate : Int, output_rate : Int, channels : Int, quality : Quality) -> Result[Config, ResampleError]pub(all) struct Latency {
input_frames : Int
output_frames : Int
seconds : Double
}pub(all) struct Progress {
consumed_frames : Int
produced_frames : Int
needs_input : Bool
needs_output : Bool
finished : Bool
}pub struct Resampler {
// private fields
}fn Resampler::finish(self : Resampler, output : FixedArray[Double]) -> Result[Progress, ResampleError]fn Resampler::process(self : Resampler, input : ArrayView[Double], output : FixedArray[Double]) -> Result[Progress, ResampleError]pub(all) struct Stats {
input_frames : Int64
output_frames : Int64
buffered_frames : Int
peak_history_frames : Int
history_capacity_samples : Int
coefficient_samples : Int
internal_samples : Int
}fn resample_into(config : Config, input : ArrayView[Double], output_buffer : FixedArray[Double]) -> Result[Int, ResampleError]Install
Download zipPure MoonBit bounded streaming sample rate conversion with anti-alias FIR filtering.