205 lines
8.1 KiB
JavaScript
205 lines
8.1 KiB
JavaScript
/**
|
|
* FtueAudioSelectionScreen
|
|
* Javascript that goes with the screen where initial
|
|
* selection of the audio devices takes place.
|
|
* Corresponds to /#ftue2
|
|
*/
|
|
(function(context,$) {
|
|
|
|
"use strict";
|
|
|
|
context.JK = context.JK || {};
|
|
context.JK.FtueWizard = function(app) {
|
|
var logger = context.JK.logger;
|
|
var jamClient = context.jamClient;
|
|
|
|
function beforeShow(data) {
|
|
var vuMeters = [
|
|
'#ftue-audio-input-vu-left',
|
|
'#ftue-audio-input-vu-right',
|
|
'#ftue-voice-input-vu-left',
|
|
'#ftue-voice-input-vu-right',
|
|
'#ftue-audio-output-vu-left',
|
|
'#ftue-audio-output-vu-right'
|
|
];
|
|
$.each(vuMeters, function() {
|
|
context.JK.VuHelpers.renderVU(this,
|
|
{vuType:"horizontal", lightCount: 12, lightWidth: 15, lightHeight: 3});
|
|
});
|
|
function randomVU() {
|
|
$.each(vuMeters, function() {
|
|
var val = Math.random();
|
|
context.JK.VuHelpers.updateVU(this, val);
|
|
});
|
|
}
|
|
context.setInterval(randomVU,175);
|
|
|
|
|
|
var faders = [
|
|
'#ftue-audio-input-fader',
|
|
'#ftue-voice-input-fader',
|
|
'#ftue-audio-output-fader'
|
|
];
|
|
$.each(faders, function() {
|
|
var fid = this.substr(1);
|
|
context.JK.FaderHelpers.renderFader(this,
|
|
{faderId: fid, faderType:"horizontal", width:163});
|
|
});
|
|
context.JK.FaderHelpers.subscribe('ftue', faderChange);
|
|
|
|
//loadDevices();
|
|
}
|
|
|
|
function afterShow(data) {
|
|
}
|
|
|
|
function faderChange(faderId, newValue, dragging) {
|
|
context.console.debug('faderChange fired. ID: ' + faderId +
|
|
', val: ' + newValue + ', dragging: ' + dragging);
|
|
}
|
|
|
|
//function loadDevices() {
|
|
//$('#choose-input-audio-device select').empty();
|
|
//$('#choose-output-audio-device select').empty();
|
|
//$('#choose-input-voice-device select').empty();
|
|
//var optionTemplate = $('#template_audio_device_item').html();
|
|
//var devices = context.jamClient.GetASIODevices();
|
|
//var inputOptions = [];
|
|
//var outputOptions = [];
|
|
//// We're going to build a list of individual choices...
|
|
//// Each 'value' will be device id.interface id.pin id (dot separated).
|
|
//// example: 1.1.1
|
|
//// Label will be a string with device name, interface name, pin name.
|
|
//var d, i, p;
|
|
//var deviceName, deviceId;
|
|
//var interfaceName, interfaceId;
|
|
//var pinName, pinId, isInput;
|
|
//var value, label, option;
|
|
//for (d=0; d<devices.length; d++) {
|
|
//deviceName = devices[d].device_name;
|
|
//deviceId = devices[d].device_id;
|
|
//for (i=0; i<devices[d].interfaces.length; i++) {
|
|
//interfaceName = devices[d].interfaces[i].interface_name;
|
|
//interfaceId = devices[d].interfaces[i].interface_id;
|
|
//for (p=0; p<devices[d].interfaces[i].pins.length; p++) {
|
|
//pinName = devices[d].interfaces[i].pins[p].pin_name;
|
|
//pinId = devices[d].interfaces[i].pins[p].pin_id;
|
|
//value = deviceId + "." + interfaceId + "." + pinId;
|
|
//label = deviceName + ":" + interfaceName + ":" + pinName;
|
|
//option = context.JK.fillTemplate(optionTemplate, { value: value, label: label});
|
|
//isInput = devices[d].interfaces[i].pins[p].is_input;
|
|
//if (isInput) {
|
|
//inputOptions.push(option);
|
|
//} else {
|
|
//outputOptions.push(option);
|
|
//}
|
|
//}
|
|
//}
|
|
//}
|
|
//$('#choose-input-audio-device select').html(inputOptions.join(''));
|
|
//$('#choose-output-audio-device select').html(outputOptions.join(''));
|
|
//$('#choose-input-voice-device select').html(inputOptions.join(''));
|
|
//}
|
|
|
|
/**
|
|
* Use the currently selecting input and output device to call SetASIOEnabled
|
|
* on the bridge.
|
|
*/
|
|
//function enableAudioDevices() {
|
|
//var input = $('#choose-input-audio-device select').val().split('.');
|
|
//var output = $('#choose-output-audio-device select').val().split('.');
|
|
//context.jamClient.SetASIOEnabled(
|
|
//parseInt(input[0], 10),
|
|
//parseInt(input[1], 10),
|
|
//parseInt(input[2], 10),
|
|
//parseInt(output[0], 10),
|
|
//parseInt(output[1], 10),
|
|
//parseInt(output[2], 10));
|
|
//}
|
|
|
|
function testLatency() {
|
|
//logger.debug("TODO: Test Latency with jamClient. Will simulate failure in 3 sec");
|
|
//context.setTimeout(latencyFailed, 3000);
|
|
logger.debug("TODO: Test Latency with jamClient. Will simulate success in 3 sec");
|
|
context.setTimeout(latencyPassed, 3000);
|
|
//$('#latency-testing p').html("Testing latency...");
|
|
//context.jamClient.TestASIOLatency("JK.latencyTestingComplete");
|
|
}
|
|
|
|
function latencyFailed() {
|
|
logger.debug("latencyFailed called.");
|
|
app.setWizardStep("5"); // Wizard step for failed test.
|
|
}
|
|
|
|
function latencyPassed() {
|
|
logger.debug("latencyPassed called.");
|
|
// Set the "Don't Show FTUE" bit.
|
|
context.jamClient.FTUESetStatus(true);
|
|
app.setWizardStep("6"); // Wizard step for passed test.
|
|
}
|
|
|
|
//function latencyTestingComplete() {
|
|
//logger.debug("latencyTestingComplete. Arguments:");
|
|
//logger.debug(arguments);
|
|
//$('#latency-testing p').html("Done.");
|
|
//}
|
|
|
|
|
|
function events() {
|
|
//$('#enableDevices').click(function() {
|
|
//enableAudioDevices();
|
|
//testLatency();
|
|
//});
|
|
|
|
}
|
|
|
|
/**
|
|
* This function loads the available audio devices from jamClient, and
|
|
* builds up the select dropdowns in the audio-settings step of the FTUE wizard.
|
|
*/
|
|
function loadAudioDevices() {
|
|
var funcs = [
|
|
jamClient.FTUEGetMusicInputs,
|
|
jamClient.FTUEGetMusicOutputs,
|
|
jamClient.FTUEGetChatInputs
|
|
];
|
|
var selectors = [
|
|
'[layout-wizard-step="2"] .audio-input select',
|
|
'[layout-wizard-step="2"] .voice-chat-input select',
|
|
'[layout-wizard-step="2"] .audio-output select'
|
|
];
|
|
var optionsHtml = '';
|
|
var optionFunc = function(deviceKey, index, list) {
|
|
optionsHtml += '<option value=' + deviceKey + '>' +
|
|
devices[deviceKey] + '</option>';
|
|
};
|
|
for (var i=0; i<funcs.length; i++) {
|
|
optionsHtml = '<option selected="selected" value="">Choose...</option>';
|
|
var devices = funcs[i](); // returns hash of device id: device name
|
|
var $select = $(selectors[i]);
|
|
$select.empty();
|
|
var sortedDeviceKeys = context._.keys(devices).sort();
|
|
context._.each(sortedDeviceKeys, optionFunc);
|
|
$select.html(optionsHtml);
|
|
}
|
|
}
|
|
|
|
function initialize() {
|
|
//
|
|
//events();
|
|
var dialogBindings = { 'beforeShow': beforeShow, 'afterShow': afterShow };
|
|
app.bindDialog('ftue', dialogBindings);
|
|
app.registerWizardStepFunction("4", testLatency);
|
|
loadAudioDevices();
|
|
}
|
|
|
|
// Expose publics
|
|
this.initialize = initialize;
|
|
|
|
// Expose callbacks for the bridge on the global namespace
|
|
//context.JK.latencyTestingComplete = latencyTestingComplete;
|
|
|
|
return this;
|
|
};
|
|
|
|
})(window,jQuery); |