Skip to content

Latest commit

 

History

History
87 lines (74 loc) · 3.33 KB

dynamic_fluidsynth.c

File metadata and controls

87 lines (74 loc) · 3.33 KB
 
Dec 31, 2011
Dec 31, 2011
2
SDL_mixer: An audio mixer library based on the SDL library
Feb 15, 2013
Feb 15, 2013
3
Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
Dec 31, 2011
Dec 31, 2011
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
James Le Cuirot
chewi@aura-online.co.uk
23
24
25
26
27
28
29
30
*/
#ifdef USE_FLUIDSYNTH_MIDI
#include "SDL_loadso.h"
#include "dynamic_fluidsynth.h"
fluidsynth_loader fluidsynth = {
May 22, 2013
May 22, 2013
31
0, NULL
32
33
34
35
};
#ifdef FLUIDSYNTH_DYNAMIC
#define FLUIDSYNTH_LOADER(FUNC, SIG) \
May 22, 2013
May 22, 2013
36
37
fluidsynth.FUNC = (SIG) SDL_LoadFunction(fluidsynth.handle, #FUNC); \
if (fluidsynth.FUNC == NULL) { SDL_UnloadObject(fluidsynth.handle); return -1; }
38
39
#else
#define FLUIDSYNTH_LOADER(FUNC, SIG) \
May 22, 2013
May 22, 2013
40
fluidsynth.FUNC = FUNC;
41
42
43
44
#endif
int Mix_InitFluidSynth()
{
May 22, 2013
May 22, 2013
45
if ( fluidsynth.loaded == 0 ) {
46
#ifdef FLUIDSYNTH_DYNAMIC
May 22, 2013
May 22, 2013
47
48
fluidsynth.handle = SDL_LoadObject(FLUIDSYNTH_DYNAMIC);
if ( fluidsynth.handle == NULL ) return -1;
May 22, 2013
May 22, 2013
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
FLUIDSYNTH_LOADER(delete_fluid_player, int (*)(fluid_player_t*));
FLUIDSYNTH_LOADER(delete_fluid_settings, void (*)(fluid_settings_t*));
FLUIDSYNTH_LOADER(delete_fluid_synth, int (*)(fluid_synth_t*));
FLUIDSYNTH_LOADER(fluid_player_add, int (*)(fluid_player_t*, const char*));
FLUIDSYNTH_LOADER(fluid_player_add_mem, int (*)(fluid_player_t*, const void*, size_t));
FLUIDSYNTH_LOADER(fluid_player_get_status, int (*)(fluid_player_t*));
FLUIDSYNTH_LOADER(fluid_player_play, int (*)(fluid_player_t*));
FLUIDSYNTH_LOADER(fluid_player_set_loop, int (*)(fluid_player_t*, int));
FLUIDSYNTH_LOADER(fluid_player_stop, int (*)(fluid_player_t*));
FLUIDSYNTH_LOADER(fluid_settings_setnum, int (*)(fluid_settings_t*, const char*, double));
FLUIDSYNTH_LOADER(fluid_synth_get_settings, fluid_settings_t* (*)(fluid_synth_t*));
FLUIDSYNTH_LOADER(fluid_synth_set_gain, void (*)(fluid_synth_t*, float));
FLUIDSYNTH_LOADER(fluid_synth_sfload, int(*)(fluid_synth_t*, const char*, int));
FLUIDSYNTH_LOADER(fluid_synth_write_s16, int(*)(fluid_synth_t*, int, void*, int, int, void*, int, int));
FLUIDSYNTH_LOADER(new_fluid_player, fluid_player_t* (*)(fluid_synth_t*));
FLUIDSYNTH_LOADER(new_fluid_settings, fluid_settings_t* (*)(void));
FLUIDSYNTH_LOADER(new_fluid_synth, fluid_synth_t* (*)(fluid_settings_t*));
}
++fluidsynth.loaded;
May 22, 2013
May 22, 2013
71
return 0;
72
73
74
75
}
void Mix_QuitFluidSynth()
{
May 22, 2013
May 22, 2013
76
77
78
79
if ( fluidsynth.loaded == 0 ) {
return;
}
if ( fluidsynth.loaded == 1 ) {
80
#ifdef FLUIDSYNTH_DYNAMIC
May 22, 2013
May 22, 2013
81
SDL_UnloadObject(fluidsynth.handle);
May 22, 2013
May 22, 2013
83
84
}
--fluidsynth.loaded;
85
86
87
}
#endif /* USE_FLUIDSYNTH_MIDI */