// Requires installed FFmpeg/libswresample; preserves filter history across blocks.
import aner.audio

if audio.available() {
    let source = audio.synthetic(frames: 4800, rate: 48000, channels: 2,
                                 block_frames: 480)
    let block = audio.block_slot()
    let converter = audio.resampler(in_rate: 48000, in_channels: 2,
                                    out_rate: 16000, out_channels: 1)
    while source.read_into(block) == "ready" {
        let converted = converter.process(block.freeze())
        print(converted.frames())
    }
    let tail = converter.flush()
    print(tail.frames())
    source.close()
} else {
    print("Optional sample-rate conversion backend unavailable")
}
