1 /* GSequencer - Advanced GTK Sequencer 2 * Copyright (C) 2005-2021 Joël Krähemann 3 * 4 * This file is part of GSequencer. 5 * 6 * GSequencer is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * GSequencer is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with GSequencer. If not, see <http://www.gnu.org/licenses/>. 18 * 19 * FluidSynth - A Software Synthesizer 20 * 21 * Copyright (C) 2003 Peter Hanappe and others. 22 * 23 * This library is free software; you can redistribute it and/or 24 * modify it under the terms of the GNU Lesser General Public License 25 * as published by the Free Software Foundation; either version 2.1 of 26 * the License, or (at your option) any later version. 27 * 28 * This library is distributed in the hope that it will be useful, but 29 * WITHOUT ANY WARRANTY; without even the implied warranty of 30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 31 * Lesser General Public License for more details. 32 * 33 * You should have received a copy of the GNU Lesser General Public 34 * License along with this library; if not, write to the Free 35 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 36 * 02110-1301, USA 37 */ 38 39 #ifndef __AGS_FLUID_UTIL_H__ 40 #define __AGS_FLUID_UTIL_H__ 41 42 #include <glib.h> 43 #include <glib-object.h> 44 45 #include <ags/libags.h> 46 47 #include <math.h> 48 #include <complex.h> 49 50 G_BEGIN_DECLS 51 #define AGS_TYPE_FLUID_UTIL (ags_fluid_util_get_type()) 52 53 #define AGS_FLUID_INTERP_BITS (8) 54 #define AGS_FLUID_INTERP_BITS_MASK (0xff000000) 55 #define AGS_FLUID_INTERP_BITS_SHIFT (24) 56 57 #define AGS_FLUID_FRACT_MAX ((gdouble) 4294967296.0) 58 59 #define AGS_FLUID_INTERP_MAX (256) 60 #define AGS_FLUID_SINC_INTERP_ORDER 7 /* 7th order constant */ 61 62 #define AGS_FLUID_CENTS_HZ_SIZE (1200) 63 64 typedef struct _AgsFluidUtil AgsFluidUtil; 65 66 struct _AgsFluidUtil 67 { 68 //empty 69 }; 70 71 GType ags_fluid_util_get_type(void); 72 73 #define ags_fluid_phase_set(a,b) a=b; 74 #define ags_fluid_phase_set_int(a, b) ((a) = ((guint64)(b)) << 32) 75 76 #define ags_fluid_phase_set_float(a, b) \ 77 (a) = (((guint64)(b)) << 32) \ 78 | (guint32) (((gdouble)(b) - (gint)(b)) * (gdouble)AGS_FLUID_FRACT_MAX) 79 80 #define ags_fluid_phase_from_index_fract(index, fract) \ 81 ((((guint64)(index)) << 32) + (fract)) 82 83 #define ags_fluid_phase_index(_x) \ 84 ((guint)((_x) >> 32)) 85 #define ags_fluid_phase_fract(_x) \ 86 ((guint32)((_x) & 0xFFFFFFFF)) 87 88 #define ags_fluid_phase_index_round(_x) \ 89 ((guint)(((_x) + 0x80000000) >> 32)) 90 91 #define ags_fluid_phase_fract_to_tablerow(_x) \ 92 ((guint)(ags_fluid_phase_fract(_x) & AGS_FLUID_INTERP_BITS_MASK) >> AGS_FLUID_INTERP_BITS_SHIFT) 93 94 #define ags_fluid_phase_double(_x) \ 95 ((gdouble)(ags_fluid_phase_index(_x)) + ((gdouble)ags_fluid_phase_fract(_x) / AGS_FLUID_FRACT_MAX)) 96 97 #define ags_fluid_phase_incr(a, b) a += b 98 99 #define ags_fluid_phase_decr(a, b) a -= b 100 101 #define ags_fluid_phase_sub_int(a, b) ((a) -= (guint64)(b) << 32) 102 103 #define ags_fluid_phase_index_plusplus(a) (((a) += 0x100000000LL) 104 105 gdouble ags_fluid_ct2hz_real(gdouble cents); 106 gdouble ags_fluid_ct2hz(gdouble cents); 107 108 G_END_DECLS 109 110 #endif /*__AGS_FLUID_UTIL_H__*/ 111