mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2024-12-11 21:31:18 +00:00
Merge pull request #239 from carlo-bramini/fluidsynth_no_glib_1
Fluidsynth no glib 1
This commit is contained in:
commit
7146ecd61b
5 changed files with 36 additions and 60 deletions
|
@ -42,8 +42,8 @@
|
||||||
/* Private data for SEQUENCER */
|
/* Private data for SEQUENCER */
|
||||||
struct _fluid_sequencer_t {
|
struct _fluid_sequencer_t {
|
||||||
unsigned int startMs;
|
unsigned int startMs;
|
||||||
gint currentMs;
|
int currentMs;
|
||||||
gboolean useSystemTimer;
|
int useSystemTimer;
|
||||||
double scale; // ticks per second
|
double scale; // ticks per second
|
||||||
fluid_list_t* clients;
|
fluid_list_t* clients;
|
||||||
short clientsID;
|
short clientsID;
|
||||||
|
@ -121,7 +121,7 @@ new_fluid_sequencer2 (int use_system_timer)
|
||||||
FLUID_MEMSET(seq, 0, sizeof(fluid_sequencer_t));
|
FLUID_MEMSET(seq, 0, sizeof(fluid_sequencer_t));
|
||||||
|
|
||||||
seq->scale = 1000; // default value
|
seq->scale = 1000; // default value
|
||||||
seq->useSystemTimer = use_system_timer ? TRUE : FALSE;
|
seq->useSystemTimer = use_system_timer ? 1 : 0;
|
||||||
seq->startMs = seq->useSystemTimer ? fluid_curtime() : 0;
|
seq->startMs = seq->useSystemTimer ? fluid_curtime() : 0;
|
||||||
seq->clients = NULL;
|
seq->clients = NULL;
|
||||||
seq->clientsID = 0;
|
seq->clientsID = 0;
|
||||||
|
@ -196,7 +196,7 @@ delete_fluid_sequencer (fluid_sequencer_t* seq)
|
||||||
int
|
int
|
||||||
fluid_sequencer_get_use_system_timer (fluid_sequencer_t* seq)
|
fluid_sequencer_get_use_system_timer (fluid_sequencer_t* seq)
|
||||||
{
|
{
|
||||||
return seq->useSystemTimer ? 1 : 0;
|
return seq->useSystemTimer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -500,7 +500,7 @@ fluid_sequencer_remove_events (fluid_sequencer_t* seq, short source,
|
||||||
unsigned int
|
unsigned int
|
||||||
fluid_sequencer_get_tick (fluid_sequencer_t* seq)
|
fluid_sequencer_get_tick (fluid_sequencer_t* seq)
|
||||||
{
|
{
|
||||||
unsigned int absMs = seq->useSystemTimer ? (int) fluid_curtime() : g_atomic_int_get(&seq->currentMs);
|
unsigned int absMs = seq->useSystemTimer ? (int) fluid_curtime() : fluid_atomic_int_get(&seq->currentMs);
|
||||||
double nowFloat;
|
double nowFloat;
|
||||||
unsigned int now;
|
unsigned int now;
|
||||||
nowFloat = ((double)(absMs - seq->startMs))*seq->scale/1000.0f;
|
nowFloat = ((double)(absMs - seq->startMs))*seq->scale/1000.0f;
|
||||||
|
@ -846,7 +846,7 @@ fluid_sequencer_process(fluid_sequencer_t* seq, unsigned int msec)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* send queued events */
|
/* send queued events */
|
||||||
g_atomic_int_set(&seq->currentMs, msec);
|
fluid_atomic_int_set(&seq->currentMs, msec);
|
||||||
_fluid_seq_queue_send_queued_events(seq);
|
_fluid_seq_queue_send_queued_events(seq);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2030,86 +2030,59 @@ fluid_sample_import_sfont(fluid_sample_t* sample, SFSample* sfsample, fluid_defs
|
||||||
equivalent to the matching ID list in memory regardless of LE/BE machine
|
equivalent to the matching ID list in memory regardless of LE/BE machine
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if FLUID_IS_BIG_ENDIAN
|
#define READCHUNK(var,fd) FLUID_STMT_START { \
|
||||||
|
|
||||||
#define READCHUNK(var,fd) G_STMT_START { \
|
|
||||||
if (!safe_fread(var, 8, fd)) \
|
if (!safe_fread(var, 8, fd)) \
|
||||||
return(FAIL); \
|
return(FAIL); \
|
||||||
((SFChunk *)(var))->size = GUINT32_FROM_LE(((SFChunk *)(var))->size); \
|
((SFChunk *)(var))->size = GUINT32_FROM_LE(((SFChunk *)(var))->size); \
|
||||||
} G_STMT_END
|
} FLUID_STMT_END
|
||||||
|
|
||||||
#define READD(var,fd) G_STMT_START { \
|
#define READD(var,fd) FLUID_STMT_START { \
|
||||||
unsigned int _temp; \
|
unsigned int _temp; \
|
||||||
if (!safe_fread(&_temp, 4, fd)) \
|
if (!safe_fread(&_temp, 4, fd)) \
|
||||||
return(FAIL); \
|
return(FAIL); \
|
||||||
var = GINT32_FROM_LE(_temp); \
|
var = GINT32_FROM_LE(_temp); \
|
||||||
} G_STMT_END
|
} FLUID_STMT_END
|
||||||
|
|
||||||
#define READW(var,fd) G_STMT_START { \
|
#define READW(var,fd) FLUID_STMT_START { \
|
||||||
unsigned short _temp; \
|
unsigned short _temp; \
|
||||||
if (!safe_fread(&_temp, 2, fd)) \
|
if (!safe_fread(&_temp, 2, fd)) \
|
||||||
return(FAIL); \
|
return(FAIL); \
|
||||||
var = GINT16_FROM_LE(_temp); \
|
var = GINT16_FROM_LE(_temp); \
|
||||||
} G_STMT_END
|
} FLUID_STMT_END
|
||||||
|
|
||||||
#else
|
#define READID(var,fd) FLUID_STMT_START { \
|
||||||
|
|
||||||
#define READCHUNK(var,fd) G_STMT_START { \
|
|
||||||
if (!safe_fread(var, 8, fd)) \
|
|
||||||
return(FAIL); \
|
|
||||||
((SFChunk *)(var))->size = GUINT32_FROM_LE(((SFChunk *)(var))->size); \
|
|
||||||
} G_STMT_END
|
|
||||||
|
|
||||||
#define READD(var,fd) G_STMT_START { \
|
|
||||||
unsigned int _temp; \
|
|
||||||
if (!safe_fread(&_temp, 4, fd)) \
|
|
||||||
return(FAIL); \
|
|
||||||
var = GINT32_FROM_LE(_temp); \
|
|
||||||
} G_STMT_END
|
|
||||||
|
|
||||||
#define READW(var,fd) G_STMT_START { \
|
|
||||||
unsigned short _temp; \
|
|
||||||
if (!safe_fread(&_temp, 2, fd)) \
|
|
||||||
return(FAIL); \
|
|
||||||
var = GINT16_FROM_LE(_temp); \
|
|
||||||
} G_STMT_END
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#define READID(var,fd) G_STMT_START { \
|
|
||||||
if (!safe_fread(var, 4, fd)) \
|
if (!safe_fread(var, 4, fd)) \
|
||||||
return(FAIL); \
|
return(FAIL); \
|
||||||
} G_STMT_END
|
} FLUID_STMT_END
|
||||||
|
|
||||||
#define READSTR(var,fd) G_STMT_START { \
|
#define READSTR(var,fd) FLUID_STMT_START { \
|
||||||
if (!safe_fread(var, 20, fd)) \
|
if (!safe_fread(var, 20, fd)) \
|
||||||
return(FAIL); \
|
return(FAIL); \
|
||||||
(*var)[20] = '\0'; \
|
(*var)[20] = '\0'; \
|
||||||
} G_STMT_END
|
} FLUID_STMT_END
|
||||||
|
|
||||||
#define READB(var,fd) G_STMT_START { \
|
#define READB(var,fd) FLUID_STMT_START { \
|
||||||
if (!safe_fread(&var, 1, fd)) \
|
if (!safe_fread(&var, 1, fd)) \
|
||||||
return(FAIL); \
|
return(FAIL); \
|
||||||
} G_STMT_END
|
} FLUID_STMT_END
|
||||||
|
|
||||||
#define FSKIP(size,fd) G_STMT_START { \
|
#define FSKIP(size,fd) FLUID_STMT_START { \
|
||||||
if (!safe_fseek(fd, size, SEEK_CUR)) \
|
if (!safe_fseek(fd, size, SEEK_CUR)) \
|
||||||
return(FAIL); \
|
return(FAIL); \
|
||||||
} G_STMT_END
|
} FLUID_STMT_END
|
||||||
|
|
||||||
#define FSKIPW(fd) G_STMT_START { \
|
#define FSKIPW(fd) FLUID_STMT_START { \
|
||||||
if (!safe_fseek(fd, 2, SEEK_CUR)) \
|
if (!safe_fseek(fd, 2, SEEK_CUR)) \
|
||||||
return(FAIL); \
|
return(FAIL); \
|
||||||
} G_STMT_END
|
} FLUID_STMT_END
|
||||||
|
|
||||||
/* removes and advances a fluid_list_t pointer */
|
/* removes and advances a fluid_list_t pointer */
|
||||||
#define SLADVREM(list, item) G_STMT_START { \
|
#define SLADVREM(list, item) FLUID_STMT_START { \
|
||||||
fluid_list_t *_temp = item; \
|
fluid_list_t *_temp = item; \
|
||||||
item = fluid_list_next(item); \
|
item = fluid_list_next(item); \
|
||||||
list = fluid_list_remove_link(list, _temp); \
|
list = fluid_list_remove_link(list, _temp); \
|
||||||
delete1_fluid_list(_temp); \
|
delete1_fluid_list(_temp); \
|
||||||
} G_STMT_END
|
} FLUID_STMT_END
|
||||||
|
|
||||||
static int chunkid (unsigned int id);
|
static int chunkid (unsigned int id);
|
||||||
static int load_body (unsigned int size, SFData * sf, FILE * fd);
|
static int load_body (unsigned int size, SFData * sf, FILE * fd);
|
||||||
|
@ -2760,7 +2733,7 @@ load_pgen (int size, SFData * sf, FILE * fd)
|
||||||
{ /* inst is last gen */
|
{ /* inst is last gen */
|
||||||
level = 3;
|
level = 3;
|
||||||
READW (genval.uword, fd);
|
READW (genval.uword, fd);
|
||||||
((SFZone *) (p2->data))->instsamp = GINT_TO_POINTER (genval.uword + 1);
|
((SFZone *) (p2->data))->instsamp = FLUID_INT_TO_POINTER (genval.uword + 1);
|
||||||
break; /* break out of generator loop */
|
break; /* break out of generator loop */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -3110,7 +3083,7 @@ load_igen (int size, SFData * sf, FILE * fd)
|
||||||
{ /* sample is last gen */
|
{ /* sample is last gen */
|
||||||
level = 3;
|
level = 3;
|
||||||
READW (genval.uword, fd);
|
READW (genval.uword, fd);
|
||||||
((SFZone *) (p2->data))->instsamp = GINT_TO_POINTER (genval.uword + 1);
|
((SFZone *) (p2->data))->instsamp = FLUID_INT_TO_POINTER (genval.uword + 1);
|
||||||
break; /* break out of generator loop */
|
break; /* break out of generator loop */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -3270,7 +3243,7 @@ fixup_pgen (SFData * sf)
|
||||||
while (p2)
|
while (p2)
|
||||||
{ /* traverse this preset's zones */
|
{ /* traverse this preset's zones */
|
||||||
z = (SFZone *) (p2->data);
|
z = (SFZone *) (p2->data);
|
||||||
if ((i = GPOINTER_TO_INT (z->instsamp)))
|
if ((i = FLUID_POINTER_TO_INT (z->instsamp)))
|
||||||
{ /* load instrument # */
|
{ /* load instrument # */
|
||||||
p3 = fluid_list_nth (sf->inst, i - 1);
|
p3 = fluid_list_nth (sf->inst, i - 1);
|
||||||
if (!p3)
|
if (!p3)
|
||||||
|
@ -3305,7 +3278,7 @@ fixup_igen (SFData * sf)
|
||||||
while (p2)
|
while (p2)
|
||||||
{ /* traverse instrument's zones */
|
{ /* traverse instrument's zones */
|
||||||
z = (SFZone *) (p2->data);
|
z = (SFZone *) (p2->data);
|
||||||
if ((i = GPOINTER_TO_INT (z->instsamp)))
|
if ((i = FLUID_POINTER_TO_INT (z->instsamp)))
|
||||||
{ /* load sample # */
|
{ /* load sample # */
|
||||||
p3 = fluid_list_nth (sf->sample, i - 1);
|
p3 = fluid_list_nth (sf->sample, i - 1);
|
||||||
if (!p3)
|
if (!p3)
|
||||||
|
|
|
@ -3353,13 +3353,12 @@ fluid_synth_start_voice(fluid_synth_t* synth, fluid_voice_t* voice)
|
||||||
void
|
void
|
||||||
fluid_synth_add_sfloader(fluid_synth_t* synth, fluid_sfloader_t* loader)
|
fluid_synth_add_sfloader(fluid_synth_t* synth, fluid_sfloader_t* loader)
|
||||||
{
|
{
|
||||||
gboolean sfont_already_loaded;
|
|
||||||
|
|
||||||
fluid_return_if_fail (synth != NULL);
|
fluid_return_if_fail (synth != NULL);
|
||||||
fluid_return_if_fail (loader != NULL);
|
fluid_return_if_fail (loader != NULL);
|
||||||
fluid_synth_api_enter(synth);
|
fluid_synth_api_enter(synth);
|
||||||
sfont_already_loaded = synth->sfont_info != NULL;
|
|
||||||
if (!sfont_already_loaded)
|
/* Test if sfont is already loaded */
|
||||||
|
if (synth->sfont_info == NULL)
|
||||||
synth->loaders = fluid_list_prepend(synth->loaders, loader);
|
synth->loaders = fluid_list_prepend(synth->loaders, loader);
|
||||||
fluid_synth_api_exit(synth);
|
fluid_synth_api_exit(synth);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ typedef struct
|
||||||
|
|
||||||
/* Excerpt from glib gprimes.c */
|
/* Excerpt from glib gprimes.c */
|
||||||
|
|
||||||
static const guint primes[] =
|
static const unsigned int primes[] =
|
||||||
{
|
{
|
||||||
11,
|
11,
|
||||||
19,
|
19,
|
||||||
|
|
|
@ -65,6 +65,10 @@ void fluid_time_config(void);
|
||||||
#define FLUID_INT_TO_POINTER GINT_TO_POINTER
|
#define FLUID_INT_TO_POINTER GINT_TO_POINTER
|
||||||
#define FLUID_N_ELEMENTS(struct) (sizeof (struct) / sizeof (struct[0]))
|
#define FLUID_N_ELEMENTS(struct) (sizeof (struct) / sizeof (struct[0]))
|
||||||
|
|
||||||
|
/* Open/closes statement block */
|
||||||
|
#define FLUID_STMT_START do
|
||||||
|
#define FLUID_STMT_END while (0)
|
||||||
|
|
||||||
#define FLUID_IS_BIG_ENDIAN (G_BYTE_ORDER == G_BIG_ENDIAN)
|
#define FLUID_IS_BIG_ENDIAN (G_BYTE_ORDER == G_BIG_ENDIAN)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue