diff --git a/pd/nw/dialog_prefs.html b/pd/nw/dialog_prefs.html
index 8148d0d5c749a533cc7d968e4e14f0e75c7ff62b..44b95fce4dbb9779d14673b487aa98159335cf7a 100644
--- a/pd/nw/dialog_prefs.html
+++ b/pd/nw/dialog_prefs.html
@@ -244,28 +244,94 @@
             <span data-i18n="[title]prefs.midi.input_title_tt">
               <span data-i18n="prefs.midi.input_title"></span>
             </span>
+            <table class="tab_settings">
+              <tr>
+                <td>1</td><td>
+                  <select id="midi_in1" onchange="dev_change(this);"></select>
+                </td>
+                <td align="right">6</td><td>
+                  <select id="midi_in6" onchange="dev_change(this);"></select>
+                </td>
+              </tr>
+              <tr>
+                <td>2</td><td>
+                  <select id="midi_in2" onchange="dev_change(this);"></select>
+                </td>
+                <td align="right">7</td><td>
+                  <select id="midi_in7" onchange="dev_change(this);"></select>
+                </td>
+              </tr>
+              <tr>
+                <td>3</td><td>
+                  <select id="midi_in3" onchange="dev_change(this);"></select>
+                </td>
+                <td align="right">8</td><td>
+                  <select id="midi_in8" onchange="dev_change(this);"></select>
+                </td>
+              </tr>
+              <tr>
+                <td>4</td><td>
+                  <select id="midi_in4" onchange="dev_change(this);"></select>
+                </td>
+                <td align="right">9</td><td>
+                  <select id="midi_in9" onchange="dev_change(this);"></select>
+                </td>
+              </tr>
+              <tr>
+                <td>5</td><td>
+                  <select id="midi_in5" onchange="dev_change(this);"></select>
+                </td>
+                <td align="right">10</td><td>
+                  <select id="midi_in10" onchange="dev_change(this);"></select>
+                </td>
+              </tr>
+            </table>
             <br/>
-            <select id="midi_in1" onchange="dev_change(this);"></select>
-            <br/>
-            <select id="midi_in2" onchange="dev_change(this);"></select>
-            <br/>
-            <select id="midi_in3" onchange="dev_change(this);"></select>
-            <br/>
-            <select id="midi_in4" onchange="dev_change(this);"></select>
-            <br/>
-
             <span data-i18n="[title]prefs.midi.output_title_tt">
               <span data-i18n="prefs.midi.output_title"></span>
             </span>
-            <br/>
-            <select id="midi_out1" onchange="dev_change(this);"></select>
-            <br/>
-            <select id="midi_out2" onchange="dev_change(this);"></select>
-            <br/>
-            <select id="midi_out3" onchange="dev_change(this);"></select>
-            <br/>
-            <select id="midi_out4" onchange="dev_change(this);"></select>
-            <br/>
+            <table class="tab_settings">
+              <tr>
+                <td>1</td><td>
+                  <select id="midi_out1" onchange="dev_change(this);"></select>
+                </td>
+                <td align="right">6</td><td>
+                  <select id="midi_out6" onchange="dev_change(this);"></select>
+                </td>
+              </tr>
+              <tr>
+                <td>2</td><td>
+                  <select id="midi_out2" onchange="dev_change(this);"></select>
+                </td>
+                <td align="right">7</td><td>
+                  <select id="midi_out7" onchange="dev_change(this);"></select>
+                </td>
+              </tr>
+              <tr>
+                <td>3</td><td>
+                  <select id="midi_out3" onchange="dev_change(this);"></select>
+                </td>
+                <td align="right">8</td><td>
+                  <select id="midi_out8" onchange="dev_change(this);"></select>
+                </td>
+              </tr>
+              <tr>
+                <td>4</td><td>
+                  <select id="midi_out4" onchange="dev_change(this);"></select>
+                </td>
+                <td align="right">9</td><td>
+                  <select id="midi_out9" onchange="dev_change(this);"></select>
+                </td>
+              </tr>
+              <tr>
+                <td>5</td><td>
+                  <select id="midi_out5" onchange="dev_change(this);"></select>
+                </td>
+                <td align="right">10</td><td>
+                  <select id="midi_out10" onchange="dev_change(this);"></select>
+                </td>
+              </tr>
+            </table>
           </div>
         </div>
 
