New jack MIDI driver, updated README-OSX.

This commit is contained in:
Josh Green 2009-03-09 05:48:04 +00:00
parent 7e96e922d9
commit b28c01954a
5 changed files with 224 additions and 6 deletions

View file

@ -1,3 +1,8 @@
2009-03-08 Josh Green <jgreen@users.sourceforge.net>
* src/fluid_jack.c: Added support for Jack MIDI.
* src/fluid_mdriver.c: Registered Jack MIDI driver.
* README-OSX: Update from Ebrahim Mayat.
2009-02-28 Pedro Lopez-Cabanillas <plcl@users.sourceforge.net>
* src/fluid_midi.c: Fix for ticket #22 (Wrong tempo changes)
* src/fluid_midi.h: delta-time accumulator moved to fluid_midi_file struct.

View file

@ -1,13 +1,18 @@
Compiling fluidsynth-1.0.8 on Mac OS X.5 (Leopard)
fluidsynth-1.0.9 on Mac OS X.5 (Leopard)
-----------------------------------------------------------------------
fluidsynth-1.0.9 can be installed in two ways on your Apple computer:
A. Compilation and installation by hand
---------------------------------------
Requirements:
- "XcodeTools.mpkg","DevSDK.pkg", "CoreAudioSDK.pkg" packages (The Leopard Install DVD).
- "XcodeTools.mpkg","DevSDK.pkg", "CoreAudioSDK.pkg" packages (The Leopard Install DVD)
- Fink installation <http://fink.sourceforge.net>
- libgnugetopt and readline from fink: e.g. "fink install libgnugetopt"
- JackOSX.0.80.pkg.zip <http://www.jackosx.com>
- JackOSX.0.81.pkg.zip <http://www.jackosx.com>
- MIDI Patchbay 1.0.3 <http://www.apple.com/downloads/macosx/audio/index6.html>
@ -17,17 +22,38 @@ $ PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./configure && make
2. make install as superuser
B. Compilation and installation of the fink fluidsynth package
--------------------------------------------------------------
Requirements:
- "XcodeTools.mpkg","DevSDK.pkg", "CoreAudioSDK.pkg" packages (The Leopard Install DVD)
- Fink installation <http://fink.sourceforge.net>
- MIDI Patchbay 1.0.3 <http://www.apple.com/downloads/macosx/audio/index6.html>
In Terminal.app simply type $ fink install fluidsynth
and the fink fluidsynth package automatically installs dependencies like libgnugetopt, readline and jack.
Running fluidsynth:
$ fluidsynth -a jack -m coremidi -j (it also possible to run the coreaudio sound driver simply by omitting the "-a jack" option)
In order to run fluidsynth via the jack sound server either launch JackPilot.app if you have installed the JackOSX package or, if you have installed the fink package, start jack from Terminal.app
In order to run another instance of fluidsynth, open a second terminal window:
$ jackd -R -p 512 -d coreaudio -i 2 -o 2
then start fluidsynth
$ fluidsynth -a jack -m coremidi -j (it also possible to run the coreaudio sound driver simply by omitting the "-a jack -j" options)
In order to run another instance of fluidsynth, open another terminal window:
$ fluidsynth -a jack -m coremidi -o audio.jack.id=name_of_instance -p name_of_instance -j
Connect MIDI I/O devices using MIDI Patchbay
Ebrahim Mayat <emayat@users.sourceforge.net>
28th January 2009
8th March 2009

View file

@ -129,6 +129,10 @@
/* Include the LADSPA Fx unit */
#undef LADSPA
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#undef LT_OBJDIR
/* Define to enable MidiShare driver */
#undef MIDISHARE_SUPPORT

View file

