.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Soundfont generic routines. |
---|
3 | 4 | * It is intended that these should be used by any driver that is willing |
---|
.. | .. |
---|
5 | 6 | * |
---|
6 | 7 | * Copyright (C) 1999 Steve Ratcliffe |
---|
7 | 8 | * Copyright (c) 1999-2000 Takashi Iwai <tiwai@suse.de> |
---|
8 | | - * |
---|
9 | | - * This program is free software; you can redistribute it and/or modify |
---|
10 | | - * it under the terms of the GNU General Public License as published by |
---|
11 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
12 | | - * (at your option) any later version. |
---|
13 | | - * |
---|
14 | | - * This program is distributed in the hope that it will be useful, |
---|
15 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | | - * GNU General Public License for more details. |
---|
18 | | - * |
---|
19 | | - * You should have received a copy of the GNU General Public License |
---|
20 | | - * along with this program; if not, write to the Free Software |
---|
21 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
22 | 9 | */ |
---|
23 | 10 | /* |
---|
24 | 11 | * Deal with reading in of a soundfont. Code follows the OSS way |
---|
.. | .. |
---|
764 | 751 | |
---|
765 | 752 | |
---|
766 | 753 | /* log2_tbl[i] = log2(i+128) * 0x10000 */ |
---|
767 | | -static int log_tbl[129] = { |
---|
| 754 | +static const int log_tbl[129] = { |
---|
768 | 755 | 0x70000, 0x702df, 0x705b9, 0x7088e, 0x70b5d, 0x70e26, 0x710eb, 0x713aa, |
---|
769 | 756 | 0x71663, 0x71918, 0x71bc8, 0x71e72, 0x72118, 0x723b9, 0x72655, 0x728ed, |
---|
770 | 757 | 0x72b80, 0x72e0e, 0x73098, 0x7331d, 0x7359e, 0x7381b, 0x73a93, 0x73d08, |
---|
.. | .. |
---|
856 | 843 | int r, p, t; |
---|
857 | 844 | r = (3 - ((rate >> 6) & 3)) * 3; |
---|
858 | 845 | p = rate & 0x3f; |
---|
| 846 | + if (!p) |
---|
| 847 | + p = 1; |
---|
859 | 848 | t = end - start; |
---|
860 | 849 | if (t < 0) t = -t; |
---|
861 | 850 | if (13 > r) |
---|
.. | .. |
---|
868 | 857 | /* convert envelope time parameter to soundfont parameters */ |
---|
869 | 858 | |
---|
870 | 859 | /* attack & decay/release time table (msec) */ |
---|
871 | | -static short attack_time_tbl[128] = { |
---|
| 860 | +static const short attack_time_tbl[128] = { |
---|
872 | 861 | 32767, 32767, 5989, 4235, 2994, 2518, 2117, 1780, 1497, 1373, 1259, 1154, 1058, 970, 890, 816, |
---|
873 | 862 | 707, 691, 662, 634, 607, 581, 557, 533, 510, 489, 468, 448, 429, 411, 393, 377, |
---|
874 | 863 | 361, 345, 331, 317, 303, 290, 278, 266, 255, 244, 234, 224, 214, 205, 196, 188, |
---|
.. | .. |
---|
879 | 868 | 11, 11, 10, 10, 10, 9, 9, 8, 8, 8, 8, 7, 7, 7, 6, 0, |
---|
880 | 869 | }; |
---|
881 | 870 | |
---|
882 | | -static short decay_time_tbl[128] = { |
---|
| 871 | +static const short decay_time_tbl[128] = { |
---|
883 | 872 | 32767, 32767, 22614, 15990, 11307, 9508, 7995, 6723, 5653, 5184, 4754, 4359, 3997, 3665, 3361, 3082, |
---|
884 | 873 | 2828, 2765, 2648, 2535, 2428, 2325, 2226, 2132, 2042, 1955, 1872, 1793, 1717, 1644, 1574, 1507, |
---|
885 | 874 | 1443, 1382, 1324, 1267, 1214, 1162, 1113, 1066, 978, 936, 897, 859, 822, 787, 754, 722, |
---|
.. | .. |
---|
902 | 891 | |
---|
903 | 892 | /* search an index for specified time from given time table */ |
---|
904 | 893 | static int |
---|
905 | | -calc_parm_search(int msec, short *table) |
---|
| 894 | +calc_parm_search(int msec, const short *table) |
---|
906 | 895 | { |
---|
907 | 896 | int left = 1, right = 127, mid; |
---|
908 | 897 | while (left < right) { |
---|