@@ -615,10 +681,22 @@ function apply(save_prefs) {
         get_attr("pd-indevs", attrs)[1],
         get_attr("pd-indevs", attrs)[2],
         get_attr("pd-indevs", attrs)[3],
+        get_attr("pd-indevs", attrs)[4],
+        get_attr("pd-indevs", attrs)[5],
+        get_attr("pd-indevs", attrs)[6],
+        get_attr("pd-indevs", attrs)[7],
+        get_attr("pd-indevs", attrs)[8],
+        get_attr("pd-indevs", attrs)[9],
         get_attr("pd-outdevs", attrs)[0],
         get_attr("pd-outdevs", attrs)[1],
         get_attr("pd-outdevs", attrs)[2],
         get_attr("pd-outdevs", attrs)[3],
+        get_attr("pd-outdevs", attrs)[4],
+        get_attr("pd-outdevs", attrs)[5],
+        get_attr("pd-outdevs", attrs)[6],
+        get_attr("pd-outdevs", attrs)[7],
+        get_attr("pd-outdevs", attrs)[8],
+        get_attr("pd-outdevs", attrs)[9],
         midi_use_alsa ? get_attr("midi-indev-names", attrs).length : 0,
         midi_use_alsa ? get_attr("midi-outdev-names", attrs).length : 0
     );
