On Tue, Jan 10, 2023 at 08:22:27PM +0000, John Rigg wrote: > > > > # If I recall correctly, I converted to FLAC here because the WAV headers > > > # generated by aucat and SoX differed, and so SoX would refuse to play > > > WAV fil > > es > > > # created by aucat. > > > > That would be a bug in itself. > > How exactly does SoX refuse to play the WAVs created by aucat? > > sox is strict about headers and will complain if cbSize is inconsistent with > fmt size. Workaround is to use the '-t sndfile' option. > > aucat is not alone here; several other programs write .wav files that > require this option with sox. >
Here's a diff to switch aucat to extended wav format. According to Microsoft docs, it is needed if bits > 16 or if there are more than 2 channels, which aucat supports. It fixes the sox problem. No regressions found with various ports and few windows programs. ok? Index: afile.c =================================================================== RCS file: /cvs/src/usr.bin/aucat/afile.c,v retrieving revision 1.9 diff -u -p -u -p -r1.9 afile.c --- afile.c 24 Oct 2021 21:24:15 -0000 1.9 +++ afile.c 10 Jan 2023 23:52:47 -0000 @@ -432,12 +432,17 @@ afile_wav_writehdr(struct afile *f) le32_set(&hdr.riff.size, f->endpos - sizeof(hdr.riff)); memcpy(hdr.fmt_hdr.id, wav_id_fmt, 4); le32_set(&hdr.fmt_hdr.size, sizeof(hdr.fmt)); - le16_set(&hdr.fmt.fmt, 1); + le16_set(&hdr.fmt.fmt, WAV_FMT_EXT); le16_set(&hdr.fmt.nch, f->nch); le32_set(&hdr.fmt.rate, f->rate); le32_set(&hdr.fmt.byterate, f->rate * f->par.bps * f->nch); le16_set(&hdr.fmt.blkalign, f->par.bps * f->nch); le16_set(&hdr.fmt.bits, f->par.bits); + le16_set(&hdr.fmt.extsize, + WAV_FMT_EXT_SIZE - WAV_FMT_SIZE - sizeof(hdr.fmt.extsize)); + le16_set(&hdr.fmt.valbits, f->par.bits); + le16_set(&hdr.fmt.extfmt, 1); + memcpy(&hdr.fmt.guid, wav_guid, sizeof(hdr.fmt.guid)); memcpy(hdr.data_hdr.id, wav_id_data, 4); le32_set(&hdr.data_hdr.size, f->endpos - f->startpos); return afile_writehdr(f, &hdr, sizeof(struct wav_hdr));