From a2d01cbc0d542b87bece37b6644326fdd79f006c Mon Sep 17 00:00:00 2001 From: ratchov Date: Mon, 7 Mar 2022 09:04:45 +0000 Subject: [PATCH] Switch internal sample representation to 24-bit fixed-point Note that this also changes the default file encoding to 24-bit. --- usr.bin/aucat/aucat.1 | 6 +++--- usr.bin/aucat/aucat.c | 6 +++++- usr.bin/aucat/dsp.h | 18 ++---------------- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/usr.bin/aucat/aucat.1 b/usr.bin/aucat/aucat.1 index 63d9fee8e70..787a8f829a4 100644 --- a/usr.bin/aucat/aucat.1 +++ b/usr.bin/aucat/aucat.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: aucat.1,v 1.116 2020/04/22 05:37:00 jmc Exp $ +.\" $OpenBSD: aucat.1,v 1.117 2022/03/07 09:04:45 ratchov Exp $ .\" .\" Copyright (c) 2006 Alexandre Ratchov .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: April 22 2020 $ +.Dd $Mdocdate: March 7 2022 $ .Dt AUCAT 1 .Os .Sh NAME @@ -88,7 +88,7 @@ Increase log verbosity. .It Fl e Ar enc Encoding of the audio file. The default is -.Va s16 . +.Va s24 . Encoding names use the following scheme: signedness .Po .Va s diff --git a/usr.bin/aucat/aucat.c b/usr.bin/aucat/aucat.c index 8d2ae50d908..64b9986d492 100644 --- a/usr.bin/aucat/aucat.c +++ b/usr.bin/aucat/aucat.c @@ -1393,7 +1393,11 @@ main(int argc, char **argv) rate = DEFAULT_RATE; cmin = 0; cmax = 1; - aparams_init(&par); + par.bits = ADATA_BITS; + par.bps = APARAMS_BPS(par.bits); + par.le = ADATA_LE; + par.sig = 1; + par.msb = 1; hdr = AFILE_HDR_AUTO; n_flag = 0; port = NULL; diff --git a/usr.bin/aucat/dsp.h b/usr.bin/aucat/dsp.h index 925ccf23abb..3ebb59abfc5 100644 --- a/usr.bin/aucat/dsp.h +++ b/usr.bin/aucat/dsp.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dsp.h,v 1.8 2021/05/25 08:06:12 ratchov Exp $ */ +/* $OpenBSD: dsp.h,v 1.9 2022/03/07 09:04:45 ratchov Exp $ */ /* * Copyright (c) 2012 Alexandre Ratchov * @@ -25,29 +25,15 @@ * boundary is excluded. We represent them as signed fixed point numbers * of ADATA_BITS. We also assume that 2^(ADATA_BITS - 1) fits in a int. */ -#ifndef ADATA_BITS -#define ADATA_BITS 16 -#endif +#define ADATA_BITS 24 #define ADATA_LE (BYTE_ORDER == LITTLE_ENDIAN) #define ADATA_UNIT (1 << (ADATA_BITS - 1)) -#if ADATA_BITS == 16 - -#define ADATA_MUL(x,y) (((int)(x) * (int)(y)) >> (ADATA_BITS - 1)) - -typedef short adata_t; - -#elif ADATA_BITS == 24 - #define ADATA_MUL(x,y) \ ((int)(((long long)(x) * (long long)(y)) >> (ADATA_BITS - 1))) typedef int adata_t; -#else -#error "only 16-bit and 24-bit precisions are supported" -#endif - /* * The FIR is sampled and stored in a table of fixed-point numbers * with 23 fractional bits. For convenience, we use the same fixed-point -- 2.20.1