@@ -705,7 +783,7 @@ function populate_midi_devs(type, attrs) {
     var dev_names = get_attr(type === "in" ?
         "midi-indev-names" : "midi-outdev-names", attrs);
     var i, j, opt, elem;
-    for (i = 0; i < 4; i++) {
+    for (i = 0; i < 10; i++) {
         elem = document.getElementById("midi_" + type + (i+1));
         // if the user changed the API, we need to remove the old devs
         while (elem.firstChild) {
diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js
index 7f3bffa474585e25a182bf0d711651e32d1a29f3..41de49aed641786618325d1dd9d9b0820282ac7d 100644
--- a/pd/nw/pdgui.js
+++ b/pd/nw/pdgui.js
@@ -4999,7 +4999,7 @@ function gui_pd_dsp(state) {
 
 function open_prefs() {
     if (!dialogwin["prefs"]) {
-        create_window("prefs", "prefs", 350, 470, 0, 0, null);
+        create_window("prefs", "prefs", 370, 470, 0, 0, null);
     }
 }
 
diff --git a/pd/src/s_midi.c b/pd/src/s_midi.c
index 51ffb91dffd002ffe7ecdac55ba68250a5726053..36dcc29fb3f8e84ab491ca9f15bbc07b8896b6ae 100644
--- a/pd/src/s_midi.c
+++ b/pd/src/s_midi.c
@@ -707,8 +707,10 @@ void glob_midi_properties(t_pd *dummy, t_floatarg flongform)
         /* these are the devices you're using: */
     int nindev, midiindev[MAXMIDIINDEV];
     int noutdev, midioutdev[MAXMIDIOUTDEV];
-    int midiindev1, midiindev2, midiindev3, midiindev4,
-        midioutdev1, midioutdev2, midioutdev3, midioutdev4;
+    int midiindev1, midiindev2, midiindev3, midiindev4, midiindev5,
+        midiindev6, midiindev7, midiindev8, midiindev9, midiindev10,
+        midioutdev1, midioutdev2, midioutdev3, midioutdev4, midioutdev5,
+        midioutdev6, midioutdev7, midioutdev8, midioutdev9, midioutdev10;
 
         /* these are all the devices on your system: */
     char indevlist[MAXNDEV*DEVDESCSIZE], outdevlist[MAXNDEV*DEVDESCSIZE];
@@ -750,16 +752,34 @@ void glob_midi_properties(t_pd *dummy, t_floatarg flongform)
     midiindev2 = (nindev > 1 &&  midiindev[1]>= 0 ? midiindev[1]+1 : 0);
     midiindev3 = (nindev > 2 &&  midiindev[2]>= 0 ? midiindev[2]+1 : 0);
     midiindev4 = (nindev > 3 &&  midiindev[3]>= 0 ? midiindev[3]+1 : 0);
-    midioutdev1 = (noutdev > 0 && midioutdev[0]>=0 ? midioutdev[0]+1 : 0);  
-    midioutdev2 = (noutdev > 1 && midioutdev[1]>=0 ? midioutdev[1]+1 : 0);  
-    midioutdev3 = (noutdev > 2 && midioutdev[2]>=0 ? midioutdev[2]+1 : 0);  
-    midioutdev4 = (noutdev > 3 && midioutdev[3]>=0 ? midioutdev[3]+1 : 0);  
+    midiindev5 = (nindev > 4 &&  midiindev[4]>= 0 ? midiindev[4]+1 : 0);
+    midiindev6 = (nindev > 5 &&  midiindev[5]>= 0 ? midiindev[5]+1 : 0);
+    midiindev7 = (nindev > 6 &&  midiindev[6]>= 0 ? midiindev[6]+1 : 0);
+    midiindev8 = (nindev > 7 &&  midiindev[7]>= 0 ? midiindev[7]+1 : 0);
+    midiindev9 = (nindev > 8 &&  midiindev[8]>= 0 ? midiindev[8]+1 : 0);
+    midiindev10 = (nindev > 9 &&  midiindev[9]>= 0 ? midiindev[9]+1 : 0);
+    midioutdev1 = (noutdev > 0 && midioutdev[0]>=0 ? midioutdev[0]+1 : 0);
+    midioutdev2 = (noutdev > 1 && midioutdev[1]>=0 ? midioutdev[1]+1 : 0);
+    midioutdev3 = (noutdev > 2 && midioutdev[2]>=0 ? midioutdev[2]+1 : 0);
+    midioutdev4 = (noutdev > 3 && midioutdev[3]>=0 ? midioutdev[3]+1 : 0);
+    midioutdev5 = (noutdev > 4 && midioutdev[4]>=0 ? midioutdev[4]+1 : 0);
+    midioutdev6 = (noutdev > 5 && midioutdev[5]>=0 ? midioutdev[5]+1 : 0);
+    midioutdev7 = (noutdev > 6 && midioutdev[6]>=0 ? midioutdev[6]+1 : 0);
+    midioutdev8 = (noutdev > 7 && midioutdev[7]>=0 ? midioutdev[7]+1 : 0);
+    midioutdev9 = (noutdev > 8 && midioutdev[8]>=0 ? midioutdev[8]+1 : 0);
+    midioutdev10 = (noutdev > 9 && midioutdev[9]>=0 ? midioutdev[9]+1 : 0);
 
     gui_start_array(); // input devices
     gui_i(midiindev1);
     gui_i(midiindev2);
     gui_i(midiindev3);
     gui_i(midiindev4);
+    gui_i(midiindev5);
+    gui_i(midiindev6);
+    gui_i(midiindev7);
+    gui_i(midiindev8);
+    gui_i(midiindev9);
+    gui_i(midiindev10);
     gui_end_array();
 
     gui_start_array(); // output devices
@@ -767,6 +787,12 @@ void glob_midi_properties(t_pd *dummy, t_floatarg flongform)
     gui_i(midioutdev2);
     gui_i(midioutdev3);
     gui_i(midioutdev4);
+    gui_i(midioutdev5);
+    gui_i(midioutdev6);
+    gui_i(midioutdev7);
+    gui_i(midioutdev8);
+    gui_i(midioutdev9);
+    gui_i(midioutdev10);
     gui_end_array();
 
     gui_start_array();
@@ -810,16 +836,16 @@ void glob_midi_properties(t_pd *dummy, t_floatarg flongform)
 void glob_midi_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv)
 {
     int i, nindev, noutdev;
-    int newmidiindev[4], newmidioutdev[4];
+    int newmidiindev[10], newmidioutdev[10];
     int alsadevin, alsadevout;
 
-    for (i = 0; i < 4; i++)
+    for (i = 0; i < 10; i++)
     {
         newmidiindev[i] = atom_getintarg(i, argc, argv);
-        newmidioutdev[i] = atom_getintarg(i+4, argc, argv);
+        newmidioutdev[i] = atom_getintarg(i+10, argc, argv);
     }
 
-    for (i = 0, nindev = 0; i < 4; i++)
+    for (i = 0, nindev = 0; i < 10; i++)
     {
         if (newmidiindev[i] > 0)
         {
@@ -827,7 +853,7 @@ void glob_midi_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv)
             nindev++;
         }
     }
-    for (i = 0, noutdev = 0; i < 4; i++)
+    for (i = 0, noutdev = 0; i < 10; i++)
     {
         if (newmidioutdev[i] > 0)
         {
@@ -835,8 +861,8 @@ void glob_midi_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv)
             noutdev++;
         }
     }
-    alsadevin = atom_getintarg(8, argc, argv);
-    alsadevout = atom_getintarg(9, argc, argv);
+    alsadevin = atom_getintarg(20, argc, argv);
+    alsadevout = atom_getintarg(21, argc, argv);
         
 #ifdef USEAPI_ALSA
             /* invent a story so that saving/recalling "settings" will