// Full-pipeline Windows check, linked with libopus and libsamplerate: // `encode IN.wav OUT.opus` uses the Linux CLI's voice settings (24 kbps, // voice, wide-band cap, constrained VBR); `resample IN.wav RATE` prints the // status so the test can assert the documented Windows sinc boundary. #import "types" #import "std/audio_types" #import "pipeline" #import "resample" #import "std/audio_wav" #import "std/vec" #import "std/file" #import "std/byte_text_linux" #program_export main :: (argc: s32, argv: **u8) -> s32 { if argc != 4 { print("windows_encode encode INPUT.wav OUTPUT.opus | resample INPUT.wav 16000\n"); return Invalid } command := TextFromCString(argv[1]) bytes: Vec(u8) if !ReadFileInto(TextFromCString(argv[2]), *bytes) { print("input/output failed\n"); return IOFailure } pcm: PCM code := WavDecode(VecSlice(bytes, 0, bytes.count), MaxFrames, *pcm) if code != OK { print("%\n", ErrorText(code)); return code } if command == "resample" { converted: PCM print("%\n", ErrorText(Resample(*pcm, 16000, *converted))) return 0 } if command != "encode" { return Invalid } options := DefaultOptions() options.bitrate = 24000; options.application = .Voice; options.bandwidth = .Wide options.vbr = true; options.constrained_vbr = true output: Vec(u8) code = Encode(*pcm, options, *output) if code != OK { print("%\n", ErrorText(code)); return code } if !WriteEntireFile(TextFromCString(argv[3]), TextFromBytes(VecSlice(output, 0, output.count))) { print("input/output failed\n"); return IOFailure } print("wrote % bytes\n", output.count) return 0 }