From: ratchov Date: Mon, 22 Apr 2024 11:07:42 +0000 (+0000) Subject: sndiod: Use a 24-bit table for index to volume conversion. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=be3fa683b7d2a7843c650b1ee88410194466220b;p=openbsd sndiod: Use a 24-bit table for index to volume conversion. --- diff --git a/usr.bin/sndiod/dsp.c b/usr.bin/sndiod/dsp.c index 57085b8dbbc..f3420d151cd 100644 --- a/usr.bin/sndiod/dsp.c +++ b/usr.bin/sndiod/dsp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsp.c,v 1.19 2024/04/22 11:01:02 ratchov Exp $ */ +/* $OpenBSD: dsp.c,v 1.20 2024/04/22 11:07:42 ratchov Exp $ */ /* * Copyright (c) 2008-2012 Alexandre Ratchov * @@ -19,23 +19,38 @@ #include "utils.h" const int aparams_ctltovol[128] = { - 0, - 256, 266, 276, 287, 299, 310, 323, 335, - 348, 362, 376, 391, 406, 422, 439, 456, - 474, 493, 512, 532, 553, 575, 597, 621, - 645, 670, 697, 724, 753, 782, 813, 845, - 878, 912, 948, 985, 1024, 1064, 1106, 1149, - 1195, 1241, 1290, 1341, 1393, 1448, 1505, 1564, - 1625, 1689, 1756, 1825, 1896, 1971, 2048, 2128, - 2212, 2299, 2389, 2483, 2580, 2682, 2787, 2896, - 3010, 3128, 3251, 3379, 3511, 3649, 3792, 3941, - 4096, 4257, 4424, 4598, 4778, 4966, 5161, 5363, - 5574, 5793, 6020, 6256, 6502, 6757, 7023, 7298, - 7585, 7883, 8192, 8514, 8848, 9195, 9556, 9931, - 10321, 10726, 11148, 11585, 12040, 12513, 13004, 13515, - 14045, 14596, 15170, 15765, 16384, 17027, 17696, 18390, - 19112, 19863, 20643, 21453, 22295, 23170, 24080, 25025, - 26008, 27029, 28090, 29193, 30339, 31530, 32768 + 0, 65536, 68109, 70783, + 73562, 76450, 79451, 82570, + 85812, 89181, 92682, 96321, + 100102, 104032, 108116, 112361, + 116772, 121356, 126121, 131072, + 136218, 141566, 147123, 152899, + 158902, 165140, 171624, 178361, + 185364, 192641, 200204, 208064, + 216232, 224721, 233544, 242713, + 252241, 262144, 272436, 283131, + 294247, 305799, 317804, 330281, + 343247, 356723, 370728, 385282, + 400408, 416128, 432465, 449443, + 467088, 485425, 504482, 524288, + 544871, 566262, 588493, 611597, + 635608, 660561, 686495, 713446, + 741455, 770564, 800816, 832255, + 864929, 898885, 934175, 970850, + 1008965, 1048576, 1089742, 1132525, + 1176987, 1223194, 1271216, 1321123, + 1372989, 1426892, 1482910, 1541128, + 1601632, 1664511, 1729858, 1797771, + 1868350, 1941700, 2017930, 2097152, + 2179485, 2265049, 2353974, 2446389, + 2542432, 2642246, 2745978, 2853783, + 2965821, 3082257, 3203264, 3329021, + 3459716, 3595542, 3736700, 3883400, + 4035859, 4194304, 4358969, 4530099, + 4707947, 4892777, 5084864, 5284492, + 5491957, 5707567, 5931642, 6164513, + 6406527, 6658043, 6919432, 7191084, + 7473400, 7766800, 8071719, 8388608 }; const int resamp_filt[RESAMP_LENGTH / RESAMP_STEP + 1] = { diff --git a/usr.bin/sndiod/dsp.h b/usr.bin/sndiod/dsp.h index 69e1b7a63ba..d4f96a3cbae 100644 --- a/usr.bin/sndiod/dsp.h +++ b/usr.bin/sndiod/dsp.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dsp.h,v 1.13 2024/04/22 11:01:02 ratchov Exp $ */ +/* $OpenBSD: dsp.h,v 1.14 2024/04/22 11:07:42 ratchov Exp $ */ /* * Copyright (c) 2012 Alexandre Ratchov * @@ -107,7 +107,7 @@ struct cmap { int nch; }; -#define MIDI_TO_ADATA(m) (aparams_ctltovol[m] << (ADATA_BITS - 16)) +#define MIDI_TO_ADATA(m) (aparams_ctltovol[m]) extern const int aparams_ctltovol[128]; void aparams_init(struct aparams *);