@ -36,6 +36,7 @@
#include "fluid_settings.h"
#include <jack/jack.h>
#include <jack/midiport.h>
#include "config.h"
#include "fluid_lash.h"
@ -63,6 +64,15 @@ typedef struct {
} fluid_jack_audio_driver_t;
/* Jack MIDI driver instance */
typedef struct {
fluid_midi_driver_t driver;
jack_client_t *client;
jack_port_t *midi_port;
fluid_midi_parser_t *parser;
} fluid_jack_midi_driver_t;
fluid_audio_driver_t*
new_fluid_jack_audio_driver2(fluid_settings_t* settings, fluid_audio_func_t func, void* data);
int delete_fluid_jack_audio_driver(fluid_audio_driver_t* p);
@ -71,6 +81,9 @@ int fluid_jack_audio_driver_srate(jack_nframes_t nframes, void *arg);
int fluid_jack_audio_driver_bufsize(jack_nframes_t nframes, void *arg);
int fluid_jack_audio_driver_process(jack_nframes_t nframes, void *arg);
int fluid_jack_audio_driver_process2(jack_nframes_t nframes, void *arg);
int delete_fluid_jack_midi_driver(fluid_midi_driver_t *p);
static int fluid_jack_midi_driver_process (jack_nframes_t nframes, void *arg);
void
fluid_jack_audio_driver_settings(fluid_settings_t* settings)
@ -122,6 +135,8 @@ new_fluid_jack_audio_driver2(fluid_settings_t* settings, fluid_audio_func_t func
snprintf(name, 64, "fluidsynth");
}
name[63] = '\0';
if ((dev->client = jack_client_new(name)) == 0) {
FLUID_LOG(FLUID_ERR, "Jack server not running?");
goto error_recovery;
@ -348,3 +363,151 @@ fluid_jack_audio_driver_shutdown(void *arg)
FLUID_LOG(FLUID_ERR, "Help! Lost the connection to the JACK server");
/* exit (1); */
}
void fluid_jack_midi_driver_settings (fluid_settings_t *settings)
{
fluid_settings_register_str (settings, "midi.jack.id", "fluidsynth-midi", 0, NULL, NULL);
}
/*
* new_fluid_jack_midi_driver
*/
fluid_midi_driver_t *
new_fluid_jack_midi_driver (fluid_settings_t *settings,
handle_midi_event_func_t handler, void *data)
{
fluid_jack_midi_driver_t* dev;
char *client_name;
char name[64];
int err;
/* not much use doing anything */
if (handler == NULL)
{
FLUID_LOG(FLUID_ERR, "Invalid argument");
return NULL;
}
/* allocate the device */
dev = FLUID_NEW(fluid_jack_midi_driver_t);
if (dev == NULL)
{
FLUID_LOG(FLUID_ERR, "Out of memory");
return NULL;
}
FLUID_MEMSET(dev, 0, sizeof(fluid_jack_midi_driver_t));
dev->driver.handler = handler;
dev->driver.data = data;
/* allocate one event to store the input data */
dev->parser = new_fluid_midi_parser ();
if (dev->parser == NULL)
{
FLUID_LOG(FLUID_ERR, "Out of memory");
goto error_recovery;
}
/* try to become a client of the JACK server */
if (fluid_settings_getstr(settings, "midi.jack.id", &client_name)
&& (client_name != NULL)
&& (strlen(client_name) > 0))
snprintf(name, 64, "%s", client_name);
else snprintf(name, 64, "fluidsynth-midi");
name[63] = '\0';
if ((dev->client = jack_client_new (name)) == 0)
{
FLUID_LOG (FLUID_ERR, "Jack server not running?");
goto error_recovery;
}
jack_set_process_callback (dev->client, fluid_jack_midi_driver_process, dev);
dev->midi_port = jack_port_register (dev->client, "midi",
JACK_DEFAULT_MIDI_TYPE,
JackPortIsInput | JackPortIsTerminal, 0);
if (!dev->midi_port)
{
FLUID_LOG (FLUID_ERR, "Failed to create Jack MIDI port");
goto error_recovery;
}
/* tell the JACK server that we are ready to roll */
if (jack_activate (dev->client) != 0)
{
FLUID_LOG (FLUID_ERR, "Failed to activate FluidSynth Jack MIDI driver");
goto error_recovery;
}
return (fluid_midi_driver_t *)dev;
error_recovery:
delete_fluid_jack_midi_driver((fluid_midi_driver_t *)dev);
return NULL;
}
/*
* delete_fluid_jack_midi_driver
*/
int
delete_fluid_jack_midi_driver(fluid_midi_driver_t *p)
{
fluid_jack_midi_driver_t* dev;
int err;
dev = (fluid_jack_midi_driver_t *)p;
if (dev == NULL)
return FLUID_OK;
if (dev->client != NULL)
jack_client_close (dev->client);
if (dev->parser != NULL)
delete_fluid_midi_parser (dev->parser);
FLUID_FREE (dev);
return FLUID_OK;
}
/*
* fluid_jack_midi_driver_process
*/
static int
fluid_jack_midi_driver_process (jack_nframes_t nframes, void *arg)
{
fluid_jack_midi_driver_t *dev = (fluid_jack_midi_driver_t *)arg;
jack_midi_event_t midi_event;
fluid_midi_event_t *evt;
void *midi_buffer;
jack_nframes_t event_count;
jack_nframes_t event_index;
unsigned int i;
midi_buffer = jack_port_get_buffer (dev->midi_port, 0);
event_count = jack_midi_get_event_count (midi_buffer);
for (event_index = 0; event_index < event_count; event_index++)
{
jack_midi_event_get (&midi_event, midi_buffer, event_index);
/* let the parser convert the data into events */
for (i = 0; i < midi_event.size; i++)
{
evt = fluid_midi_parser_parse (dev->parser, midi_event.buffer[i]);
/* send the event to the next link in the chain */
if (evt != NULL) dev->driver.handler (dev->driver.data, evt);
}
}
return 0;
}

