MoonBit RIR engine with path-dependent octave materials, atmospheric loss, convex geometry and AudioLabs-compatible numerics
moon add zhangbowen2006/boxrir@0.3.0| 模式 | 能力与输入约定 | 时间轴 |
|---|---|---|
| octave_bands | 逐路径六频段墙面能量吸声、按物理距离的空气损耗;温度/湿度/压力方程或显式 dB/m;矩形和凸柱体 | 互补 FIR 合成,核长随采样率缩放;16kHz 默认共同延迟272采样,保留完整尾部 |
| audiolabs_v030 | 移植 AudioLabs RIR Generator 0.3.0 数值核;五种麦克风指向性、方位/俯仰、六墙有符号压力反射系数或 T60、二维/三维反射、有限阶/窗口内镜像、可选 100Hz 高通 | 上游 8ms Hann-sinc,固定 nsample,无额外延迟;默认长度规则保留上游行为 |
| 原矩形模型 | 全向点源/接收点,六墙能量吸声、有限总反射阶数、归一化 Hann-sinc | 保留到达时间窗,加共同 half_width 延迟及完整核尾部 |
| 凸多边形柱体 | 3–8 个逆时针严格凸顶点,0–4 阶;逐有限墙面回溯,导出墙序列与命中点 | 与原模型相同;排除棱边、顶点及擦边退化路径 |
node bin/boxrir.mjs --version
node bin/boxrir.mjs simulate examples/spectral-before.json examples/probe.wav output-spectral
node bin/boxrir.mjs rir examples/stereo.json output-stereo
node bin/boxrir.mjs simulate examples/triangle.json examples/probe.wav output-triangle
node bin/boxrir.mjs --backend wasm-gc simulate examples/reference-cardioid.json examples/probe.wav output-cardioidimport {createBoxRIR} from './sdk/client.mjs';
import fs from 'node:fs';
const engine = await createBoxRIR();
const scene = JSON.parse(fs.readFileSync('examples/reference-cardioid.json', 'utf8'));
const result = engine.render(scene, {dryWav: fs.readFileSync('examples/probe.wav')});
fs.writeFileSync('my-rir.wav', result.rirWav);moon update
moon check --target all --deny-warn
moon test --target js --deny-warn
moon test --target wasm --deny-warn
moon test --target wasm-gc --deny-warn
node scripts/build-sdk.mjs
node --test tests/*.test.mjs
node scripts/build-demo.mjs
node scripts/serve-demo.mjsnode scripts/build-release.mjs
node scripts/test-distribution.mjs
moon package
python scripts/test-moon-package.py| 使用者与问题 | 输入与操作 | 输出及验证 |
|---|---|---|
| 浏览器音频工具开发者需要无需 Python 服务的双通道响应 | stereo.json 执行 rir,或在工作台生成 | 两通道 4032 帧;直接声到达约 7.658/8.090ms,每通道 377 条保留路径。独立镜像参考、延迟和增益测试 |
| 语音/阵列算法开发者需要带方向性差异的可复现模拟录音 | reference-cardioid.json + probe.wav 执行 simulate | 两通道 2048 帧 RIR、18047 帧录音,无额外延迟;原版 AudioLabs C++ 波形和 SciPy 卷积逐样本对照 |
| 声学原型与教学开发者需要非矩形房间反射 | triangle.json、trapezoid.json、pentagon.json 执行 simulate | 两通道 WAV、有限面有效路径和卷积尾部;pyroomacoustics 几何/可见性对照,命中点、反射定律和物理路径长度验证 |
| 材料/语音原型开发者对比高频吸声处理 | spectral-before.json 与 spectral-after.json 执行 simulate,仅改变一面墙的部分频带 | 两通道2464帧RIR、18463帧录音;逐路径频段增益、真实WAV与SciPy核对 |
| 教学人员对比单墙吸声变化 | wall-before.json 与 wall-after.json 只改变 x 低墙吸声 | 该墙一阶压力增益变成 1/3,到达时间及其他一阶反射不变;独立公式与输出文件核对 |
pub struct Audio {
sample_rate : Int
latency_samples : Int
// private fields
}pub(all) struct Point2 {
x : Double
y : Double
}pub struct ReferenceRir {
audio : Audio
beta : Array[Double]
reverberation_time : Double?
microphone : String
orientation : Array[Double]
dimension : Int
high_pass : Bool
kernel_frames : Int
evaluated_candidates : Int
contributing : Array[Int]
late : Array[Int]
zero : Array[Int]
paths : Array[Path]
direct_paths : Array[Path]
paths_truncated : Bool
}pub struct Response {
// private fields
}pub struct Scene {
// private fields
}pub(all) struct Vec3 {
x : Double
y : Double
z : Double
}fn audiolabs_rir(room : Vec3, source : Vec3, receivers : Array[Vec3], sample_rate : Int, speed? : Double, beta? : Array[Double]?, reverberation_time? : Double?, nsample? : Int?, order? : Int, dimension? : Int, microphone? : String, orientation? : Array[Double], high_pass? : Bool) -> Result[ReferenceRir, String]Install
Download zipMoonBit RIR engine with path-dependent octave materials, atmospheric loss, convex geometry and AudioLabs-compatible numerics