Added Fluidsynth to be used in ScummVM
This commit is contained in:
320
project/jni/fluidsynth/src/utils/fluid_conv.c
Normal file
320
project/jni/fluidsynth/src/utils/fluid_conv.c
Normal file
@@ -0,0 +1,320 @@
|
||||
/* FluidSynth - A Software Synthesizer
|
||||
*
|
||||
* Copyright (C) 2003 Peter Hanappe and others.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "fluid_conv.h"
|
||||
|
||||
|
||||
/* conversion tables */
|
||||
fluid_real_t fluid_ct2hz_tab[FLUID_CENTS_HZ_SIZE];
|
||||
fluid_real_t fluid_cb2amp_tab[FLUID_CB_AMP_SIZE];
|
||||
fluid_real_t fluid_atten2amp_tab[FLUID_ATTEN_AMP_SIZE];
|
||||
fluid_real_t fluid_posbp_tab[128];
|
||||
fluid_real_t fluid_concave_tab[128];
|
||||
fluid_real_t fluid_convex_tab[128];
|
||||
fluid_real_t fluid_pan_tab[FLUID_PAN_SIZE];
|
||||
|
||||
/*
|
||||
* void fluid_synth_init
|
||||
*
|
||||
* Does all the initialization for this module.
|
||||
*/
|
||||
void
|
||||
fluid_conversion_config(void)
|
||||
{
|
||||
int i;
|
||||
double x;
|
||||
|
||||
for (i = 0; i < FLUID_CENTS_HZ_SIZE; i++) {
|
||||
fluid_ct2hz_tab[i] = (fluid_real_t) pow(2.0, (double) i / 1200.0);
|
||||
}
|
||||
|
||||
/* centibels to amplitude conversion
|
||||
* Note: SF2.01 section 8.1.3: Initial attenuation range is
|
||||
* between 0 and 144 dB. Therefore a negative attenuation is
|
||||
* not allowed.
|
||||
*/
|
||||
for (i = 0; i < FLUID_CB_AMP_SIZE; i++) {
|
||||
fluid_cb2amp_tab[i] = (fluid_real_t) pow(10.0, (double) i / -200.0);
|
||||
}
|
||||
|
||||
/* NOTE: EMU8k and EMU10k devices don't conform to the SoundFont
|
||||
* specification in regards to volume attenuation. The below calculation
|
||||
* is an approx. equation for generating a table equivelant to the
|
||||
* cb_to_amp_table[] in tables.c of the TiMidity++ source, which I'm told
|
||||
* was generated from device testing. By the spec this should be centibels.
|
||||
*/
|
||||
for (i = 0; i < FLUID_ATTEN_AMP_SIZE; i++) {
|
||||
fluid_atten2amp_tab[i] = (fluid_real_t) pow(10.0, (double) i / FLUID_ATTEN_POWER_FACTOR);
|
||||
}
|
||||
|
||||
/* initialize the conversion tables (see fluid_mod.c
|
||||
fluid_mod_get_value cases 4 and 8) */
|
||||
|
||||
/* concave unipolar positive transform curve */
|
||||
fluid_concave_tab[0] = 0.0;
|
||||
fluid_concave_tab[127] = 1.0;
|
||||
|
||||
/* convex unipolar positive transform curve */
|
||||
fluid_convex_tab[0] = 0;
|
||||
fluid_convex_tab[127] = 1.0;
|
||||
x = log10(128.0 / 127.0);
|
||||
|
||||
/* There seems to be an error in the specs. The equations are
|
||||
implemented according to the pictures on SF2.01 page 73. */
|
||||
|
||||
for (i = 1; i < 127; i++) {
|
||||
x = -20.0 / 96.0 * log((i * i) / (127.0 * 127.0)) / log(10.0);
|
||||
fluid_convex_tab[i] = (fluid_real_t) (1.0 - x);
|
||||
fluid_concave_tab[127 - i] = (fluid_real_t) x;
|
||||
}
|
||||
|
||||
/* initialize the pan conversion table */
|
||||
x = PI / 2.0 / (FLUID_PAN_SIZE - 1.0);
|
||||
for (i = 0; i < FLUID_PAN_SIZE; i++) {
|
||||
fluid_pan_tab[i] = (fluid_real_t) sin(i * x);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* fluid_ct2hz
|
||||
*/
|
||||
fluid_real_t
|
||||
fluid_ct2hz_real(fluid_real_t cents)
|
||||
{
|
||||
if (cents < 0)
|
||||
return (fluid_real_t) 1.0;
|
||||
else if (cents < 900) {
|
||||
return (fluid_real_t) 6.875 * fluid_ct2hz_tab[(int) (cents + 300)];
|
||||
} else if (cents < 2100) {
|
||||
return (fluid_real_t) 13.75 * fluid_ct2hz_tab[(int) (cents - 900)];
|
||||
} else if (cents < 3300) {
|
||||
return (fluid_real_t) 27.5 * fluid_ct2hz_tab[(int) (cents - 2100)];
|
||||
} else if (cents < 4500) {
|
||||
return (fluid_real_t) 55.0 * fluid_ct2hz_tab[(int) (cents - 3300)];
|
||||
} else if (cents < 5700) {
|
||||
return (fluid_real_t) 110.0 * fluid_ct2hz_tab[(int) (cents - 4500)];
|
||||
} else if (cents < 6900) {
|
||||
return (fluid_real_t) 220.0 * fluid_ct2hz_tab[(int) (cents - 5700)];
|
||||
} else if (cents < 8100) {
|
||||
return (fluid_real_t) 440.0 * fluid_ct2hz_tab[(int) (cents - 6900)];
|
||||
} else if (cents < 9300) {
|
||||
return (fluid_real_t) 880.0 * fluid_ct2hz_tab[(int) (cents - 8100)];
|
||||
} else if (cents < 10500) {
|
||||
return (fluid_real_t) 1760.0 * fluid_ct2hz_tab[(int) (cents - 9300)];
|
||||
} else if (cents < 11700) {
|
||||
return (fluid_real_t) 3520.0 * fluid_ct2hz_tab[(int) (cents - 10500)];
|
||||
} else if (cents < 12900) {
|
||||
return (fluid_real_t) 7040.0 * fluid_ct2hz_tab[(int) (cents - 11700)];
|
||||
} else if (cents < 14100) {
|
||||
return (fluid_real_t) 14080.0 * fluid_ct2hz_tab[(int) (cents - 12900)];
|
||||
} else {
|
||||
return (fluid_real_t) 1.0; /* some loony trying to make you deaf */
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* fluid_ct2hz
|
||||
*/
|
||||
fluid_real_t
|
||||
fluid_ct2hz(fluid_real_t cents)
|
||||
{
|
||||
/* Filter fc limit: SF2.01 page 48 # 8 */
|
||||
if (cents >= 13500){
|
||||
cents = 13500; /* 20 kHz */
|
||||
} else if (cents < 1500){
|
||||
cents = 1500; /* 20 Hz */
|
||||
}
|
||||
return fluid_ct2hz_real(cents);
|
||||
}
|
||||
|
||||
/*
|
||||
* fluid_cb2amp
|
||||
*
|
||||
* in: a value between 0 and 960, 0 is no attenuation
|
||||
* out: a value between 1 and 0
|
||||
*/
|
||||
fluid_real_t
|
||||
fluid_cb2amp(fluid_real_t cb)
|
||||
{
|
||||
/*
|
||||
* cb: an attenuation in 'centibels' (1/10 dB)
|
||||
* SF2.01 page 49 # 48 limits it to 144 dB.
|
||||
* 96 dB is reasonable for 16 bit systems, 144 would make sense for 24 bit.
|
||||
*/
|
||||
|
||||
/* minimum attenuation: 0 dB */
|
||||
if (cb < 0) {
|
||||
return 1.0;
|
||||
}
|
||||
if (cb >= FLUID_CB_AMP_SIZE) {
|
||||
return 0.0;
|
||||
}
|
||||
return fluid_cb2amp_tab[(int) cb];
|
||||
}
|
||||
|
||||
/*
|
||||
* fluid_atten2amp
|
||||
*
|
||||
* in: a value between 0 and 1440, 0 is no attenuation
|
||||
* out: a value between 1 and 0
|
||||
*
|
||||
* Note: Volume attenuation is supposed to be centibels but EMU8k/10k don't
|
||||
* follow this. Thats the reason for separate fluid_cb2amp and fluid_atten2amp.
|
||||
*/
|
||||
fluid_real_t
|
||||
fluid_atten2amp(fluid_real_t atten)
|
||||
{
|
||||
if (atten < 0) return 1.0;
|
||||
else if (atten >= FLUID_ATTEN_AMP_SIZE) return 0.0;
|
||||
else return fluid_atten2amp_tab[(int) atten];
|
||||
}
|
||||
|
||||
/*
|
||||
* fluid_tc2sec_delay
|
||||
*/
|
||||
fluid_real_t
|
||||
fluid_tc2sec_delay(fluid_real_t tc)
|
||||
{
|
||||
/* SF2.01 section 8.1.2 items 21, 23, 25, 33
|
||||
* SF2.01 section 8.1.3 items 21, 23, 25, 33
|
||||
*
|
||||
* The most negative number indicates a delay of 0. Range is limited
|
||||
* from -12000 to 5000 */
|
||||
if (tc <= -32768.0f) {
|
||||
return (fluid_real_t) 0.0f;
|
||||
};
|
||||
if (tc < -12000.) {
|
||||
tc = (fluid_real_t) -12000.0f;
|
||||
}
|
||||
if (tc > 5000.0f) {
|
||||
tc = (fluid_real_t) 5000.0f;
|
||||
}
|
||||
return (fluid_real_t) pow(2.0, (double) tc / 1200.0);
|
||||
}
|
||||
|
||||
/*
|
||||
* fluid_tc2sec_attack
|
||||
*/
|
||||
fluid_real_t
|
||||
fluid_tc2sec_attack(fluid_real_t tc)
|
||||
{
|
||||
/* SF2.01 section 8.1.2 items 26, 34
|
||||
* SF2.01 section 8.1.3 items 26, 34
|
||||
* The most negative number indicates a delay of 0
|
||||
* Range is limited from -12000 to 8000 */
|
||||
if (tc<=-32768.){return (fluid_real_t) 0.0;};
|
||||
if (tc<-12000.){tc=(fluid_real_t) -12000.0;};
|
||||
if (tc>8000.){tc=(fluid_real_t) 8000.0;};
|
||||
return (fluid_real_t) pow(2.0, (double) tc / 1200.0);
|
||||
}
|
||||
|
||||
/*
|
||||
* fluid_tc2sec
|
||||
*/
|
||||
fluid_real_t
|
||||
fluid_tc2sec(fluid_real_t tc)
|
||||
{
|
||||
/* No range checking here! */
|
||||
return (fluid_real_t) pow(2.0, (double) tc / 1200.0);
|
||||
}
|
||||
|
||||
/*
|
||||
* fluid_tc2sec_release
|
||||
*/
|
||||
fluid_real_t
|
||||
fluid_tc2sec_release(fluid_real_t tc)
|
||||
{
|
||||
/* SF2.01 section 8.1.2 items 30, 38
|
||||
* SF2.01 section 8.1.3 items 30, 38
|
||||
* No 'most negative number' rule here!
|
||||
* Range is limited from -12000 to 8000 */
|
||||
if (tc<=-32768.){return (fluid_real_t) 0.0;};
|
||||
if (tc<-12000.){tc=(fluid_real_t) -12000.0;};
|
||||
if (tc>8000.){tc=(fluid_real_t) 8000.0;};
|
||||
return (fluid_real_t) pow(2.0, (double) tc / 1200.0);
|
||||
}
|
||||
|
||||
/*
|
||||
* fluid_act2hz
|
||||
*
|
||||
* Convert from absolute cents to Hertz
|
||||
*/
|
||||
fluid_real_t
|
||||
fluid_act2hz(fluid_real_t c)
|
||||
{
|
||||
return (fluid_real_t) (8.176 * pow(2.0, (double) c / 1200.0));
|
||||
}
|
||||
|
||||
/*
|
||||
* fluid_hz2ct
|
||||
*
|
||||
* Convert from Hertz to cents
|
||||
*/
|
||||
fluid_real_t
|
||||
fluid_hz2ct(fluid_real_t f)
|
||||
{
|
||||
return (fluid_real_t) (6900 + 1200 * log(f / 440.0) / log(2.0));
|
||||
}
|
||||
|
||||
/*
|
||||
* fluid_pan
|
||||
*/
|
||||
fluid_real_t
|
||||
fluid_pan(fluid_real_t c, int left)
|
||||
{
|
||||
if (left) {
|
||||
c = -c;
|
||||
}
|
||||
if (c < -500) {
|
||||
return (fluid_real_t) 0.0;
|
||||
} else if (c > 500) {
|
||||
return (fluid_real_t) 1.0;
|
||||
} else {
|
||||
return fluid_pan_tab[(int) (c + 500)];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* fluid_concave
|
||||
*/
|
||||
fluid_real_t
|
||||
fluid_concave(fluid_real_t val)
|
||||
{
|
||||
if (val < 0) {
|
||||
return 0;
|
||||
} else if (val > 127) {
|
||||
return 1;
|
||||
}
|
||||
return fluid_concave_tab[(int) val];
|
||||
}
|
||||
|
||||
/*
|
||||
* fluid_convex
|
||||
*/
|
||||
fluid_real_t
|
||||
fluid_convex(fluid_real_t val)
|
||||
{
|
||||
if (val < 0) {
|
||||
return 0;
|
||||
} else if (val > 127) {
|
||||
return 1;
|
||||
}
|
||||
return fluid_convex_tab[(int) val];
|
||||
}
|
||||
63
project/jni/fluidsynth/src/utils/fluid_conv.h
Normal file
63
project/jni/fluidsynth/src/utils/fluid_conv.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/* FluidSynth - A Software Synthesizer
|
||||
*
|
||||
* Copyright (C) 2003 Peter Hanappe and others.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307, USA
|
||||
*/
|
||||
|
||||
#ifndef _FLUID_CONV_H
|
||||
#define _FLUID_CONV_H
|
||||
|
||||
#include "fluidsynth_priv.h"
|
||||
|
||||
#define FLUID_CENTS_HZ_SIZE 1200
|
||||
#define FLUID_VEL_CB_SIZE 128
|
||||
#define FLUID_CB_AMP_SIZE 961
|
||||
#define FLUID_ATTEN_AMP_SIZE 1441
|
||||
#define FLUID_PAN_SIZE 1002
|
||||
|
||||
/* EMU 8k/10k don't follow spec in regards to volume attenuation.
|
||||
* This factor is used in the equation pow (10.0, cb / FLUID_ATTEN_POWER_FACTOR).
|
||||
* By the standard this should be -200.0. */
|
||||
/* 07/11/2008 modified by S. Christian Collins for increased velocity sensitivity. Now it equals the response of EMU10K1 programming.*/
|
||||
#define FLUID_ATTEN_POWER_FACTOR (-200.0) /* was (-531.509)*/
|
||||
|
||||
void fluid_conversion_config(void);
|
||||
|
||||
fluid_real_t fluid_ct2hz_real(fluid_real_t cents);
|
||||
fluid_real_t fluid_ct2hz(fluid_real_t cents);
|
||||
fluid_real_t fluid_cb2amp(fluid_real_t cb);
|
||||
fluid_real_t fluid_atten2amp(fluid_real_t atten);
|
||||
fluid_real_t fluid_tc2sec(fluid_real_t tc);
|
||||
fluid_real_t fluid_tc2sec_delay(fluid_real_t tc);
|
||||
fluid_real_t fluid_tc2sec_attack(fluid_real_t tc);
|
||||
fluid_real_t fluid_tc2sec_release(fluid_real_t tc);
|
||||
fluid_real_t fluid_act2hz(fluid_real_t c);
|
||||
fluid_real_t fluid_hz2ct(fluid_real_t c);
|
||||
fluid_real_t fluid_pan(fluid_real_t c, int left);
|
||||
fluid_real_t fluid_concave(fluid_real_t val);
|
||||
fluid_real_t fluid_convex(fluid_real_t val);
|
||||
|
||||
extern fluid_real_t fluid_ct2hz_tab[FLUID_CENTS_HZ_SIZE];
|
||||
extern fluid_real_t fluid_vel2cb_tab[FLUID_VEL_CB_SIZE];
|
||||
extern fluid_real_t fluid_cb2amp_tab[FLUID_CB_AMP_SIZE];
|
||||
extern fluid_real_t fluid_posbp_tab[128];
|
||||
extern fluid_real_t fluid_concave_tab[128];
|
||||
extern fluid_real_t fluid_convex_tab[128];
|
||||
extern fluid_real_t fluid_pan_tab[FLUID_PAN_SIZE];
|
||||
|
||||
|
||||
#endif /* _FLUID_CONV_H */
|
||||
1308
project/jni/fluidsynth/src/utils/fluid_hash.c
Normal file
1308
project/jni/fluidsynth/src/utils/fluid_hash.c
Normal file
File diff suppressed because it is too large
Load Diff
131
project/jni/fluidsynth/src/utils/fluid_hash.h
Normal file
131
project/jni/fluidsynth/src/utils/fluid_hash.h
Normal file
@@ -0,0 +1,131 @@
|
||||
/* GLIB - Library of useful routines for C programming
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modified by the GLib Team and others 1997-2000. See the AUTHORS
|
||||
* file for a list of people on the GLib Team. See the ChangeLog
|
||||
* files for a list of changes. These files are distributed with
|
||||
* GLib at ftp://ftp.gtk.org/pub/gtk/.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Adapted for FluidSynth use by Josh Green <jgreen@users.sourceforge.net>
|
||||
* September 8, 2009 from glib 2.18.4
|
||||
*
|
||||
* - Self contained (no dependencies on glib)
|
||||
* - changed names to fluid_hashtable_...
|
||||
*/
|
||||
|
||||
#ifndef _FLUID_HASH_H
|
||||
#define _FLUID_HASH_H
|
||||
|
||||
#include "fluidsynth_priv.h"
|
||||
#include "fluid_list.h"
|
||||
#include "fluid_sys.h"
|
||||
|
||||
/* Extracted from gtypes.h */
|
||||
typedef void (*fluid_destroy_notify_t)(void *data);
|
||||
typedef unsigned int (*fluid_hash_func_t)(const void *key);
|
||||
typedef int (*fluid_equal_func_t)(const void *a, const void *b);
|
||||
/* End gtypes.h extraction */
|
||||
|
||||
typedef int (*fluid_hr_func_t)(void *key, void *value, void *user_data);
|
||||
typedef struct _fluid_hashtable_iter_t fluid_hashtable_iter_t;
|
||||
|
||||
typedef struct _fluid_hashnode_t fluid_hashnode_t;
|
||||
|
||||
struct _fluid_hashnode_t
|
||||
{
|
||||
void *key;
|
||||
void *value;
|
||||
fluid_hashnode_t *next;
|
||||
unsigned int key_hash;
|
||||
};
|
||||
|
||||
struct _fluid_hashtable_t
|
||||
{
|
||||
int size;
|
||||
int nnodes;
|
||||
fluid_hashnode_t **nodes;
|
||||
fluid_hash_func_t hash_func;
|
||||
fluid_equal_func_t key_equal_func;
|
||||
volatile int ref_count;
|
||||
fluid_destroy_notify_t key_destroy_func;
|
||||
fluid_destroy_notify_t value_destroy_func;
|
||||
//fluid_rec_mutex_t mutex; // Optionally used in other modules (fluid_settings.c for example)
|
||||
};
|
||||
|
||||
struct _fluid_hashtable_iter_t
|
||||
{
|
||||
/*< private >*/
|
||||
void * dummy1;
|
||||
void * dummy2;
|
||||
void * dummy3;
|
||||
int dummy4;
|
||||
int dummy5; // Bool
|
||||
void * dummy6;
|
||||
};
|
||||
|
||||
fluid_hashtable_t* new_fluid_hashtable (fluid_hash_func_t hash_func,
|
||||
fluid_equal_func_t key_equal_func);
|
||||
fluid_hashtable_t* new_fluid_hashtable_full (fluid_hash_func_t hash_func,
|
||||
fluid_equal_func_t key_equal_func,
|
||||
fluid_destroy_notify_t key_destroy_func,
|
||||
fluid_destroy_notify_t value_destroy_func);
|
||||
void delete_fluid_hashtable(fluid_hashtable_t *hashtable);
|
||||
|
||||
void fluid_hashtable_iter_init (fluid_hashtable_iter_t *iter, fluid_hashtable_t *hashtable);
|
||||
int fluid_hashtable_iter_next (fluid_hashtable_iter_t *iter, void **key, void **value);
|
||||
fluid_hashtable_t *fluid_hashtable_iter_get_hash_table (fluid_hashtable_iter_t *iter);
|
||||
void fluid_hashtable_iter_remove (fluid_hashtable_iter_t *iter);
|
||||
void fluid_hashtable_iter_steal (fluid_hashtable_iter_t *iter);
|
||||
|
||||
fluid_hashtable_t* fluid_hashtable_ref (fluid_hashtable_t *hashtable);
|
||||
void fluid_hashtable_unref (fluid_hashtable_t *hashtable);
|
||||
|
||||
void *fluid_hashtable_lookup (fluid_hashtable_t *hashtable, const void *key);
|
||||
int fluid_hashtable_lookup_extended (fluid_hashtable_t *hashtable, const void *lookup_key,
|
||||
void **orig_key, void **value);
|
||||
|
||||
void fluid_hashtable_insert (fluid_hashtable_t *hashtable, void *key, void *value);
|
||||
void fluid_hashtable_replace (fluid_hashtable_t *hashtable, void *key, void *value);
|
||||
|
||||
int fluid_hashtable_remove (fluid_hashtable_t *hashtable, const void *key);
|
||||
int fluid_hashtable_steal (fluid_hashtable_t *hashtable, const void *key);
|
||||
void fluid_hashtable_remove_all (fluid_hashtable_t *hashtable);
|
||||
void fluid_hashtable_steal_all (fluid_hashtable_t *hashtable);
|
||||
unsigned int fluid_hashtable_foreach_steal (fluid_hashtable_t *hashtable,
|
||||
fluid_hr_func_t func, void *user_data);
|
||||
void fluid_hashtable_foreach (fluid_hashtable_t *hashtable, fluid_hr_func_t func,
|
||||
void *user_data);
|
||||
void *fluid_hashtable_find (fluid_hashtable_t *hashtable, fluid_hr_func_t predicate,
|
||||
void *user_data);
|
||||
unsigned int fluid_hashtable_size (fluid_hashtable_t *hashtable);
|
||||
fluid_list_t *fluid_hashtable_get_keys (fluid_hashtable_t *hashtable);
|
||||
fluid_list_t *fluid_hashtable_get_values (fluid_hashtable_t *hashtable);
|
||||
|
||||
int fluid_str_equal (const void *v1, const void *v2);
|
||||
unsigned int fluid_str_hash (const void *v);
|
||||
int fluid_direct_equal (const void *v1, const void *v2);
|
||||
unsigned int fluid_direct_hash (const void *v);
|
||||
int fluid_int_equal (const void *v1, const void *v2);
|
||||
unsigned int fluid_int_hash (const void *v);
|
||||
|
||||
#endif /* _FLUID_HASH_H */
|
||||
|
||||
268
project/jni/fluidsynth/src/utils/fluid_list.c
Normal file
268
project/jni/fluidsynth/src/utils/fluid_list.c
Normal file
@@ -0,0 +1,268 @@
|
||||
/* GLIB - Library of useful routines for C programming
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modified by the GLib Team and others 1997-1999. See the AUTHORS
|
||||
* file for a list of people on the GLib Team. See the ChangeLog
|
||||
* files for a list of changes. These files are distributed with
|
||||
* GLib at ftp://ftp.gtk.org/pub/gtk/.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "fluid_list.h"
|
||||
|
||||
|
||||
fluid_list_t*
|
||||
new_fluid_list(void)
|
||||
{
|
||||
fluid_list_t* list;
|
||||
list = (fluid_list_t*) FLUID_MALLOC(sizeof(fluid_list_t));
|
||||
list->data = NULL;
|
||||
list->next = NULL;
|
||||
return list;
|
||||
}
|
||||
|
||||
void
|
||||
delete_fluid_list(fluid_list_t *list)
|
||||
{
|
||||
fluid_list_t *next;
|
||||
while (list) {
|
||||
next = list->next;
|
||||
FLUID_FREE(list);
|
||||
list = next;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
delete1_fluid_list(fluid_list_t *list)
|
||||
{
|
||||
if (list) {
|
||||
FLUID_FREE(list);
|
||||
}
|
||||
}
|
||||
|
||||
fluid_list_t*
|
||||
fluid_list_append(fluid_list_t *list, void* data)
|
||||
{
|
||||
fluid_list_t *new_list;
|
||||
fluid_list_t *last;
|
||||
|
||||
new_list = new_fluid_list();
|
||||
new_list->data = data;
|
||||
|
||||
if (list)
|
||||
{
|
||||
last = fluid_list_last(list);
|
||||
/* g_assert (last != NULL); */
|
||||
last->next = new_list;
|
||||
|
||||
return list;
|
||||
}
|
||||
else
|
||||
return new_list;
|
||||
}
|
||||
|
||||
fluid_list_t*
|
||||
fluid_list_prepend(fluid_list_t *list, void* data)
|
||||
{
|
||||
fluid_list_t *new_list;
|
||||
|
||||
new_list = new_fluid_list();
|
||||
new_list->data = data;
|
||||
new_list->next = list;
|
||||
|
||||
return new_list;
|
||||
}
|
||||
|
||||
fluid_list_t*
|
||||
fluid_list_nth(fluid_list_t *list, int n)
|
||||
{
|
||||
while ((n-- > 0) && list) {
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
fluid_list_t*
|
||||
fluid_list_remove(fluid_list_t *list, void* data)
|
||||
{
|
||||
fluid_list_t *tmp;
|
||||
fluid_list_t *prev;
|
||||
|
||||
prev = NULL;
|
||||
tmp = list;
|
||||
|
||||
while (tmp) {
|
||||
if (tmp->data == data) {
|
||||
if (prev) {
|
||||
prev->next = tmp->next;
|
||||
}
|
||||
if (list == tmp) {
|
||||
list = list->next;
|
||||
}
|
||||
tmp->next = NULL;
|
||||
delete_fluid_list(tmp);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
prev = tmp;
|
||||
tmp = tmp->next;
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
fluid_list_t*
|
||||
fluid_list_remove_link(fluid_list_t *list, fluid_list_t *link)
|
||||
{
|
||||
fluid_list_t *tmp;
|
||||
fluid_list_t *prev;
|
||||
|
||||
prev = NULL;
|
||||
tmp = list;
|
||||
|
||||
while (tmp) {
|
||||
if (tmp == link) {
|
||||
if (prev) {
|
||||
prev->next = tmp->next;
|
||||
}
|
||||
if (list == tmp) {
|
||||
list = list->next;
|
||||
}
|
||||
tmp->next = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
prev = tmp;
|
||||
tmp = tmp->next;
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static fluid_list_t*
|
||||
fluid_list_sort_merge(fluid_list_t *l1, fluid_list_t *l2, fluid_compare_func_t compare_func)
|
||||
{
|
||||
fluid_list_t list, *l;
|
||||
|
||||
l = &list;
|
||||
|
||||
while (l1 && l2) {
|
||||
if (compare_func(l1->data,l2->data) < 0) {
|
||||
l = l->next = l1;
|
||||
l1 = l1->next;
|
||||
} else {
|
||||
l = l->next = l2;
|
||||
l2 = l2->next;
|
||||
}
|
||||
}
|
||||
l->next= l1 ? l1 : l2;
|
||||
|
||||
return list.next;
|
||||
}
|
||||
|
||||
fluid_list_t*
|
||||
fluid_list_sort(fluid_list_t *list, fluid_compare_func_t compare_func)
|
||||
{
|
||||
fluid_list_t *l1, *l2;
|
||||
|
||||
if (!list) {
|
||||
return NULL;
|
||||
}
|
||||
if (!list->next) {
|
||||
return list;
|
||||
}
|
||||
|
||||
l1 = list;
|
||||
l2 = list->next;
|
||||
|
||||
while ((l2 = l2->next) != NULL) {
|
||||
if ((l2 = l2->next) == NULL)
|
||||
break;
|
||||
l1=l1->next;
|
||||
}
|
||||
l2 = l1->next;
|
||||
l1->next = NULL;
|
||||
|
||||
return fluid_list_sort_merge(fluid_list_sort(list, compare_func),
|
||||
fluid_list_sort(l2, compare_func),
|
||||
compare_func);
|
||||
}
|
||||
|
||||
|
||||
fluid_list_t*
|
||||
fluid_list_last(fluid_list_t *list)
|
||||
{
|
||||
if (list) {
|
||||
while (list->next)
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
int
|
||||
fluid_list_size(fluid_list_t *list)
|
||||
{
|
||||
int n = 0;
|
||||
while (list) {
|
||||
n++;
|
||||
list = list->next;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
fluid_list_t* fluid_list_insert_at(fluid_list_t *list, int n, void* data)
|
||||
{
|
||||
fluid_list_t *new_list;
|
||||
fluid_list_t *cur;
|
||||
fluid_list_t *prev = NULL;
|
||||
|
||||
new_list = new_fluid_list();
|
||||
new_list->data = data;
|
||||
|
||||
cur = list;
|
||||
while ((n-- > 0) && cur) {
|
||||
prev = cur;
|
||||
cur = cur->next;
|
||||
}
|
||||
|
||||
new_list->next = cur;
|
||||
|
||||
if (prev) {
|
||||
prev->next = new_list;
|
||||
return list;
|
||||
} else {
|
||||
return new_list;
|
||||
}
|
||||
}
|
||||
|
||||
/* Compare function to sort strings alphabetically,
|
||||
* for use with fluid_list_sort(). */
|
||||
int
|
||||
fluid_list_str_compare_func (void *a, void *b)
|
||||
{
|
||||
if (a && b) return FLUID_STRCMP ((char *)a, (char *)b);
|
||||
if (!a && !b) return 0;
|
||||
if (a) return -1;
|
||||
return 1;
|
||||
}
|
||||
62
project/jni/fluidsynth/src/utils/fluid_list.h
Normal file
62
project/jni/fluidsynth/src/utils/fluid_list.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/* GLIB - Library of useful routines for C programming
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _FLUID_LIST_H
|
||||
#define _FLUID_LIST_H
|
||||
|
||||
#include "fluidsynth_priv.h"
|
||||
|
||||
/*
|
||||
*
|
||||
* Lists
|
||||
*
|
||||
* A sound font loader has to pack the data from the .SF2 file into
|
||||
* list structures of this type.
|
||||
*
|
||||
*/
|
||||
|
||||
typedef struct _fluid_list_t fluid_list_t;
|
||||
|
||||
typedef int (*fluid_compare_func_t)(void* a, void* b);
|
||||
|
||||
struct _fluid_list_t
|
||||
{
|
||||
void* data;
|
||||
fluid_list_t *next;
|
||||
};
|
||||
|
||||
fluid_list_t* new_fluid_list(void);
|
||||
void delete_fluid_list(fluid_list_t *list);
|
||||
void delete1_fluid_list(fluid_list_t *list);
|
||||
fluid_list_t* fluid_list_sort(fluid_list_t *list, fluid_compare_func_t compare_func);
|
||||
fluid_list_t* fluid_list_append(fluid_list_t *list, void* data);
|
||||
fluid_list_t* fluid_list_prepend(fluid_list_t *list, void* data);
|
||||
fluid_list_t* fluid_list_remove(fluid_list_t *list, void* data);
|
||||
fluid_list_t* fluid_list_remove_link(fluid_list_t *list, fluid_list_t *llink);
|
||||
fluid_list_t* fluid_list_nth(fluid_list_t *list, int n);
|
||||
fluid_list_t* fluid_list_last(fluid_list_t *list);
|
||||
fluid_list_t* fluid_list_insert_at(fluid_list_t *list, int n, void* data);
|
||||
int fluid_list_size(fluid_list_t *list);
|
||||
|
||||
#define fluid_list_next(slist) ((slist) ? (((fluid_list_t *)(slist))->next) : NULL)
|
||||
#define fluid_list_get(slist) ((slist) ? ((slist)->data) : NULL)
|
||||
|
||||
int fluid_list_str_compare_func (void *a, void *b);
|
||||
|
||||
#endif /* _FLUID_LIST_H */
|
||||
89
project/jni/fluidsynth/src/utils/fluid_ringbuffer.c
Normal file
89
project/jni/fluidsynth/src/utils/fluid_ringbuffer.c
Normal file
@@ -0,0 +1,89 @@
|
||||
/* FluidSynth - A Software Synthesizer
|
||||
*
|
||||
* Copyright (C) 2003 Peter Hanappe and others.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307, USA
|
||||
*/
|
||||
|
||||
/*
|
||||
* Josh Green <josh@resonance.org>
|
||||
* 2009-05-28
|
||||
*/
|
||||
|
||||
#include "fluid_ringbuffer.h"
|
||||
#include "fluidsynth_priv.h"
|
||||
|
||||
|
||||
/**
|
||||
* Create a lock free queue with a fixed maximum count and size of elements.
|
||||
* @param count Count of elements in queue (fixed max number of queued elements)
|
||||
* @return New lock free queue or NULL if out of memory (error message logged)
|
||||
*
|
||||
* Lockless FIFO queues don't use any locking mechanisms and can therefore be
|
||||
* advantageous in certain situations, such as passing data between a lower
|
||||
* priority thread and a higher "real time" thread, without potential lock
|
||||
* contention which could stall the high priority thread. Note that there may
|
||||
* only be one producer thread and one consumer thread.
|
||||
*/
|
||||
fluid_ringbuffer_t *
|
||||
new_fluid_ringbuffer (int count, int elementsize)
|
||||
{
|
||||
fluid_ringbuffer_t *queue;
|
||||
|
||||
fluid_return_val_if_fail (count > 0, NULL);
|
||||
|
||||
queue = FLUID_NEW (fluid_ringbuffer_t);
|
||||
|
||||
if (!queue)
|
||||
{
|
||||
FLUID_LOG (FLUID_ERR, "Out of memory");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
queue->array = FLUID_MALLOC (elementsize * count);
|
||||
|
||||
if (!queue->array)
|
||||
{
|
||||
FLUID_FREE (queue);
|
||||
FLUID_LOG (FLUID_ERR, "Out of memory");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Clear array, in case dynamic pointer reclaiming is being done */
|
||||
FLUID_MEMSET (queue->array, 0, elementsize * count);
|
||||
|
||||
queue->totalcount = count;
|
||||
queue->elementsize = elementsize;
|
||||
queue->count = 0;
|
||||
queue->in = 0;
|
||||
queue->out = 0;
|
||||
|
||||
return (queue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Free an event queue.
|
||||
* @param queue Lockless queue instance
|
||||
*
|
||||
* Care must be taken when freeing a queue, to ensure that the consumer and
|
||||
* producer threads will no longer access it.
|
||||
*/
|
||||
void
|
||||
delete_fluid_ringbuffer (fluid_ringbuffer_t *queue)
|
||||
{
|
||||
FLUID_FREE (queue->array);
|
||||
FLUID_FREE (queue);
|
||||
}
|
||||
128
project/jni/fluidsynth/src/utils/fluid_ringbuffer.h
Normal file
128
project/jni/fluidsynth/src/utils/fluid_ringbuffer.h
Normal file
@@ -0,0 +1,128 @@
|
||||
/* FluidSynth - A Software Synthesizer
|
||||
*
|
||||
* Copyright (C) 2003 Peter Hanappe and others.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307, USA
|
||||
*/
|
||||
|
||||
#ifndef _FLUID_RINGBUFFER_H
|
||||
#define _FLUID_RINGBUFFER_H
|
||||
|
||||
#include "fluid_sys.h"
|
||||
|
||||
/**
|
||||
* Lockless event queue instance.
|
||||
*/
|
||||
struct _fluid_ringbuffer_t
|
||||
{
|
||||
char *array; /**< Queue array of arbitrary size elements */
|
||||
int totalcount; /**< Total count of elements in array */
|
||||
int count; /**< Current count of elements */
|
||||
int in; /**< Index in queue to store next pushed element */
|
||||
int out; /**< Index in queue of next popped element */
|
||||
int elementsize; /**< Size of each element */
|
||||
void* userdata;
|
||||
};
|
||||
|
||||
typedef struct _fluid_ringbuffer_t fluid_ringbuffer_t;
|
||||
|
||||
|
||||
fluid_ringbuffer_t *new_fluid_ringbuffer (int count, int elementsize);
|
||||
void delete_fluid_ringbuffer (fluid_ringbuffer_t *queue);
|
||||
|
||||
/**
|
||||
* Get pointer to next input array element in queue.
|
||||
* @param queue Lockless queue instance
|
||||
* @param count Normally zero, or more if you need to push several items at once
|
||||
* @return Pointer to array element in queue to store data to or NULL if queue is full
|
||||
*
|
||||
* This function along with fluid_ringbuffer_next_inptr() form a queue "push"
|
||||
* operation and is split into 2 functions to avoid an element copy. Note that
|
||||
* the returned array element pointer may contain the data of a previous element
|
||||
* if the queue has wrapped around. This can be used to reclaim pointers to
|
||||
* allocated memory, etc.
|
||||
*/
|
||||
static FLUID_INLINE void*
|
||||
fluid_ringbuffer_get_inptr (fluid_ringbuffer_t *queue, int offset)
|
||||
{
|
||||
return fluid_atomic_int_get (&queue->count) + offset >= queue->totalcount ? NULL
|
||||
: queue->array + queue->elementsize * ((queue->in + offset) % queue->totalcount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Advance the input queue index to complete a "push" operation.
|
||||
* @param queue Lockless queue instance
|
||||
* @param count Normally one, or more if you need to push several items at once
|
||||
*
|
||||
* This function along with fluid_ringbuffer_get_inptr() form a queue "push"
|
||||
* operation and is split into 2 functions to avoid element copy.
|
||||
*/
|
||||
static FLUID_INLINE void
|
||||
fluid_ringbuffer_next_inptr (fluid_ringbuffer_t *queue, int count)
|
||||
{
|
||||
fluid_atomic_int_add (&queue->count, count);
|
||||
|
||||
queue->in += count;
|
||||
if (queue->in >= queue->totalcount)
|
||||
queue->in -= queue->totalcount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get amount of items currently in queue
|
||||
* @param queue Lockless queue instance
|
||||
* @return amount of items currently in queue
|
||||
*/
|
||||
static FLUID_INLINE int
|
||||
fluid_ringbuffer_get_count (fluid_ringbuffer_t *queue)
|
||||
{
|
||||
return fluid_atomic_int_get (&queue->count);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get pointer to next output array element in queue.
|
||||
* @param queue Lockless queue instance
|
||||
* @return Pointer to array element data in the queue or NULL if empty, can only
|
||||
* be used up until fluid_ringbuffer_next_outptr() is called.
|
||||
*
|
||||
* This function along with fluid_ringbuffer_next_outptr() form a queue "pop"
|
||||
* operation and is split into 2 functions to avoid an element copy.
|
||||
*/
|
||||
static FLUID_INLINE void*
|
||||
fluid_ringbuffer_get_outptr (fluid_ringbuffer_t *queue)
|
||||
{
|
||||
return fluid_ringbuffer_get_count(queue) == 0 ? NULL
|
||||
: queue->array + queue->elementsize * queue->out;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Advance the output queue index to complete a "pop" operation.
|
||||
* @param queue Lockless queue instance
|
||||
*
|
||||
* This function along with fluid_ringbuffer_get_outptr() form a queue "pop"
|
||||
* operation and is split into 2 functions to avoid an element copy.
|
||||
*/
|
||||
static FLUID_INLINE void
|
||||
fluid_ringbuffer_next_outptr (fluid_ringbuffer_t *queue)
|
||||
{
|
||||
fluid_atomic_int_add (&queue->count, -1);
|
||||
|
||||
if (++queue->out == queue->totalcount)
|
||||
queue->out = 0;
|
||||
}
|
||||
|
||||
#endif /* _FLUID_ringbuffer_H */
|
||||
1573
project/jni/fluidsynth/src/utils/fluid_settings.c
Normal file
1573
project/jni/fluidsynth/src/utils/fluid_settings.c
Normal file
File diff suppressed because it is too large
Load Diff
56
project/jni/fluidsynth/src/utils/fluid_settings.h
Normal file
56
project/jni/fluidsynth/src/utils/fluid_settings.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/* FluidSynth - A Software Synthesizer
|
||||
*
|
||||
* Copyright (C) 2003 Peter Hanappe and others.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _FLUID_SETTINGS_H
|
||||
#define _FLUID_SETTINGS_H
|
||||
|
||||
|
||||
|
||||
/** returns 1 if the option was added, 0 otherwise */
|
||||
int fluid_settings_add_option(fluid_settings_t* settings, const char* name, const char* s);
|
||||
|
||||
/** returns 1 if the option was added, 0 otherwise */
|
||||
int fluid_settings_remove_option(fluid_settings_t* settings, const char* name, const char* s);
|
||||
|
||||
|
||||
typedef int (*fluid_num_update_t)(void* data, const char* name, double value);
|
||||
typedef int (*fluid_str_update_t)(void* data, const char* name, const char* value);
|
||||
typedef int (*fluid_int_update_t)(void* data, const char* name, int value);
|
||||
|
||||
/** returns 0 if the value has been registered correctly, non-zero
|
||||
otherwise */
|
||||
int fluid_settings_register_str(fluid_settings_t* settings, char* name, char* def, int hints,
|
||||
fluid_str_update_t fun, void* data);
|
||||
|
||||
/** returns 0 if the value has been registered correctly, non-zero
|
||||
otherwise */
|
||||
int fluid_settings_register_num(fluid_settings_t* settings, char* name, double def,
|
||||
double min, double max, int hints,
|
||||
fluid_num_update_t fun, void* data);
|
||||
|
||||
/** returns 0 if the value has been registered correctly, non-zero
|
||||
otherwise */
|
||||
int fluid_settings_register_int(fluid_settings_t* settings, char* name, int def,
|
||||
int min, int max, int hints,
|
||||
fluid_int_update_t fun, void* data);
|
||||
|
||||
|
||||
#endif /* _FLUID_SETTINGS_H */
|
||||
378
project/jni/fluidsynth/src/utils/fluid_sys.c
Normal file
378
project/jni/fluidsynth/src/utils/fluid_sys.c
Normal file
@@ -0,0 +1,378 @@
|
||||
/* FluidSynth - A Software Synthesizer
|
||||
*
|
||||
* Copyright (C) 2003 Peter Hanappe and others.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "fluid_sys.h"
|
||||
|
||||
#if WITH_READLINE
|
||||
#include <readline/readline.h>
|
||||
#include <readline/history.h>
|
||||
#endif
|
||||
|
||||
#ifdef DBUS_SUPPORT
|
||||
#include "fluid_rtkit.h"
|
||||
#endif
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
||||
/* WIN32 HACK - Flag used to differentiate between a file descriptor and a socket.
|
||||
* Should work, so long as no SOCKET or file descriptor ends up with this bit set. - JG */
|
||||
#define WIN32_SOCKET_FLAG 0x40000000
|
||||
|
||||
/* SCHED_FIFO priority for high priority timer threads */
|
||||
#define FLUID_SYS_TIMER_HIGH_PRIO_LEVEL 10
|
||||
|
||||
|
||||
struct _fluid_timer_t
|
||||
{
|
||||
long msec;
|
||||
fluid_timer_callback_t callback;
|
||||
void *data;
|
||||
//fluid_thread_t *thread;
|
||||
int cont;
|
||||
int auto_destroy;
|
||||
};
|
||||
|
||||
|
||||
|
||||
void fluid_sys_config()
|
||||
{
|
||||
//fluid_log_config();
|
||||
}
|
||||
|
||||
|
||||
unsigned int fluid_debug_flags = 0;
|
||||
|
||||
#if DEBUG
|
||||
/*
|
||||
* fluid_debug
|
||||
*/
|
||||
int fluid_debug(int level, char * fmt, ...)
|
||||
{
|
||||
if (fluid_debug_flags & level) {
|
||||
fluid_log_function_t fun;
|
||||
va_list args;
|
||||
|
||||
va_start (args, fmt);
|
||||
vsnprintf(fluid_errbuf, sizeof (fluid_errbuf), fmt, args);
|
||||
va_end (args);
|
||||
|
||||
fun = fluid_log_function[FLUID_DBG];
|
||||
if (fun != NULL) {
|
||||
(*fun)(level, fluid_errbuf, fluid_log_user_data[FLUID_DBG]);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
/**
|
||||
* Installs a new log function for a specified log level.
|
||||
* @param level Log level to install handler for.
|
||||
* @param fun Callback function handler to call for logged messages
|
||||
* @param data User supplied data pointer to pass to log function
|
||||
* @return The previously installed function.
|
||||
*/
|
||||
fluid_log_function_t
|
||||
fluid_set_log_function(int level, fluid_log_function_t fun, void* data)
|
||||
{
|
||||
fluid_log_function_t old = NULL;
|
||||
|
||||
if ((level >= 0) && (level < LAST_LOG_LEVEL)) {
|
||||
old = fluid_log_function[level];
|
||||
fluid_log_function[level] = fun;
|
||||
fluid_log_user_data[level] = data;
|
||||
}
|
||||
return old;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default log function which prints to the stderr.
|
||||
* @param level Log level
|
||||
* @param message Log message
|
||||
* @param data User supplied data (not used)
|
||||
*/
|
||||
void
|
||||
fluid_default_log_function(int level, char* message, void* data)
|
||||
{
|
||||
FILE* out;
|
||||
|
||||
#if defined(WIN32)
|
||||
out = stdout;
|
||||
#else
|
||||
out = stderr;
|
||||
#endif
|
||||
|
||||
if (fluid_log_initialized == 0) {
|
||||
fluid_log_config();
|
||||
}
|
||||
|
||||
switch (level) {
|
||||
case FLUID_PANIC:
|
||||
FLUID_FPRINTF(out, "%s: panic: %s\n", fluid_libname, message);
|
||||
break;
|
||||
case FLUID_ERR:
|
||||
FLUID_FPRINTF(out, "%s: error: %s\n", fluid_libname, message);
|
||||
break;
|
||||
case FLUID_WARN:
|
||||
FLUID_FPRINTF(out, "%s: warning: %s\n", fluid_libname, message);
|
||||
break;
|
||||
case FLUID_INFO:
|
||||
FLUID_FPRINTF(out, "%s: %s\n", fluid_libname, message);
|
||||
break;
|
||||
case FLUID_DBG:
|
||||
#if DEBUG
|
||||
FLUID_FPRINTF(out, "%s: debug: %s\n", fluid_libname, message);
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
FLUID_FPRINTF(out, "%s: %s\n", fluid_libname, message);
|
||||
break;
|
||||
}
|
||||
fflush(out);
|
||||
}
|
||||
|
||||
/*
|
||||
* fluid_init_log
|
||||
*/
|
||||
void
|
||||
fluid_log_config(void)
|
||||
{
|
||||
if (fluid_log_initialized == 0) {
|
||||
|
||||
fluid_log_initialized = 1;
|
||||
|
||||
if (fluid_log_function[FLUID_PANIC] == NULL) {
|
||||
fluid_set_log_function(FLUID_PANIC, fluid_default_log_function, NULL);
|
||||
}
|
||||
|
||||
if (fluid_log_function[FLUID_ERR] == NULL) {
|
||||
fluid_set_log_function(FLUID_ERR, fluid_default_log_function, NULL);
|
||||
}
|
||||
|
||||
if (fluid_log_function[FLUID_WARN] == NULL) {
|
||||
fluid_set_log_function(FLUID_WARN, fluid_default_log_function, NULL);
|
||||
}
|
||||
|
||||
if (fluid_log_function[FLUID_INFO] == NULL) {
|
||||
fluid_set_log_function(FLUID_INFO, fluid_default_log_function, NULL);
|
||||
}
|
||||
|
||||
if (fluid_log_function[FLUID_DBG] == NULL) {
|
||||
fluid_set_log_function(FLUID_DBG, fluid_default_log_function, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Print a message to the log.
|
||||
* @param level Log level (#fluid_log_level).
|
||||
* @param fmt Printf style format string for log message
|
||||
* @param ... Arguments for printf 'fmt' message string
|
||||
* @return Always returns #FLUID_FAILED
|
||||
*/
|
||||
int
|
||||
fluid_log(int level, const char* fmt, ...)
|
||||
{
|
||||
/*
|
||||
fluid_log_function_t fun = NULL;
|
||||
|
||||
va_list args;
|
||||
va_start (args, fmt);
|
||||
vsnprintf(fluid_errbuf, sizeof (fluid_errbuf), fmt, args);
|
||||
va_end (args);
|
||||
|
||||
if ((level >= 0) && (level < LAST_LOG_LEVEL)) {
|
||||
fun = fluid_log_function[level];
|
||||
if (fun != NULL) {
|
||||
(*fun)(level, fluid_errbuf, fluid_log_user_data[level]);
|
||||
}
|
||||
}
|
||||
*/
|
||||
return FLUID_FAILED;
|
||||
}
|
||||
|
||||
/**
|
||||
* An improved strtok, still trashes the input string, but is portable and
|
||||
* thread safe. Also skips token chars at beginning of token string and never
|
||||
* returns an empty token (will return NULL if source ends in token chars though).
|
||||
* NOTE: NOT part of public API
|
||||
* @internal
|
||||
* @param str Pointer to a string pointer of source to tokenize. Pointer gets
|
||||
* updated on each invocation to point to beginning of next token. Note that
|
||||
* token char get's overwritten with a 0 byte. String pointer is set to NULL
|
||||
* when final token is returned.
|
||||
* @param delim String of delimiter chars.
|
||||
* @return Pointer to the next token or NULL if no more tokens.
|
||||
*/
|
||||
char *fluid_strtok (char **str, char *delim)
|
||||
{
|
||||
char *s, *d, *token;
|
||||
char c;
|
||||
|
||||
if (str == NULL || delim == NULL || !*delim)
|
||||
{
|
||||
FLUID_LOG(FLUID_ERR, "Null pointer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
s = *str;
|
||||
if (!s) return NULL; /* str points to a NULL pointer? (tokenize already ended) */
|
||||
|
||||
/* skip delimiter chars at beginning of token */
|
||||
do
|
||||
{
|
||||
c = *s;
|
||||
if (!c) /* end of source string? */
|
||||
{
|
||||
*str = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (d = delim; *d; d++) /* is source char a token char? */
|
||||
{
|
||||
if (c == *d) /* token char match? */
|
||||
{
|
||||
s++; /* advance to next source char */
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (*d); /* while token char match */
|
||||
|
||||
token = s; /* start of token found */
|
||||
|
||||
/* search for next token char or end of source string */
|
||||
for (s = s+1; *s; s++)
|
||||
{
|
||||
c = *s;
|
||||
|
||||
for (d = delim; *d; d++) /* is source char a token char? */
|
||||
{
|
||||
if (c == *d) /* token char match? */
|
||||
{
|
||||
*s = '\0'; /* overwrite token char with zero byte to terminate token */
|
||||
*str = s+1; /* update str to point to beginning of next token */
|
||||
return token;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* we get here only if source string ended */
|
||||
*str = NULL;
|
||||
return token;
|
||||
}
|
||||
|
||||
/*
|
||||
* fluid_error
|
||||
*/
|
||||
char*
|
||||
fluid_error()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file is a MIDI file.
|
||||
* @param filename Path to the file to check
|
||||
* @return TRUE if it could be a MIDI file, FALSE otherwise
|
||||
*
|
||||
* The current implementation only checks for the "MThd" header in the file.
|
||||
* It is useful only to distinguish between SoundFont and MIDI files.
|
||||
*/
|
||||
int
|
||||
fluid_is_midifile(const char *filename)
|
||||
{
|
||||
FILE* fp = fopen(filename, "rb");
|
||||
char id[4];
|
||||
|
||||
if (fp == NULL) {
|
||||
return 0;
|
||||
}
|
||||
if (fread((void*) id, 1, 4, fp) != 4) {
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
return strncmp(id, "MThd", 4) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file is a SoundFont file.
|
||||
* @param filename Path to the file to check
|
||||
* @return TRUE if it could be a SoundFont, FALSE otherwise
|
||||
*
|
||||
* The current implementation only checks for the "RIFF" header in the file.
|
||||
* It is useful only to distinguish between SoundFont and MIDI files.
|
||||
*/
|
||||
int
|
||||
fluid_is_soundfont(const char *filename)
|
||||
{
|
||||
FILE* fp = fopen(filename, "rb");
|
||||
char id[4];
|
||||
|
||||
if (fp == NULL) {
|
||||
return 0;
|
||||
}
|
||||
if (fread((void*) id, 1, 4, fp) != 4) {
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
return strncmp(id, "RIFF", 4) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get time in milliseconds to be used in relative timing operations.
|
||||
* @return Unix time in milliseconds.
|
||||
*/
|
||||
unsigned int fluid_curtime(void)
|
||||
{
|
||||
static long initial_seconds = 0;
|
||||
struct timeval timeval;
|
||||
|
||||
if (initial_seconds == 0) {
|
||||
gettimeofday (&timeval, NULL);
|
||||
initial_seconds = timeval.tv_sec;
|
||||
}
|
||||
|
||||
gettimeofday (&timeval, NULL);
|
||||
|
||||
return (unsigned int)((timeval.tv_sec - initial_seconds) * 1000.0 + timeval.tv_usec / 1000.0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get time in microseconds to be used in relative timing operations.
|
||||
* @return Unix time in microseconds.
|
||||
*/
|
||||
double
|
||||
fluid_utime (void)
|
||||
{
|
||||
struct timeval timeval;
|
||||
|
||||
gettimeofday (&timeval, NULL);
|
||||
|
||||
return (timeval.tv_sec * 1000000.0 + timeval.tv_usec);
|
||||
}
|
||||
|
||||
|
||||
|
||||
128
project/jni/fluidsynth/src/utils/fluid_sys.h
Normal file
128
project/jni/fluidsynth/src/utils/fluid_sys.h
Normal file
@@ -0,0 +1,128 @@
|
||||
/* FluidSynth - A Software Synthesizer
|
||||
*
|
||||
* Copyright (C) 2003 Peter Hanappe and others.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
|
||||
This header contains a bunch of (mostly) system and machine
|
||||
dependent functions:
|
||||
|
||||
- timers
|
||||
- current time in milliseconds and microseconds
|
||||
- debug logging
|
||||
- profiling
|
||||
- memory locking
|
||||
- checking for floating point exceptions
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _FLUID_SYS_H
|
||||
#define _FLUID_SYS_H
|
||||
|
||||
#include "fluidsynth_priv.h"
|
||||
|
||||
|
||||
|
||||
void fluid_sys_config(void);
|
||||
void fluid_log_config(void);
|
||||
void fluid_time_config(void);
|
||||
|
||||
|
||||
/* Misc */
|
||||
|
||||
/*
|
||||
#define fluid_return_val_if_fail g_return_val_if_fail
|
||||
#define fluid_return_if_fail g_return_if_fail
|
||||
#define FLUID_INLINE inline
|
||||
#define FLUID_POINTER_TO_UINT GPOINTER_TO_UINT
|
||||
#define FLUID_UINT_TO_POINTER GUINT_TO_POINTER
|
||||
#define FLUID_POINTER_TO_INT GPOINTER_TO_INT
|
||||
#define FLUID_INT_TO_POINTER GINT_TO_POINTER
|
||||
#define FLUID_N_ELEMENTS(struct) (sizeof (struct) / sizeof (struct[0]))
|
||||
|
||||
#define FLUID_IS_BIG_ENDIAN (G_BYTE_ORDER == G_BIG_ENDIAN)
|
||||
*/
|
||||
|
||||
#include <endian.h>
|
||||
#define FLUID_INLINE inline
|
||||
#define FLUID_N_ELEMENTS(struct) (sizeof (struct) / sizeof (struct[0]))
|
||||
#define FLUID_IS_BIG_ENDIAN (__BYTE_ORDER == 4321)
|
||||
|
||||
|
||||
/*
|
||||
* Utility functions
|
||||
*/
|
||||
char *fluid_strtok (char **str, char *delim);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Additional debugging system, separate from the log system. This
|
||||
allows to print selected debug messages of a specific subsystem.
|
||||
*/
|
||||
|
||||
extern unsigned int fluid_debug_flags;
|
||||
|
||||
#if DEBUG
|
||||
|
||||
enum fluid_debug_level {
|
||||
FLUID_DBG_DRIVER = 1
|
||||
};
|
||||
|
||||
int fluid_debug(int level, char * fmt, ...);
|
||||
|
||||
#else
|
||||
#define fluid_debug
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
unsigned int fluid_curtime(void);
|
||||
double fluid_utime(void);
|
||||
|
||||
|
||||
/**
|
||||
Timers
|
||||
|
||||
*/
|
||||
|
||||
/* if the callback function returns 1 the timer will continue; if it
|
||||
returns 0 it will stop */
|
||||
typedef int (*fluid_timer_callback_t)(void* data, unsigned int msec);
|
||||
|
||||
typedef struct _fluid_timer_t fluid_timer_t;
|
||||
|
||||
/*
|
||||
fluid_timer_t* new_fluid_timer(int msec, fluid_timer_callback_t callback,
|
||||
void* data, int new_thread, int auto_destroy,
|
||||
int high_priority);
|
||||
*/
|
||||
//int delete_fluid_timer(fluid_timer_t* timer);
|
||||
//int fluid_timer_join(fluid_timer_t* timer);
|
||||
//int fluid_timer_stop(fluid_timer_t* timer);
|
||||
|
||||
|
||||
/* No profiling */
|
||||
#define fluid_profiling_print()
|
||||
#define fluid_profile_ref() 0
|
||||
#define fluid_profile_ref_var(name)
|
||||
#define fluid_profile(_num,_ref)
|
||||
|
||||
#endif /* _FLUID_SYS_H */
|
||||
349
project/jni/fluidsynth/src/utils/fluidsynth_priv.h
Normal file
349
project/jni/fluidsynth/src/utils/fluidsynth_priv.h
Normal file
@@ -0,0 +1,349 @@
|
||||
/* FluidSynth - A Software Synthesizer
|
||||
*
|
||||
* Copyright (C) 2003 Peter Hanappe and others.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _FLUIDSYNTH_PRIV_H
|
||||
#define _FLUIDSYNTH_PRIV_H
|
||||
|
||||
//#include <glib.h>
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(__POWERPC__) && !(defined(__APPLE__) && defined(__MACH__))
|
||||
#include "config_maxmsp43.h"
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) && !defined(MINGW32)
|
||||
#include "config_win32.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_MATH_H
|
||||
#include <math.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_ERRNO_H
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_STDARG_H
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_MMAN_H
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_STAT_H
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_NETINET_TCP_H
|
||||
#include <netinet/tcp.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_ARPA_INET_H
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_PTHREAD_H
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_IO_H
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_WINDOWS_H
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
/* MinGW32 special defines */
|
||||
#ifdef MINGW32
|
||||
|
||||
#include <stdint.h>
|
||||
#define snprintf _snprintf
|
||||
#define vsnprintf _vsnprintf
|
||||
|
||||
#define DSOUND_SUPPORT 1
|
||||
#define WINMIDI_SUPPORT 1
|
||||
#define STDIN_FILENO 0
|
||||
#define STDOUT_FILENO 1
|
||||
#define STDERR_FILENO 2
|
||||
|
||||
#endif
|
||||
|
||||
/* Darwin special defines (taken from config_macosx.h) */
|
||||
#ifdef DARWIN
|
||||
#define MACINTOSH
|
||||
#define __Types__
|
||||
#define WITHOUT_SERVER 1
|
||||
#endif
|
||||
|
||||
|
||||
#include "fluidsynth.h"
|
||||
|
||||
|
||||
/***************************************************************
|
||||
*
|
||||
* BASIC TYPES
|
||||
*/
|
||||
|
||||
#if defined(WITH_FLOAT)
|
||||
typedef float fluid_real_t;
|
||||
#else
|
||||
typedef double fluid_real_t;
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(WIN32)
|
||||
typedef SOCKET fluid_socket_t;
|
||||
#else
|
||||
typedef int fluid_socket_t;
|
||||
#define INVALID_SOCKET -1
|
||||
#endif
|
||||
|
||||
#define g_newa(type, len) (type *) alloca(len)
|
||||
|
||||
#if defined(SUPPORTS_VLA)
|
||||
# define FLUID_DECLARE_VLA(_type, _name, _len) \
|
||||
_type _name[_len]
|
||||
#else
|
||||
# define FLUID_DECLARE_VLA(_type, _name, _len) \
|
||||
_type* _name = g_newa(_type, (_len))
|
||||
#endif
|
||||
|
||||
|
||||
/** Integer types */
|
||||
//typedef gint8 sint8;
|
||||
typedef uint8_t uint8;
|
||||
//typedef gint16 sint16;
|
||||
//typedef guint16 uint16;
|
||||
typedef int32_t sint32;
|
||||
typedef uint32_t uint32;
|
||||
//typedef gint64 sint64;
|
||||
//typedef guint64 uint64;
|
||||
|
||||
|
||||
/***************************************************************
|
||||
*
|
||||
* FORWARD DECLARATIONS
|
||||
*/
|
||||
typedef struct _fluid_env_data_t fluid_env_data_t;
|
||||
typedef struct _fluid_adriver_definition_t fluid_adriver_definition_t;
|
||||
typedef struct _fluid_channel_t fluid_channel_t;
|
||||
typedef struct _fluid_tuning_t fluid_tuning_t;
|
||||
typedef struct _fluid_hashtable_t fluid_hashtable_t;
|
||||
typedef struct _fluid_client_t fluid_client_t;
|
||||
typedef struct _fluid_server_socket_t fluid_server_socket_t;
|
||||
typedef struct _fluid_sample_timer_t fluid_sample_timer_t;
|
||||
|
||||
/***************************************************************
|
||||
*
|
||||
* CONSTANTS
|
||||
*/
|
||||
|
||||
#define FLUID_BUFSIZE 64 /**< FluidSynth internal buffer size (in samples) */
|
||||
#define FLUID_MAX_EVENTS_PER_BUFSIZE 1024 /**< Maximum queued MIDI events per #FLUID_BUFSIZE */
|
||||
#define FLUID_MAX_RETURN_EVENTS 1024 /**< Maximum queued synthesis thread return events */
|
||||
#define FLUID_MAX_EVENT_QUEUES 16 /**< Maximum number of unique threads queuing events */
|
||||
#define FLUID_DEFAULT_AUDIO_RT_PRIO 60 /**< Default setting for audio.realtime-prio */
|
||||
#define FLUID_DEFAULT_MIDI_RT_PRIO 50 /**< Default setting for midi.realtime-prio */
|
||||
|
||||
#ifndef PI
|
||||
#define PI 3.141592654
|
||||
#endif
|
||||
|
||||
/***************************************************************
|
||||
*
|
||||
* SYSTEM INTERFACE
|
||||
*/
|
||||
typedef FILE* fluid_file;
|
||||
|
||||
#define FLUID_MALLOC(_n) malloc(_n)
|
||||
#define FLUID_REALLOC(_p,_n) realloc(_p,_n)
|
||||
#define FLUID_NEW(_t) (_t*)malloc(sizeof(_t))
|
||||
#define FLUID_ARRAY(_t,_n) (_t*)malloc((_n)*sizeof(_t))
|
||||
#define FLUID_FREE(_p) free(_p)
|
||||
#define FLUID_FOPEN(_f,_m) fopen(_f,_m)
|
||||
#define FLUID_FCLOSE(_f) fclose(_f)
|
||||
#define FLUID_FREAD(_p,_s,_n,_f) fread(_p,_s,_n,_f)
|
||||
#define FLUID_FSEEK(_f,_n,_set) fseek(_f,_n,_set)
|
||||
#define FLUID_MEMCPY(_dst,_src,_n) memcpy(_dst,_src,_n)
|
||||
#define FLUID_MEMSET(_s,_c,_n) memset(_s,_c,_n)
|
||||
#define FLUID_STRLEN(_s) strlen(_s)
|
||||
#define FLUID_STRCMP(_s,_t) strcmp(_s,_t)
|
||||
#define FLUID_STRNCMP(_s,_t,_n) strncmp(_s,_t,_n)
|
||||
#define FLUID_STRCPY(_dst,_src) strcpy(_dst,_src)
|
||||
#define FLUID_STRNCPY(_dst,_src,_n) strncpy(_dst,_src,_n)
|
||||
#define FLUID_STRCHR(_s,_c) strchr(_s,_c)
|
||||
#define FLUID_STRRCHR(_s,_c) strrchr(_s,_c)
|
||||
#ifdef strdup
|
||||
#define FLUID_STRDUP(s) strdup(s)
|
||||
#else
|
||||
#define FLUID_STRDUP(s) FLUID_STRCPY(FLUID_MALLOC(FLUID_STRLEN(s) + 1), s)
|
||||
#endif
|
||||
#define FLUID_SPRINTF sprintf
|
||||
#define FLUID_FPRINTF fprintf
|
||||
|
||||
#define fluid_clip(_val, _min, _max) \
|
||||
{ (_val) = ((_val) < (_min))? (_min) : (((_val) > (_max))? (_max) : (_val)); }
|
||||
|
||||
#if WITH_FTS
|
||||
#define FLUID_PRINTF post
|
||||
#define FLUID_FLUSH()
|
||||
#else
|
||||
#define FLUID_PRINTF printf
|
||||
#define FLUID_FLUSH() fflush(stdout)
|
||||
#endif
|
||||
|
||||
#define FLUID_LOG fluid_log
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.1415926535897932384626433832795
|
||||
#endif
|
||||
|
||||
|
||||
#define FLUID_ASSERT(a,b)
|
||||
#define FLUID_ASSERT_P(a,b)
|
||||
|
||||
char* fluid_error(void);
|
||||
|
||||
|
||||
/* Internationalization */
|
||||
#define _(s) s
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
#if !(defined (G_STMT_START) && defined (G_STMT_END))
|
||||
# define G_STMT_START do
|
||||
# define G_STMT_END while (0)
|
||||
#endif
|
||||
typedef uint32_t fluid_private_t;
|
||||
|
||||
#define fluid_rec_mutex_lock(X)
|
||||
#define fluid_rec_mutex_unlock(X)
|
||||
typedef void * fluid_mutex_t;
|
||||
#define fluid_private_free(X)
|
||||
|
||||
typedef int gboolean;
|
||||
typedef int gint;
|
||||
|
||||
#define fluid_mutex_destroy(_m)
|
||||
#define fluid_mutex_init(_m)
|
||||
#define fluid_mutex_lock(X)
|
||||
#define fluid_mutex_unlock(X)
|
||||
|
||||
#define g_return_if_fail(expr) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define g_return_val_if_fail(expr,val) G_STMT_START{ (void)0; }G_STMT_END
|
||||
|
||||
#define fluid_return_val_if_fail g_return_val_if_fail
|
||||
#define fluid_return_if_fail g_return_if_fail
|
||||
|
||||
#include <SDL_endian.h>
|
||||
#define GUINT16_FROM_LE(X) SDL_SwapLE16(X)
|
||||
#define GUINT32_FROM_LE(X) SDL_SwapLE32(X)
|
||||
#define GINT16_FROM_LE(X) SDL_SwapLE16(X)
|
||||
#define GINT32_FROM_LE(X) SDL_SwapLE32(X)
|
||||
|
||||
#define fluid_check_fpe(X)
|
||||
|
||||
#define fluid_ostream_printf(x, y)
|
||||
|
||||
static inline void fluid_atomic_int_add(int * x, int y) { *x += y; };
|
||||
static inline void fluid_atomic_int_set(int * x, int y) { *x = y; };
|
||||
static inline int fluid_atomic_int_get(int * x) { return *x; };
|
||||
static inline void fluid_atomic_int_inc(int * x) { * x += 1; };
|
||||
static inline int fluid_atomic_int_compare_and_exchange( int* reg, int oldval, int newval)
|
||||
{
|
||||
int old_reg_val = *reg;
|
||||
if (old_reg_val == oldval)
|
||||
*reg = newval;
|
||||
return old_reg_val;
|
||||
};
|
||||
|
||||
static inline int fluid_atomic_int_exchange_and_add(int * x, int y) { int oldval = *x; *x += y; return oldval; };
|
||||
|
||||
static inline void fluid_atomic_float_set(float * x, float y) { *x = y; };
|
||||
static inline float fluid_atomic_float_get(float * x) { return *x; };
|
||||
|
||||
#define g_atomic_int_set fluid_atomic_int_set
|
||||
#define g_atomic_int_get fluid_atomic_int_get
|
||||
|
||||
#define fluid_atomic_pointer_get(X) (*X)
|
||||
#define fluid_atomic_pointer_set(X, Y) *(X) = Y
|
||||
|
||||
#define FLUID_POINTER_TO_INT(X) (int32_t)(X)
|
||||
#define FLUID_POINTER_TO_UINT(X) (int32_t)(X)
|
||||
#define FLUID_INT_TO_POINTER(X) (void *)(X)
|
||||
#define FLUID_UINT_TO_POINTER(X) (void *)(X)
|
||||
#define GINT_TO_POINTER(X) FLUID_INT_TO_POINTER(X)
|
||||
#define GUINT_TO_POINTER(X) FLUID_UINT_TO_POINTER(X)
|
||||
#define GPOINTER_TO_INT(X) FLUID_POINTER_TO_INT(X)
|
||||
#define GPOINTER_TO_UINT(X) FLUID_POINTER_TO_UINT(X)
|
||||
|
||||
#define fluid_mlock(_p,_n) 0
|
||||
#define fluid_munlock(_p,_n)
|
||||
|
||||
#endif /* _FLUIDSYNTH_PRIV_H */
|
||||
Reference in New Issue
Block a user