///|
test "typed reference core from the selected release" {
  let rir = @boxrir.audiolabs_rir(
    { x: 6.0, y: 4.0, z: 3.0 }, { x: 1.0, y: 1.0, z: 1.0 },
    [{ x: 2.0, y: 1.0, z: 1.0 }], 16000,
    beta=Some([0.7, 0.6, 0.5, 0.4, 0.3, 0.2]), nsample=Some(512),
    microphone="cardioid", order=2,
  ).unwrap()
  assert_eq(rir.audio.frames(), 512)
  assert_eq(rir.audio.latency_samples, 0)
  assert_eq(rir.audio.convolve([1.0, 0.5]).unwrap().frames(), 513)
}
///|
test "typed convex geometry from the selected release" {
  let room = @boxrir.prism_scene(
    [{ x: 0.0, y: 0.0 }, { x: 6.0, y: 0.0 }, { x: 0.0, y: 4.0 }], 3.0,
    { x: 1.0, y: 1.0, z: 1.0 }, [{ x: 2.0, y: 1.0, z: 1.0 }],
    [0.2, 0.3, 0.4, 0.5, 0.6], 16000, 4, 100,
  ).unwrap()
  assert_true(@boxrir.trace_prism(room).length() > 1)
  assert_eq(@boxrir.render(room).channel_count(), 1)
}
///|
test "WAV module preserves amplitudes from the selected release" {
  let bytes = @wav.write_float32([[0.5, -2.0, 0.0]], 16000).unwrap()
  assert_eq(@wav.read_mono(bytes).unwrap().samples, [0.5, -2.0, 0.0])
}
///|
test "spectral materials and atmosphere are usable from a separate project" {
  let scene = @boxrir.scene(
    { x: 6.0, y: 4.0, z: 3.0 }, { x: 1.0, y: 1.0, z: 1.0 },
    [{ x: 2.0, y: 1.0, z: 1.0 }], [0.2, 0.2, 0.2, 0.2, 0.2, 0.2], 16000, 1, 60,
  ).unwrap()
  let air = @boxrir.atmospheric_air_loss(20.0, 50.0).unwrap()
  let result = @boxrir.spectral_rir(scene, Array::makei(6, fn(_) { Array::make(6, 0.3) }), air_db_per_m=air).unwrap()
  assert_eq(result.audio.frames(), 1504)
  assert_eq(result.audio.latency_samples, 272)
  assert_eq(@boxrir.octave_filters(96000).unwrap()[0].length(), 3073)
}
