Commit fe228596 authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

fix midi dialog to accommodate the non-standard alsa midi settings in Pd

parent 62a08c25
......@@ -85,8 +85,8 @@
</div>
<table>
<tr>
<td>
Input Devices
<td data-i18n="[title]prefs.audio.input_title_tt">
<span data-i18n="prefs.audio.input_title"></span>
</td>
<td>
<span data-i18n="prefs.audio.channels"></span>
......@@ -145,8 +145,8 @@
</td>
</tr>
<tr>
<td>
Output Devices
<td data-i18n="[title]prefs.audio.output_title_tt">
<span data-i18n="prefs.audio.output_title"></span>
</td>
<td>
<span data-i18n="prefs.audio.channels"></span>
......@@ -215,24 +215,50 @@
</select>
</label>
</div>
<div class="tab_settings alsa_midi">
<label data-i18n="[title]prefs.midi.alsa_in_ports_tt">
<span data-i18n="prefs.midi.alsa_in_ports"></span>
<input type="text"
id="alsa_in_ports"
name="alsa_in_ports"
onchange="attr_change(this);">
</label>
<label data-i18n="[title]prefs.midi.alsa_out_ports_tt">
<span data-i18n="prefs.midi.alsa_out_ports"></span>
<input type="text"
id="alsa_out_ports"
name="alsa_out_ports"
onchange="attr_change(this);">
</label>
</div>
<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/>
<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/>
<div class="tab_settings midi_devices">
<span data-i18n="[title]prefs.midi.input_title_tt">
<span data-i18n="prefs.midi.input_title"></span>
</span>
<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/>
</div>
</div>
<div class="tab3">
......@@ -476,15 +502,13 @@ function populate_devs(type, attrs) {
}
function populate_midi_devs(type, attrs) {
var devs = get_attr(type === "in" ? "sys-indevs" : "sys-outdevs", attrs);
var i, j, opt, elem, chan_elem, chans;
pdgui.post("devs are " + devs);
pdgui.post("type is " + type + 1);
chans = get_attr("pd-" + type + "chans", attrs);
var dev_names = get_attr(type === "in" ?
"midi-indev-names" : "midi-outdev-names", attrs);
var i, j, opt, elem;
pdgui.post("dev names are " + dev_names);
pdgui.post("type is " + type);
for (i = 0; i < 4; i++) {
elem = document.getElementById(type + (i+1));
chan_elem = document.getElementById(type + "chans" + (i+1));
chan_elem.value = chans[i];
elem = document.getElementById("midi_" + type + (i+1));
// if the user changed the API, we need to remove the old devs
while (elem.firstChild) {
elem.removeChild(elem.firstChild);
......@@ -494,10 +518,10 @@ function populate_midi_devs(type, attrs) {
opt.value = -1;
opt.textContent = "None";
elem.appendChild(opt);
for (j = 0; j < devs.length; j++) {
for (j = 0; j < dev_names.length; j++) {
opt = document.createElement("option");
opt.value = j;
opt.textContent = devs[j];
opt.textContent = dev_names[j];
elem.appendChild(opt);
}
}
......@@ -609,6 +633,23 @@ function midi_prefs_callback(attrs) {
);
}
// Hide devs and only show the alsa in/out boxes. In the future
// we need an additional user friendly alsa interface here-- one that
// just lets the user pick a single input device and single output
// device, like LMMS does.
if (+get_attr("current-api", attrs) === 1) { // ALSA API
document.getElementsByClassName("midi_devices")[0]
.style.setProperty("display", "none");
document.getElementsByClassName("alsa_midi")[0]
.style.setProperty("display", "inherit");
} else {
document.getElementsByClassName("midi_devices")[0]
.style.setProperty("display", "inherit");
document.getElementsByClassName("alsa_midi")[0]
.style.setProperty("display", "none");
populate_midi_devs("in", attrs);
populate_midi_devs("out", attrs);
}
pdgui.resize_window(pd_object_callback);
}
......
......@@ -359,11 +359,23 @@
"blocksize": "blocksize",
"blocksize_tt": "number of samples in a block to be delivered to or received from the audio api",
"channels": "channels",
"channels_tt": "number of channels for this device"
"channels_tt": "number of channels for this device",
"input_title": "Input Devices",
"input_title_tt": "hardware devices used to get audio into Pd",
"output_title": "Output Devices",
"output_title_tt": "hardware devices to send audio from Pd"
},
"midi": {
"api": "midi api",
"api_tt": "midi backend or server used to communicate with midi devices"
"api_tt": "midi backend or server used to communicate with midi devices",
"alsa_in_ports": "input ports",
"alsa_in_ports_tt": "number of input ports for Pd",
"alsa_out_ports": "output ports",
"alsa_out_ports_tt": "number of output ports for Pd",
"input_title": "Input Devices",
"input_title_tt": "hardware devices used to get midi data into Pd",
"output_title": "Output Devices",
"output_title_tt": "hardware devices to send midi data from Pd"
},
"ok": "Ok",
"ok_tt": "Update the audio properties and close the dialog",
......
......@@ -3628,8 +3628,8 @@ function gui_midi_properties(gfxstub, sys_indevs, sys_outdevs,
pd_indevs, pd_outdevs, midi_attrs) {
var attrs = midi_attrs.concat([
"midi-apis", pd_midiapilist,
"sys-indevs", sys_indevs,
"sys-outdevs", sys_outdevs,
"midi-indev-names", sys_indevs,
"midi-outdev-names", sys_outdevs,
"pd-indevs", pd_indevs,
"pd-outdevs", pd_outdevs,
]);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment