diff --git a/pd/src/s_midi.c b/pd/src/s_midi.c
index 36dcc29fb3f8e84ab491ca9f15bbc07b8896b6ae..0258cd6303606d7d6cd024ae3c6ac0c77a267271 100644
--- a/pd/src/s_midi.c
+++ b/pd/src/s_midi.c
@@ -590,19 +590,21 @@ static void sys_save_midi_params(
 void sys_open_midi(int nmidiindev, int *midiindev,
     int nmidioutdev, int *midioutdev, int enable)
 {
+    if (enable)
+    {
 #ifdef USEAPI_ALSA
-  midi_alsa_init();
+        midi_alsa_init();
 #endif
 #ifdef USEAPI_OSS
-    midi_oss_init();
+        midi_oss_init();
 #endif
-    if (enable)
 #ifdef USEAPI_ALSA
-      if (sys_midiapi == API_ALSA)
-        sys_alsa_do_open_midi(nmidiindev, midiindev, nmidioutdev, midioutdev);
-      else
+        if (sys_midiapi == API_ALSA)
+            sys_alsa_do_open_midi(nmidiindev, midiindev, nmidioutdev, midioutdev);
+        else
 #endif /* ALSA */
-        sys_do_open_midi(nmidiindev, midiindev, nmidioutdev, midioutdev);
+            sys_do_open_midi(nmidiindev, midiindev, nmidioutdev, midioutdev);
+    }
     sys_save_midi_params(nmidiindev, midiindev,
         nmidioutdev, midioutdev);