mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-01-19 07:50:49 +00:00
Applied Stephane Letz patch: MidiShare is now connected to fluidsynth
by default so that received MIDI events directly trigger the synth
This commit is contained in:
parent
a360fdded7
commit
83ae11f873
8 changed files with 51 additions and 31 deletions
|
@ -17,3 +17,5 @@
|
||||||
|
|
||||||
/* define to support DARWIN */
|
/* define to support DARWIN */
|
||||||
#define DARWIN
|
#define DARWIN
|
||||||
|
|
||||||
|
typedef int socklen_t
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
#define VERSION "0.2.4"
|
#define VERSION "1.0.x"
|
||||||
|
|
||||||
#define MACINTOSH
|
#define MACINTOSH
|
||||||
|
|
||||||
|
@ -33,3 +33,5 @@
|
||||||
#define PORTAUDIO_SUPPORT 1
|
#define PORTAUDIO_SUPPORT 1
|
||||||
#define __Types__
|
#define __Types__
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
typedef int socklen_t
|
||||||
|
|
|
@ -70,6 +70,7 @@ void fluid_core_audio_driver_settings(fluid_settings_t* settings);
|
||||||
fluid_audio_driver_t* new_fluid_dsound_audio_driver(fluid_settings_t* settings,
|
fluid_audio_driver_t* new_fluid_dsound_audio_driver(fluid_settings_t* settings,
|
||||||
fluid_synth_t* synth);
|
fluid_synth_t* synth);
|
||||||
int delete_fluid_dsound_audio_driver(fluid_audio_driver_t* p);
|
int delete_fluid_dsound_audio_driver(fluid_audio_driver_t* p);
|
||||||
|
void fluid_dsound_audio_driver_settings(fluid_settings_t* settings);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if PORTAUDIO_SUPPORT
|
#if PORTAUDIO_SUPPORT
|
||||||
|
@ -128,7 +129,7 @@ fluid_audriver_definition_t fluid_audio_drivers[] = {
|
||||||
new_fluid_dsound_audio_driver,
|
new_fluid_dsound_audio_driver,
|
||||||
NULL,
|
NULL,
|
||||||
delete_fluid_dsound_audio_driver,
|
delete_fluid_dsound_audio_driver,
|
||||||
NULL },
|
fluid_dsound_audio_driver_settings },
|
||||||
#endif
|
#endif
|
||||||
#if PORTAUDIO_SUPPORT
|
#if PORTAUDIO_SUPPORT
|
||||||
{ "portaudio",
|
{ "portaudio",
|
||||||
|
|
|
@ -508,7 +508,7 @@ static void* fluid_alsa_audio_run_s16(void* d)
|
||||||
|
|
||||||
if (snd_pcm_nonblock(dev->pcm, 0) != 0) { /* double negation */
|
if (snd_pcm_nonblock(dev->pcm, 0) != 0) { /* double negation */
|
||||||
FLUID_LOG(FLUID_ERR, "Failed to set the audio device to blocking mode");
|
FLUID_LOG(FLUID_ERR, "Failed to set the audio device to blocking mode");
|
||||||
goto error_recovery;
|
goto error_recovery;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (snd_pcm_prepare(dev->pcm) != 0) {
|
if (snd_pcm_prepare(dev->pcm) != 0) {
|
||||||
|
|
|
@ -62,6 +62,20 @@ typedef struct {
|
||||||
DWORD frame_size;
|
DWORD frame_size;
|
||||||
} fluid_dsound_audio_driver_t;
|
} fluid_dsound_audio_driver_t;
|
||||||
|
|
||||||
|
static BOOL
|
||||||
|
fluid_dsound_enum_callback(LPGUID guid, LPCSTR description, LPCSTR module, LPVOID context)
|
||||||
|
{
|
||||||
|
fluid_settings_t* settings = (fluid_settings_t*) context;
|
||||||
|
fluid_settings_add_option(settings, "audio.dsound.device", description);
|
||||||
|
}
|
||||||
|
|
||||||
|
void fluid_dsound_audio_driver_settings(fluid_settings_t* settings)
|
||||||
|
{
|
||||||
|
fluid_settings_register_str(settings, "audio.dsound.device", "default", 0, NULL, NULL);
|
||||||
|
fluid_settings_add_option(settings, "audio.dsound.device", "default");
|
||||||
|
DirectSoundEnumerate((LPDSENUMCALLBACK) fluid_dsound_enum_callback, settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* new_fluid_dsound_audio_driver
|
* new_fluid_dsound_audio_driver
|
||||||
|
@ -377,7 +391,7 @@ int fluid_win32_create_window(void)
|
||||||
myClass.hCursor = LoadCursor( NULL, IDC_ARROW );
|
myClass.hCursor = LoadCursor( NULL, IDC_ARROW );
|
||||||
myClass.hIcon = NULL;
|
myClass.hIcon = NULL;
|
||||||
myClass.lpszMenuName = (LPSTR) NULL;
|
myClass.lpszMenuName = (LPSTR) NULL;
|
||||||
myClass.lpszClassName = (LPSTR) "FLUIDSynth";
|
myClass.lpszClassName = (LPSTR) "FluidSynth";
|
||||||
myClass.hbrBackground = (HBRUSH)(COLOR_WINDOW);
|
myClass.hbrBackground = (HBRUSH)(COLOR_WINDOW);
|
||||||
myClass.hInstance = FLUID_HINSTANCE;
|
myClass.hInstance = FLUID_HINSTANCE;
|
||||||
myClass.style = CS_GLOBALCLASS;
|
myClass.style = CS_GLOBALCLASS;
|
||||||
|
@ -387,7 +401,7 @@ int fluid_win32_create_window(void)
|
||||||
if (!RegisterClass(&myClass)) {
|
if (!RegisterClass(&myClass)) {
|
||||||
return -100;
|
return -100;
|
||||||
}
|
}
|
||||||
fluid_wnd = CreateWindow((LPSTR) "FLUIDSynth", (LPSTR) "FLUIDSynth", WS_OVERLAPPEDWINDOW,
|
fluid_wnd = CreateWindow((LPSTR) "FluidSynth", (LPSTR) "FluidSynth", WS_OVERLAPPEDWINDOW,
|
||||||
CW_USEDEFAULT, CW_USEDEFAULT, 400, 300, (HWND) NULL, (HMENU) NULL,
|
CW_USEDEFAULT, CW_USEDEFAULT, 400, 300, (HWND) NULL, (HMENU) NULL,
|
||||||
FLUID_HINSTANCE, (LPSTR) NULL);
|
FLUID_HINSTANCE, (LPSTR) NULL);
|
||||||
if (fluid_wnd == NULL) {
|
if (fluid_wnd == NULL) {
|
||||||
|
@ -402,8 +416,7 @@ int fluid_win32_destroy_window(void)
|
||||||
if (fluid_wnd != NULL) {
|
if (fluid_wnd != NULL) {
|
||||||
DestroyWindow(fluid_wnd);
|
DestroyWindow(fluid_wnd);
|
||||||
fluid_wnd = NULL;
|
fluid_wnd = NULL;
|
||||||
|
UnregisterClass((LPSTR) "FluidSynth", FLUID_HINSTANCE);
|
||||||
UnregisterClass((LPSTR) "FLUIDSynth",FLUID_HINSTANCE);
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
* 21/12/01 : Add a compilation flag (MIDISHARE_DRIVER) for driver or application mode
|
* 21/12/01 : Add a compilation flag (MIDISHARE_DRIVER) for driver or application mode
|
||||||
* 29/01/02 : Compilation on MacOSX, use a task for typeNote management
|
* 29/01/02 : Compilation on MacOSX, use a task for typeNote management
|
||||||
* 03/06/03 : Adapdation for FluidSynth API
|
* 03/06/03 : Adapdation for FluidSynth API
|
||||||
|
* 18/03/04 : In appplication mode, connect MidiShare to the fluidsynth client (fluid_midishare_open_appl)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -139,7 +140,6 @@ new_fluid_midishare_midi_driver(fluid_settings_t* settings,
|
||||||
MidiSetFilter(dev->refnum, dev->filter);
|
MidiSetFilter(dev->refnum, dev->filter);
|
||||||
|
|
||||||
dev->status = FLUID_MIDI_READY;
|
dev->status = FLUID_MIDI_READY;
|
||||||
|
|
||||||
return (fluid_midi_driver_t*) dev;
|
return (fluid_midi_driver_t*) dev;
|
||||||
|
|
||||||
error_recovery:
|
error_recovery:
|
||||||
|
@ -393,6 +393,7 @@ static int fluid_midishare_open_appl (fluid_midishare_midi_driver_t* dev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
MidiSetRcvAlarm(dev->refnum, fluid_midishare_midi_driver_receive);
|
MidiSetRcvAlarm(dev->refnum, fluid_midishare_midi_driver_receive);
|
||||||
|
MidiConnect(0,dev->refnum,true);
|
||||||
#endif
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1540,21 +1540,21 @@ fluid_synth_nwrite_float(fluid_synth_t* synth, int len,
|
||||||
|
|
||||||
/* Then, run one_block() and copy till we have 'len' samples */
|
/* Then, run one_block() and copy till we have 'len' samples */
|
||||||
while (count < len) {
|
while (count < len) {
|
||||||
fluid_synth_one_block(synth, 1);
|
fluid_synth_one_block(synth, 1);
|
||||||
|
|
||||||
num = (FLUID_BUFSIZE > len - count)? len - count : FLUID_BUFSIZE;
|
num = (FLUID_BUFSIZE > len - count)? len - count : FLUID_BUFSIZE;
|
||||||
bytes = num * sizeof(float);
|
bytes = num * sizeof(float);
|
||||||
|
|
||||||
for (i = 0; i < synth->audio_channels; i++) {
|
for (i = 0; i < synth->audio_channels; i++) {
|
||||||
FLUID_MEMCPY(left[i] + count, left_in[i], bytes);
|
FLUID_MEMCPY(left[i] + count, left_in[i], bytes);
|
||||||
FLUID_MEMCPY(right[i] + count, right_in[i], bytes);
|
FLUID_MEMCPY(right[i] + count, right_in[i], bytes);
|
||||||
}
|
}
|
||||||
for (i = 0; i < synth->effects_channels; i++) {
|
for (i = 0; i < synth->effects_channels; i++) {
|
||||||
FLUID_MEMCPY(fx_left[i] + count, fx_left_in[i], bytes);
|
FLUID_MEMCPY(fx_left[i] + count, fx_left_in[i], bytes);
|
||||||
FLUID_MEMCPY(fx_right[i] + count, fx_right_in[i], bytes);
|
FLUID_MEMCPY(fx_right[i] + count, fx_right_in[i], bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
count += num;
|
count += num;
|
||||||
}
|
}
|
||||||
|
|
||||||
synth->cur = num;
|
synth->cur = num;
|
||||||
|
@ -1747,15 +1747,17 @@ fluid_synth_one_block(fluid_synth_t* synth, int do_not_mix_fx_to_out)
|
||||||
if (_PLAYING(voice)) {
|
if (_PLAYING(voice)) {
|
||||||
double prof_ref_voice = fluid_profile_ref();
|
double prof_ref_voice = fluid_profile_ref();
|
||||||
|
|
||||||
/* The output associated with a MIDI channel is wrapped around using the number of
|
/* The output associated with a MIDI channel is wrapped around
|
||||||
* audio groups as modulo divider.
|
* using the number of audio groups as modulo divider. This is
|
||||||
* This is typically the number of output channels on the 'sound card', as long as the
|
* typically the number of output channels on the 'sound card',
|
||||||
* LADSPA Fx unit is not used. In case of LADSPA unit, think of it as subgroups on a mixer.
|
* as long as the LADSPA Fx unit is not used. In case of LADSPA
|
||||||
|
* unit, think of it as subgroups on a mixer.
|
||||||
|
*
|
||||||
* For example: Assume that the number of groups is set to 2.
|
* For example: Assume that the number of groups is set to 2.
|
||||||
* Then MIDI channel 1, 3, 5, 7 etc. go to output 1, channels 2, 4, 6, 8 etc to output 2.
|
* Then MIDI channel 1, 3, 5, 7 etc. go to output 1, channels 2,
|
||||||
* Or assume 3 groups:
|
* 4, 6, 8 etc to output 2. Or assume 3 groups: Then MIDI
|
||||||
* Then MIDI channels 1, 4, 7, 10 etc go to output 1; 2, 5, 8, 11 etc to output 2,
|
* channels 1, 4, 7, 10 etc go to output 1; 2, 5, 8, 11 etc to
|
||||||
* 3, 6, 9, 12 etc to output 3.
|
* output 2, 3, 6, 9, 12 etc to output 3.
|
||||||
*/
|
*/
|
||||||
auchan = fluid_channel_get_num(fluid_voice_get_channel(voice));
|
auchan = fluid_channel_get_num(fluid_voice_get_channel(voice));
|
||||||
auchan %= synth->audio_groups;
|
auchan %= synth->audio_groups;
|
||||||
|
|
|
@ -682,7 +682,6 @@ print_welcome()
|
||||||
"under certain conditions; see the COPYING file for details.\n"
|
"under certain conditions; see the COPYING file for details.\n"
|
||||||
"SoundFont(R) is a registered trademark of E-mu Systems, Inc.\n\n"
|
"SoundFont(R) is a registered trademark of E-mu Systems, Inc.\n\n"
|
||||||
"Type 'help' to get information on the shell commands.\n\n", FLUIDSYNTH_VERSION);
|
"Type 'help' to get information on the shell commands.\n\n", FLUIDSYNTH_VERSION);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue