Hi,

While testing Fluidsynth 1.0.8 in Windows, I've found some rough edges that 
I've tried to address in the attached patch.

* There was no support for the setting "midi.winmidi.device" (naming 
convention used by other drivers) to choose which midi device to open for 
input. 

* The command line client was unable to process file names given as command 
arguments, when compiling fluidsynth without readline.

Regards,
Pedro
diff -ruNB fluidsynth-old/src/fluid_mdriver.c fluidsynth-new/src/fluid_mdriver.c
--- fluidsynth-old/src/fluid_mdriver.c	Sat Aug 18 23:53:18 2007
+++ fluidsynth-new/src/fluid_mdriver.c	Mon Jun 23 15:12:16 2008
@@ -52,6 +52,7 @@
 					    handle_midi_event_func_t handler,
 					    void* event_handler_data);
 int delete_fluid_winmidi_driver(fluid_midi_driver_t* p);
+void fluid_winmidi_midi_driver_settings(fluid_settings_t* settings);
 #endif
 
 /* definitions for the MidiShare driver */
@@ -98,7 +99,7 @@
   { "winmidi",
     new_fluid_winmidi_driver,
     delete_fluid_winmidi_driver,
-    NULL },
+    fluid_winmidi_midi_driver_settings },
 #endif
 #if MIDISHARE_SUPPORT
   { "midishare",
diff -ruNB fluidsynth-old/src/fluid_winmidi.c fluidsynth-new/src/fluid_winmidi.c
--- fluidsynth-old/src/fluid_winmidi.c	Sat Aug 18 23:53:18 2007
+++ fluidsynth-new/src/fluid_winmidi.c	Mon Jun 23 20:26:50 2008
@@ -57,6 +57,24 @@
 static char* fluid_winmidi_input_error(int no);
 int fluid_winmidi_driver_status(fluid_midi_driver_t* p);
 
+void fluid_winmidi_midi_driver_settings(fluid_settings_t* settings)
+{
+  MMRESULT res;
+  MIDIINCAPS in_caps;
+  UINT i, num;	
+  fluid_settings_register_str(settings, "midi.winmidi.device", "default", 0, NULL, NULL);
+  num = midiInGetNumDevs();
+  if (num > 0) {
+    fluid_settings_add_option(settings, "midi.winmidi.device", "default");
+    for (i = 0; i < num; i++) {
+      res = midiInGetDevCaps(i, &in_caps, sizeof(MIDIINCAPS));
+      if (res == MMSYSERR_NOERROR) {
+        fluid_settings_add_option(settings, "midi.winmidi.device", in_caps.szPname);
+      }
+    }
+  }
+}
+
 /*
  * new_fluid_winmidi_driver
  */
@@ -69,6 +87,7 @@
   UINT i, err, num;
   MIDIINCAPS in_caps;
   int midi_num = 0;
+  char* devname = NULL;
 
   /* not much use doing anything */
   if (handler == NULL) {
@@ -85,6 +104,11 @@
   dev->driver.handler = handler;
   dev->driver.data = data;
 
+  /* get the device name. if none is specified, use the default device. */
+  if(!fluid_settings_getstr(settings, "midi.winmidi.device", &devname)) {
+    devname = "default";
+  }
+  
   /* check if there any midi devices installed */
   num = midiInGetNumDevs();
   if (num == 0) {
@@ -93,9 +117,21 @@
   }
 
   /* find the device */
-  for (i = 0; i < num; i++) {
-    res = midiInGetDevCaps(i, &in_caps, sizeof(LPMIDIINCAPS));
-    if (res == MMSYSERR_NOERROR) {
+  if (strcasecmp("default", devname) != 0) {
+    for (i = 0; i < num; i++) {
+      res = midiInGetDevCaps(i, &in_caps, sizeof(MIDIINCAPS));
+      if (res == MMSYSERR_NOERROR) {
+        FLUID_LOG(FLUID_DBG, "Testing midi device: %s\n", in_caps.szPname);
+        if (strcasecmp(devname, in_caps.szPname) == 0) {
+          FLUID_LOG(FLUID_DBG, "Selected midi device number: %d\n", i);
+          midi_num = i;
+          break;
+        }
+      }
+    }
+    if (midi_num == 0) {
+      FLUID_LOG(FLUID_ERR, "Device <%s> does not exists", devname);
+      goto error_recovery;
     }
   }
 
diff -ruNB fluidsynth-old/src/fluidsynth.c fluidsynth-new/src/fluidsynth.c
--- fluidsynth-old/src/fluidsynth.c	Sun Nov 11 11:09:48 2007
+++ fluidsynth-new/src/fluidsynth.c	Sun Jun 22 15:07:16 2008
@@ -264,7 +264,7 @@
     char *optarg;
 
     /* Skip non switch arguments (assume they are file names) */
-    if ((argv[i][0] != '-') || (argv[i][1] == '\0')) continue;
+    if ((argv[i][0] != '-') || (argv[i][1] == '\0')) break;
 
     c = argv[i][1];
 
_______________________________________________
fluid-dev mailing list
fluid-dev@nongnu.org
http://lists.nongnu.org/mailman/listinfo/fluid-dev

Reply via email to