Pure MoonBit bounded streaming sample rate conversion with anti-alias FIR filtering.
| 维度 | 功能 |
|---|---|
| 比率 | 44100↔48000、48000↔16000 Hz;16000/44100/48000 同速率直通 |
| 声道 | 1 或 2,交错排列 |
| 样本 | 有限 Double;核心不截幅,拒绝 NaN/Infinity |
| 核心后端 | native、JavaScript、wasm-gc,均有本机运行证据 |
| WAV | RIFF/WAVE PCM16LE;native CLI;其他编码明确拒绝 |
| 边界 | 两端零延拓;非同速率有 96 输入帧前瞻 |
moon fmt --check
moon check --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 2 --frames 441
moon run --target native cmd/main -- convert _build/input.wav _build/output.wav --rate 48000moon 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.wavfn Config::new(input_rate : Int, output_rate : Int, channels : Int) -> 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
}Install
Download zipPure MoonBit bounded streaming sample rate conversion with anti-alias FIR filtering.