View file

@ -37,6 +37,15 @@ int delete_fluid_alsa_seq_driver(fluid_midi_driver_t* p);
void fluid_alsa_seq_driver_settings(fluid_settings_t* settings);
#endif
/* JACK */
#if JACK_SUPPORT
void fluid_jack_midi_driver_settings (fluid_settings_t *settings);
fluid_midi_driver_t *new_fluid_jack_midi_driver (fluid_settings_t *settings,
handle_midi_event_func_t handler,
void *data);
int delete_fluid_jack_midi_driver(fluid_midi_driver_t *p);
#endif
/* OSS */
#if OSS_SUPPORT
fluid_midi_driver_t* new_fluid_oss_midi_driver(fluid_settings_t* settings,
@ -87,6 +96,12 @@ struct fluid_mdriver_definition_t {
struct fluid_mdriver_definition_t fluid_midi_drivers[] = {
#if JACK_SUPPORT
{ "jack",
new_fluid_jack_midi_driver,
delete_fluid_jack_midi_driver,
fluid_jack_midi_driver_settings },
#endif
#if OSS_SUPPORT
{ "oss",
new_fluid_oss_midi_driver,
@ -133,6 +148,8 @@ void fluid_midi_driver_settings(fluid_settings_t* settings)
/* Set the default driver */
#if ALSA_SUPPORT
fluid_settings_register_str(settings, "midi.driver", "alsa_seq", 0, NULL, NULL);
#elif JACK_SUPPORT
fluid_settings_register_str(settings, "midi.driver", "jack", 0, NULL, NULL);
#elif OSS_SUPPORT
fluid_settings_register_str(settings, "midi.driver", "oss", 0, NULL, NULL);
#elif WINMIDI_SUPPORT
@ -150,6 +167,9 @@ void fluid_midi_driver_settings(fluid_settings_t* settings)
fluid_settings_add_option(settings, "midi.driver", "alsa_seq");
fluid_settings_add_option(settings, "midi.driver", "alsa_raw");
#endif
#if JACK_SUPPORT
fluid_settings_add_option(settings, "midi.driver", "jack");
#endif
#if OSS_SUPPORT
fluid_settings_add_option(settings, "midi.driver", "oss");
#endif