jam-cloud/app/assets/javascripts/configureTrack.js

789 lines
34 KiB
JavaScript

(function(context,$) {
"use strict";
context.JK = context.JK || {};
context.JK.ConfigureTrackDialog = function(app, myTracks, sessionId, sessionModel) {
var logger = context.JK.logger;
var myTrackCount;
var ASSIGNMENT = {
CHAT: -2,
OUTPUT: -1,
UNASSIGNED: 0,
TRACK1: 1,
TRACK2: 2
};
var VOICE_CHAT = {
NO_CHAT: "-1",
CHAT: "0",
SESSION: "1",
MIC: "2"
};
var instrument_array = [];
// dialog variables
var inputUnassignedList = [];
var track1AudioInputChannels = [];
var track2AudioInputChannels = [];
var outputUnassignedList = [];
var outputAssignedList = [];
var chatUnassignedList = [];
var chatAssignedList = [];
var chatOtherUnassignedList = [];
var chatOtherAssignedList = [];
var removedAudioChannels = {};
var removedVoiceChatChannels = {};
var devices = [];
var originalDeviceId;
var originalVoiceChat;
var currentVoiceChat;
var configure_audio_instructions = {
"Win32": "Choose the audio profile you would like to use for this session. If needed, use arrow buttons to assign audio inputs " +
"to your tracks, to indicate what instrument you are playing on each track, and to assign audio outputs for listening. " +
"If you want to use a new audio device you have not tested/certified for latency using JamKazam, click the Add New Audio " +
"Gear button to test that device.",
"MacOSX": "Choose the audio profile you would like to use for this session. If needed, use arrow buttons to assign audio inputs " +
"to your tracks, to indicate what instrument you are playing on each track, and to assign audio outputs for listening. " +
"If you want to use a new audio device you have not tested/certified for latency using JamKazam, click the Add New Audio " +
"Gear button to test that device.",
"Unix": "Choose the audio profile you would like to use for this session. If needed, use arrow buttons to assign audio inputs " +
"to your tracks, to indicate what instrument you are playing on each track, and to assign audio outputs for listening. " +
"If you want to use a new audio device you have not tested/certified for latency using JamKazam, click the Add New Audio " +
"Gear button to test that device."
};
var configure_voice_instructions = "If you are using a microphone to capture your instrumental or vocal audio, you can simply use that mic " +
"for both music and chat. Otherwise, choose a device to use for voice chat, and use arrow buttons to " +
"select an input on that device.";
function toggleTrack2ConfigDetails(visible) {
if (visible) {
$('#track2-details').show();
$('#track2-input-buttons').show();
$('#track1-input').height('92px');
$('#track1-instrument').height('92px');
$('#track1-input-buttons').addClass('mt30');
$('#track1-input-buttons').removeClass('mt65');
}
else {
$('#track2-details').hide();
$('#track2-input-buttons').hide();
$('#track1-input').height('195px');
$('#track1-instrument').height('195px');
$('#track1-input-buttons').addClass('mt65');
$('#track1-input-buttons').removeClass('mt30');
}
}
function events() {
$('#tab-configure-audio').unbind("click");
$('#tab-configure-audio').click(function() {
// validate voice chat settings
if (validateVoiceChatSettings(true)) {
showMusicAudioPanel(false);
}
});
$('#tab-configure-voice').unbind("click");
$('#tab-configure-voice').click(function() {
// validate audio settings
if (validateAudioSettings(true)) {
showVoiceChatPanel(false);
}
});
// Track 1 Add
$('#img-track1-input-add').unbind("click");
$('#img-track1-input-add').click(function() {
// REMOVE FROM VOICE CHAT UNUSED IF NECESSARY
$('#audio-inputs-unused > option:selected').each(function() {
var deviceId = this.value;
var description = this.description;
$(this).remove().appendTo('#track1-input');
if ($('#voice-inputs-unused > option[value="' + deviceId + '"]').length > 0) {
logger.debug("Removing " + deviceId + " from Voice Chat Unused");
$('#voice-inputs-unused > option[value="' + deviceId + '"]').remove();
var option = '<option value="' + deviceId + '">' + description + '</option>';
removedVoiceChatChannels[deviceId] = option;
}
});
syncVoiceChatDialog();
});
// Track 1 Remove
$('#img-track1-input-remove').unbind("click");
$('#img-track1-input-remove').click(function() {
// ADD TO VOICE CHAT UNUSED IF NECESSARY
$("#track1-input > option:selected").each(function() {
var deviceId = this.value;
var description = this.description;
if ($('#track1-input > option[value="' + deviceId + '"]').length > 0) {
restoreVoiceChatOption(deviceId);
}
$(this).remove().appendTo('#audio-inputs-unused');
});
syncVoiceChatDialog();
});
// Track 2 Add
$('#img-track2-input-add').unbind("click");
$('#img-track2-input-add').click(function() {
// REMOVE FROM VOICE CHAT UNUSED IF NECESSARY
$('#audio-inputs-unused > option:selected').each(function() {
var deviceId = this.value;
var description = this.description;
$(this).remove().appendTo('#track2-input');
if ($('#voice-inputs-unused > option[value="' + deviceId + '"]').length > 0) {
logger.debug("Removing " + deviceId + " from Voice Chat Unused");
$('#voice-inputs-unused > option[value="' + deviceId + '"]').remove();
var option = '<option value="' + deviceId + '">' + description + '</option>';
removedVoiceChatChannels[deviceId] = option;
}
});
syncVoiceChatDialog();
});
// Track 2 Remove
$('#img-track2-input-remove').unbind("click");
$('#img-track2-input-remove').click(function() {
// ADD TO VOICE CHAT UNUSED IF NECESSARY
$("#track2-input > option:selected").each(function() {
var deviceId = this.value;
if ($('#track2-input > option[value="' + deviceId + '"]').length > 0) {
restoreVoiceChatOption(deviceId);
}
$(this).remove().appendTo('#audio-inputs-unused');
});
syncVoiceChatDialog();
});
// Audio Output Add
$('#img-audio-output-add').unbind("click");
$('#img-audio-output-add').click(function() {
$('#audio-output-unused > option:selected').remove().appendTo('#audio-output-selection');
});
// Audio Output Remove
$('#img-audio-output-remove').unbind("click");
$('#img-audio-output-remove').click(function() {
$('#audio-output-selection > option:selected').remove().appendTo('#audio-output-unused');
});
// Voice Chat Add
$('#img-voice-input-add').unbind("click");
$('#img-voice-input-add').click(function() {
// REMOVE FROM AUDIO UNUSED IF NECESSARY
syncMusicAudioDialog();
$('#voice-inputs-unused > option:selected').remove().appendTo('#voice-inputs-selection');
});
$('#img-voice-input-remove').unbind("click");
$('#img-voice-input-remove').click(function() {
// ADD TO AUDIO UNUSED IF NECESSARY
$("#voice-inputs-selection > option:selected").each(function() {
var deviceId = this.value;
var description = this.text;
if ($('#voice-inputs-selection > option[value="' + deviceId + '"]').length > 0) {
if (removedAudioChannels[deviceId]) {
logger.debug("Adding " + deviceId + " to Music Audio Unused");
var option = '<option value="' + deviceId + '">' + description + '</option>';
$('#audio-inputs-unused').append(option);
delete removedAudioChannels[deviceId];
}
$('#voice-inputs-unused > option[value="' + deviceId + '"]').remove();
}
$(this).remove().appendTo('#voice-inputs-unused');
});
});
$('#audio-drivers').change(function() {
audioDriverChanged();
});
$('#voice-chat-device').change(function() {
voiceChatChanged();
});
$('#btn-driver-settings').click(function() {
context.jamClient.TrackOpenControlPanel();
});
$('#btn-cancel-new-audio').click(context.JK.showOverlay);
// $('#btn-cancel-new-audio').click(function() {
// app.layout.closeDialog('add-new-audio-gear');
// });
$('#btn-error-ok').click(context.JK.showOverlay);
// $('#btn-error-ok').click(function() {
// app.layout.closeDialog('error-dialog');
// });
$('#btn-save-settings').unbind("click");
$('#btn-save-settings').click(saveSettings);
$('#btn-cancel-settings').click(cancelSettings);
}
function syncVoiceChatDialog() {
logger.debug("syncVoiceChatDialog:originalVoiceChat=" + originalVoiceChat);
var $option1 = $('#voice-chat-device > option[value="1"]');
// remove Session Audio option from voice chat if none are available
if ($('#audio-inputs-unused > option').size() === 0 && originalVoiceChat != VOICE_CHAT.SESSION) {
logger.debug('Removing Option 1 from Voice Chat dropdown.');
$option1.remove();
}
else {
// make sure it's not already in list before adding back
if ($option1.length === 0) {
logger.debug('Adding Option 1 back to Voice Chat dropdown.');
$('#voice-chat-device').prepend('<option value="1">Use an input on my session audio device for chat</option>');
}
}
}
function restoreVoiceChatOption(deviceId) {
if (removedVoiceChatChannels[deviceId]) {
logger.debug("Adding " + deviceId + " to Voice Chat Unused");
$('#voice-inputs-unused').append(removedVoiceChatChannels[deviceId]);
delete removedVoiceChatChannels[deviceId];
}
}
// this function removes items from the unused box on the Music Audio tab
function syncMusicAudioDialog() {
$("#voice-inputs-unused > option:selected").each(function() {
var deviceId = this.value;
var description = this.text;
if ($('#audio-inputs-unused > option[value="' + deviceId + '"]').length > 0) {
logger.debug("Removing " + deviceId + " from Music Audio Unused");
$('#audio-inputs-unused > option[value="' + deviceId + '"]').remove();
var option = '<option value="' + deviceId + '">' + description + '</option>';
removedAudioChannels[deviceId] = option;
}
});
}
// TODO: figure out how to handle this in layout.js for layered popups
function showOverlay() {
$('.dialog-overlay').show();
}
function audioDriverChanged() {
// ensure any channels removed are restored
// var keys = Object.keys(removedVoiceChatChannels);
// for (var i=0; i < keys.length; i++) {
// restoreVoiceChatOptions(keys[i]);
// }
context.jamClient.TrackSetMusicDevice($('#audio-drivers').val());
removedAudioChannels = {};
removedVoiceChatChannels = {};
context.jamClient.TrackLoadAssignments();
initDialogData();
// refresh dialog
showVoiceChatPanel(true);
showMusicAudioPanel(true);
}
function voiceChatChanged() {
// ensure any channels removed are restored
var keys = Object.keys(removedAudioChannels);
for (var i=0; i < keys.length; i++) {
$('#audio-inputs-unused').append(removedAudioChannels[keys[i]]);
delete removedAudioChannels[keys[i]];
}
showVoiceChatPanel(true);
}
function configureDriverSettingsButton() {
if (context.jamClient.TrackHasControlPanel()) {
//logger.debug("Showing DRIVER SETTINGS button...");
$('#btn-driver-settings').show();
}
else {
//logger.debug("Hiding DRIVER SETTINGS button...");
$('#btn-driver-settings').hide();
}
}
function showMusicAudioPanel(refreshLists) {
_setInstructions('audio');
_activateTab('audio');
if (refreshLists) {
$('#audio-drivers').empty();
// determine correct music device to preselect
var deviceId = context.jamClient.TrackGetMusicDeviceID();
logger.debug("deviceId = " + deviceId);
// load Audio Driver dropdown
devices = context.jamClient.TrackGetDevices();
var keys = Object.keys(devices);
for (var i=0; i < keys.length; i++) {
var template = $('#template-option').html();
var isSelected = "";
if (keys[i] === deviceId) {
isSelected = "selected";
}
var html = context.JK.fillTemplate(template, {
value: keys[i],
label: devices[keys[i]],
selected: isSelected
});
$('#audio-drivers').append(html);
}
if (deviceId === '') {
context.jamClient.TrackSetMusicDevice($('#audio-drivers').val());
}
configureDriverSettingsButton();
$('#audio-inputs-unused').empty();
$('#track1-input').empty();
$('#track1-instrument').empty();
$('#track2-input').empty();
$('#track2-instrument').empty();
$('#audio-output-unused').empty();
$('#audio-output-selection').empty();
//initDialogData();
// load Unused Inputs
context.JK.loadOptions($('#template-option').html(), $('#audio-inputs-unused'), inputUnassignedList, "id", "name", -1);
// load Track 1 Input(s)
context.JK.loadOptions($('#template-option').html(), $('#track1-input'), track1AudioInputChannels, "id", "name", -1);
// load Track 1 Instrument
var current_instrument = context.jamClient.TrackGetInstrument(ASSIGNMENT.TRACK1);
// if no instrument is stored on the backend, the user is opening this dialog for the first time after FTUE;
// initialize to the user's first instrument
if (current_instrument === 0) {
if (context.JK.userMe.instruments && context.JK.userMe.instruments.length > 0) {
var instrument_desc = context.JK.userMe.instruments[0].description;
current_instrument = context.JK.server_to_client_instrument_map[instrument_desc].client_id;
}
}
context.JK.loadOptions($('#template-option').html(), $('#track1-instrument'), instrument_array, "id", "description", current_instrument);
// load Track 2 config details if necessary
if (myTrackCount > 1) {
// load Track 2 Input(s)
context.JK.loadOptions($('#template-option').html(), $('#track2-input'), track2AudioInputChannels, "id", "name", -1);
// load Track 2 Instrument
current_instrument = context.jamClient.TrackGetInstrument(ASSIGNMENT.TRACK2);
context.JK.loadOptions($('#template-option').html(), $('#track2-instrument'), instrument_array, "id", "description", current_instrument);
}
// load Unused Outputs
context.JK.loadOptions($('#template-option').html(), $('#audio-output-unused'), outputUnassignedList, "id", "name", -1);
// load Session Audio Output
context.JK.loadOptions($('#template-option').html(), $('#audio-output-selection'), outputAssignedList, "id", "name", -1);
}
}
function showVoiceChatPanel(refreshLists) {
_setInstructions('voice');
_activateTab('voice');
syncVoiceChatDialog();
if (refreshLists) {
$('#voice-inputs-unused').empty();
$('#voice-inputs-selection').empty();
//initDialogData();
var chatOption = $('#voice-chat-device').val();
if (chatOption === VOICE_CHAT.SESSION) {
context.JK.loadOptions($('#template-option').html(), $('#voice-inputs-unused'), chatUnassignedList, "id", "name", -1);
context.JK.loadOptions($('#template-option').html(), $('#voice-inputs-selection'), chatAssignedList, "id", "name", -1);
// This goes through each unused audio input and checks whether it already exists in the unused Voice Chat Unused box.
// If it doesn't, we add it to the unused Voice Chat list.
$('#audio-inputs-unused > option').each(function() {
var deviceId = this.value;
var description = this.text;
if ($('#voice-inputs-unused > option[value="' + deviceId + '"]').length === 0) {
var option = '<option value="' + deviceId + '">' + description + '</option>';
$('#voice-inputs-unused').append(option);
}
});
}
// populate with voice devices
else if (chatOption === VOICE_CHAT.CHAT) {
context.JK.loadOptions($('#template-option').html(), $('#voice-inputs-unused'), chatOtherUnassignedList, "id", "name", -1);
context.JK.loadOptions($('#template-option').html(), $('#voice-inputs-selection'), chatOtherAssignedList, "id", "name", -1);
}
// disable inputs
else if (chatOption === VOICE_CHAT.MIC || chatOption === VOICE_CHAT.NO_CHAT) {
}
}
}
function _activateTab(type) {
if (type === 'voice') {
$('div[tab-id="music-audio"]').hide();
$('div[tab-id="voice-chat"]').show();
$('#tab-configure-audio').removeClass('selected');
$('#tab-configure-voice').addClass('selected');
}
else {
$('div[tab-id="music-audio"]').show();
$('div[tab-id="voice-chat"]').hide();
$('#tab-configure-audio').addClass('selected');
$('#tab-configure-voice').removeClass('selected');
}
}
function initDialogData() {
// set arrays
inputUnassignedList = _loadList(ASSIGNMENT.UNASSIGNED, true, false);
logger.debug("inputUnassignedList=" + JSON.stringify(inputUnassignedList));
track1AudioInputChannels = _loadList(ASSIGNMENT.TRACK1, true, false);
logger.debug("track1AudioInputChannels=" + JSON.stringify(track1AudioInputChannels));
track2AudioInputChannels = _loadList(ASSIGNMENT.TRACK2, true, false);
logger.debug("track2AudioInputChannels=" + JSON.stringify(track2AudioInputChannels));
outputUnassignedList = _loadList(ASSIGNMENT.UNASSIGNED, false, false);
outputAssignedList = _loadList(ASSIGNMENT.OUTPUT, false, false);
chatUnassignedList = _loadList(ASSIGNMENT.UNASSIGNED, true, false);
logger.debug("chatUnassignedList=" + JSON.stringify(chatUnassignedList));
chatAssignedList = _loadList(ASSIGNMENT.CHAT, true, false);
logger.debug("chatAssignedList=" + JSON.stringify(chatAssignedList));
chatOtherUnassignedList = _loadList(ASSIGNMENT.UNASSIGNED, true, true);
logger.debug("chatOtherUnassignedList=" + JSON.stringify(chatOtherUnassignedList));
chatOtherAssignedList = _loadList(ASSIGNMENT.CHAT, true, true);
logger.debug("chatOtherAssignedList=" + JSON.stringify(chatOtherAssignedList));
}
// TODO: copied in addTrack.js - refactor to common place
function _loadList(assignment, input, chat) {
var list = [];
// get data needed for listboxes
var channels = context.jamClient.TrackGetChannels();
var musicDevices = context.jamClient.TrackGetMusicDeviceNames(input);
// SEE loadList function in TrackAssignGui.cpp of client code
$.each(channels, function(index, val) {
if (input !== val.input) {
return;
}
var currAssignment = context.jamClient.TrackGetAssignment(val.id, val.input);
if (assignment !== currAssignment) {
return;
}
// logger.debug("channel id=" + val.id + ", channel input=" + val.input + ", channel assignment=" + currAssignment +
// ", channel name=" + val.name + ", channel type=" + val.device_type + ", chat=" + val.chat);
var os = context.jamClient.GetOSAsString();
if (os === context.JK.OS.WIN32) {
if (chat && ($.inArray(val.device_id, musicDevices) > -1 || context.jamClient.TrackIsMusicDeviceType(val.device_type))) {
return;
}
}
else {
if (chat && ($.inArray(val.device_id, musicDevices) > -1 || !context.jamClient.TrackIsMusicDeviceType(val.device_type))) {
return;
}
}
if (!chat && $.inArray(val.device_id, musicDevices) === -1) {
return;
}
if ((chat && !val.chat) || (!chat && val.chat)) {
return;
}
list.push(val);
});
return list;
}
function saveSettings() {
if (!validateAudioSettings(false)) {
return;
}
if (!validateVoiceChatSettings(false)) {
return;
}
saveAudioSettings();
saveVoiceChatSettings();
context.jamClient.TrackSaveAssignments();
originalDeviceId = $('#audio-drivers').val();
app.layout.closeDialog('configure-audio');
// refresh Session screen
sessionModel.refreshCurrentSession();
}
function saveAudioSettings() {
context.jamClient.TrackSetMusicDevice($('#audio-drivers').val());
// UNASSIGNED INPUTS
$('#audio-inputs-unused > option').each(function() {
logger.debug("Marking " + this.value + " as unassigned input.");
context.jamClient.TrackSetAssignment(this.value, true, ASSIGNMENT.UNASSIGNED);
});
// TRACK 1 INPUTS
$('#track1-input > option').each(function() {
logger.debug("Saving track 1 input = " + this.value);
context.jamClient.TrackSetAssignment(this.value, true, ASSIGNMENT.TRACK1);
});
// TRACK 1 INSTRUMENT
var instrumentVal = $('#track1-instrument').val();
var instrumentText = $('#track1-instrument > option:selected').text().toLowerCase();
logger.debug("Saving track 1 instrument = " + instrumentVal);
context.jamClient.TrackSetInstrument(ASSIGNMENT.TRACK1, instrumentVal);
// UPDATE SERVER
//logger.debug("Updating track " + myTracks[0].trackId + " with instrument " + instrumentText);
var data = {};
data.instrument_id = instrumentText;
sessionModel.updateTrack(sessionId, myTracks[0].trackId, data);
if (myTrackCount > 1) {
// TRACK 2 INPUTS
$('#track2-input > option').each(function() {
logger.debug("Saving track 2 input = " + this.value);
context.jamClient.TrackSetAssignment(this.value, true, ASSIGNMENT.TRACK2);
});
// TRACK 2 INSTRUMENT
instrumentVal = $('#track2-instrument').val();
instrumentText = $('#track2-instrument > option:selected').text().toLowerCase();
logger.debug("Saving track 2 instrument = " + instrumentVal);
context.jamClient.TrackSetInstrument(ASSIGNMENT.TRACK2, instrumentVal);
// UPDATE SERVER
//logger.debug("Updating track " + myTracks[1].trackId + " with instrument " + instrumentText);
data.instrument_id = instrumentText;
sessionModel.updateTrack(sessionId, myTracks[1].trackId, data);
}
// UNASSIGNED OUTPUTS
$('#audio-output-unused > option').each(function() {
logger.debug("Marking " + this.value + " as unassigned output.");
context.jamClient.TrackSetAssignment(this.value, false, ASSIGNMENT.UNASSIGNED);
});
// OUTPUT
$('#audio-output-selection > option').each(function() {
logger.debug("Saving session audio output = " + this.value);
context.jamClient.TrackSetAssignment(this.value, false, ASSIGNMENT.OUTPUT);
});
}
function saveVoiceChatSettings() {
currentVoiceChat = $('#voice-chat-device').val();
logger.debug("Calling TrackSetChatUsesMusic with value = " + currentVoiceChat);
context.jamClient.TrackSetChatUsesMusic(currentVoiceChat);
// UNASSIGNED VOICE CHAT
$('#voice-inputs-unused > option').each(function() {
logger.debug("Marking " + this.value + " as unassigned voice input.");
context.jamClient.TrackSetAssignment(this.value, true, ASSIGNMENT.UNASSIGNED);
});
// VOICE CHAT INPUT
$("#voice-inputs-selection > option").each(function() {
logger.debug("Saving chat input = " + this.value);
context.jamClient.TrackSetAssignment(this.value, true, ASSIGNMENT.CHAT);
});
}
function cancelSettings() {
// reset to original device ID
context.jamClient.TrackSetMusicDevice(originalDeviceId);
}
function validateAudioSettings(allowEmptyInput) {
var isValid = true;
var noTrackErrMsg = 'You must assign at least one input port to each of your tracks. Please update your settings to correct this. If you want to delete a track, please return to the session screen and delete the track by clicking the "x" box in the upper right-hand corner of the track.';
var noInstrumentErrMsg = 'You must specify what instrument is being played for each track. Please update your settings to correct this.';
var outputErrMsg = 'You must assign two output ports for stereo session audio to hear music. Please update your settings to correct this.';
var errMsg;
// if there are no inputs remaining then allow the user to switch to the Voice Chat tab
// to remove some
if (allowEmptyInput && $('#audio-inputs-unused > option').size() === 0) {
return isValid;
}
else {
// verify Track 1 Input and Instrument exist
if ($('#track1-input > option').size() === 0 || $('#track1-input > option').size() > 2) {
errMsg = noTrackErrMsg;
isValid = false;
}
if (isValid) {
if ($('#track1-instrument > option:selected').length === 0) {
errMsg = noInstrumentErrMsg;
isValid = false;
}
}
logger.debug("validateAudioSettings:myTrackCount=" + myTrackCount);
// if Track 2 exists, verify Input and Instrument exist
if (isValid && myTrackCount > 1) {
if ($('#track2-input > option').size() === 0 || $('#track2-input > option').size() > 2) {
errMsg = noTrackErrMsg;
isValid = false;
}
if (isValid && $('#track2-instrument > option:selected').length === 0) {
errMsg = noInstrumentErrMsg;
isValid = false;
}
}
// verify Session Audio Output exists
if (isValid && $('#audio-output-selection > option').size() !== 2) {
errMsg = outputErrMsg;
isValid = false;
}
if (!isValid) {
context.JK.showErrorDialog(app, errMsg, "invalid settings");
}
}
return isValid;
}
function validateVoiceChatSettings(allowEmptyInput) {
var isValid = true;
var noTrackErrMsg = 'You must select a voice input.';
var errMsg;
if (allowEmptyInput && $('#voice-inputs-unused > option').size() === 0) {
return isValid;
}
else {
currentVoiceChat = $('#voice-chat-device').val();
if (currentVoiceChat === VOICE_CHAT.SESSION || currentVoiceChat === VOICE_CHAT.CHAT) {
if ($('#voice-inputs-selection > option').size() === 0 || $('#voice-inputs-selection > option').size() > 2) {
errMsg = noTrackErrMsg;
isValid = false;
}
}
else if (currentVoiceChat === VOICE_CHAT.MIC || currentVoiceChat === VOICE_CHAT.NO_CHAT) {
// NO VALIDATION NEEDED
}
if (!isValid) {
context.JK.showErrorDialog(app, errMsg, "invalid settings");
}
}
return isValid;
}
function _setInstructions(type) {
if (type === 'audio') {
var os = context.jamClient.GetOSAsString();
$('#instructions', 'div[layout-id="configure-audio"]').html(configure_audio_instructions[os]);
}
else if (type === 'voice') {
$('#instructions', 'div[layout-id="configure-audio"]').html(configure_voice_instructions);
}
}
function _init() {
// load instrument array for populating listboxes, using client_id in instrument_map as ID
context.JK.listInstruments(app, function(instruments) {
$.each(instruments, function(index, val) {
instrument_array.push({"id": context.JK.server_to_client_instrument_map[val.description].client_id, "description": val.description});
});
});
originalVoiceChat = context.jamClient.TrackGetChatUsesMusic();
logger.debug("originalVoiceChat=" + originalVoiceChat);
$('#voice-chat-device').val(originalVoiceChat);
originalDeviceId = context.jamClient.TrackGetMusicDeviceID();
context.jamClient.TrackLoadAssignments();
initDialogData();
}
this.initialize = function() {
events();
_init();
myTrackCount = myTracks.length;
logger.debug("initialize:myTrackCount=" + myTrackCount);
toggleTrack2ConfigDetails(myTrackCount > 1);
};
this.showMusicAudioPanel = showMusicAudioPanel;
this.showVoiceChatPanel = showVoiceChatPanel;
return this;
};
})(window,jQuery);