| 1 | /* |
| 2 | --------------------------------------------------------------------------- |
| 3 | a_pitch.c - Simple fixed point linear pitch table. |
| 4 | --------------------------------------------------------------------------- |
| 5 | * Copyright (C) 2001, 2002, David Olofson |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU Lesser General Public License as published by |
| 9 | * the Free Software Foundation; either version 2.1 of the License, or (at |
| 10 | * your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * Lesser General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General Public License |
| 18 | * along with this program; if not, write to the Free Software Foundation, |
| 19 | * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 20 | */ |
| 21 | |
| 22 | #include <stdlib.h> |
| 23 | #include "a_globals.h"cxx . . $ `<file>/sound/a_globals.h`/ |
| 24 | #include "a_pitch.h"cxx . . $ `<file>/sound/a_pitch.h`/ |
| 25 | |
| 26 | /* |
| 27 | * Start pitch, based on the assumption that 1.0 (original |
| 28 | * sample playback speed) gives you a middle C (MIDI #60). |
| 29 | */ |
| 30 | #define FIVE_OCTAVEScxx . . $ `sound/a_pitch.c:30:9`! (1 << 5) |
| 31 | |
| 32 | /* 1 + twelfth root of two */ |
| 33 | #define SEMITONE_MULTIPLIERcxx . . $ `sound/a_pitch.c:33:9`! 1.0594630943592953 |
| 34 | |
| 35 | int *__pitchtabcxx . . $ __pitchtab. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 36 | |
| 37 | int ptab_initcxx . . $ ptab_init(7864480464b09eea).(int middle_c) |
| 38 | { |
| 39 | int p; |
| 40 | double pitch; |
| 41 | freecxx . . $ free(5d22bdacc48458e8).(__pitchtabcxx . . $ __pitchtab.); |
| 42 | __pitchtabcxx . . $ __pitchtab. = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(129 * sizeof(int)); |
| 43 | if(!__pitchtabcxx . . $ __pitchtab.) |
| 44 | return -1; |
| 45 | |
| 46 | pitch = (double)middle_c / FIVE_OCTAVEScxx . . $ `sound/a_pitch.c:30:9`!; |
| 47 | for(p = 0; p < 129; ++p) |
| 48 | { |
| 49 | __pitchtabcxx . . $ __pitchtab.[p] = (int)pitch; |
| 50 | pitch *= SEMITONE_MULTIPLIERcxx . . $ `sound/a_pitch.c:33:9`!; |
| 51 | } |
| 52 | return 0; |
| 53 | } |
| 54 | |
| 55 | void ptab_closecxx . . $ ptab_close(49f6e7a06ebc5aa8).(void) |
| 56 | { |
| 57 | freecxx . . $ free(5d22bdacc48458e8).(__pitchtabcxx . . $ __pitchtab.); |
| 58 | __pitchtabcxx . . $ __pitchtab. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 59 | } |
| 60 |