VRFS-292 configure track work

This commit is contained in:
Brian Smith 2013-05-18 01:59:25 -04:00
parent 9a948d4633
commit ab4237addf
3 changed files with 153 additions and 37 deletions

View File

@ -201,12 +201,12 @@
// But we'll just build a list of names and fake it
var devices = [
"M-Audio FW Audiophile: FW AP 1/2",
"M-Audio FW Audiophile: FW Multi 1/2",
"M-Audio FW Audiophile: FW SPDIF 1/2",
//"M-Audio FW Audiophile: FW Multi 1/2",
//"M-Audio FW Audiophile: FW SPDIF 1/2",
"Realtek High Definition Audio: Realtek HD Digital",
"Realtek High Definition Audio: Realtek HD Line",
"Realtek High Definition Audio: Realtek HD Audio Mic",
"Realtek High Definition Audio: Realtek HD Audio Stereo",
// "Realtek High Definition Audio: Realtek HD Line",
// "Realtek High Definition Audio: Realtek HD Audio Mic",
// "Realtek High Definition Audio: Realtek HD Audio Stereo",
"WebCamDV WDM Audio Capture: WebCamDV Audio"
];
var suffixes = [ " - Left", " - Right", " - Left", " - Right"];

View File

@ -248,7 +248,7 @@
var template = $('#template-musician-option').html();
$.each(musicianArray, function(index, val) {
// check if this musician is already in the filter
if ( $('#musician-list option[value=' + val.id + ']').length == 0 ) {
if ( $('#musician-list option[value=' + val.id + ']').length === 0 ) {
var musicianOptionHtml = context.JK.fillTemplate(template, {value: val.id, label: val.name});
$('#musician-list').append(musicianOptionHtml);
}

View File

@ -20,6 +20,12 @@
TRACK2: 2
};
var VOICE_CHAT = {
CHAT: "0",
SESSION: "1",
MIC: "2"
};
var instrument_array = [];
var instrument_map = {
@ -60,9 +66,13 @@
var unusedChatInputChannels = [];
var usedChatInputChannels = [];
var removedAudioChannels = {};
var removedVoiceChatChannels = {};
var devices = [];
var originalDeviceId;
var voiceChatDevice;
var originalVoiceChat;
var currentVoiceChat;
// TODO Consolidate dragged controls and handles
var $draggingFaderHandle = null;
@ -155,8 +165,8 @@
});
});
voiceChatDevice = context.jamClient.TrackGetChatUsesMusic();
$('#voice-chat-device').val(voiceChatDevice);
originalVoiceChat = context.jamClient.TrackGetChatUsesMusic();
$('#voice-chat-device').val(originalVoiceChat);
originalDeviceId = context.jamClient.TrackGetMusicDeviceID();
}
@ -768,41 +778,85 @@
// Track 1 Add
$('#img-track1-input-add').click(function() {
$('#audio-inputs-unused option:selected').remove().appendTo('#track1-input');
// REMOVE FROM VOICE CHAT UNUSED IF NECESSARY
syncVoiceChatDialog();
$('#audio-inputs-unused > option:selected').remove().appendTo('#track1-input');
});
// Track 1 Remove
$('#img-track1-input-remove').click(function() {
$('#track1-input option:selected').remove().appendTo('#audio-inputs-unused');
// ADD TO VOICE CHAT UNUSED IF NECESSARY
$("#track1-input > option:selected").each(function() {
var deviceId = this.value;
var description = this.text;
if ($('#track1-input > option[value="' + deviceId + '"]').length > 0) {
if (removedVoiceChatChannels[deviceId]) {
logger.debug("Adding " + deviceId + " to Voice Chat Unused");
$('#voice-inputs-unused').append('<option value="' + deviceId + '">' + description + '</option>');
delete removedVoiceChatChannels[deviceId];
}
}
$(this).remove().appendTo('#audio-inputs-unused');
});
});
// Track 2 Add
$('#img-track2-input-add').click(function() {
$('#audio-inputs-unused option:selected').remove().appendTo('#track2-input');
// REMOVE FROM VOICE CHAT UNUSED IF NECESSARY
syncVoiceChatDialog();
$('#audio-inputs-unused > option:selected').remove().appendTo('#track2-input');
});
// Track 2 Remove
$('#img-track2-input-remove').click(function() {
$('#track2-input option:selected').remove().appendTo('#audio-inputs-unused');
// ADD TO VOICE CHAT UNUSED IF NECESSARY
$("#track2-input > option:selected").each(function() {
var deviceId = this.value;
var description = this.text;
if ($('#track2-input > option[value="' + deviceId + '"]').length > 0) {
if (removedVoiceChatChannels[deviceId]) {
logger.debug("Adding " + deviceId + " to Voice Chat Unused");
$('#voice-inputs-unused').append('<option value="' + deviceId + '">' + description + '</option>');
delete removedVoiceChatChannels[deviceId];
}
}
$(this).remove().appendTo('#audio-inputs-unused');
});
});
// Audio Output Add
$('#img-audio-output-add').click(function() {
$('#audio-output-unused option:selected').remove().appendTo('#audio-output-selection');
$('#audio-output-unused > option:selected').remove().appendTo('#audio-output-selection');
});
// Audio Output Remove
$('#img-audio-output-remove').click(function() {
$('#audio-output-selection option:selected').remove().appendTo('#audio-output-unused');
$('#audio-output-selection > option:selected').remove().appendTo('#audio-output-unused');
});
// Voice Chat Add
$('#img-voice-input-add').click(function() {
$('#voice-inputs-unused option:selected').remove().appendTo('#voice-inputs-selection');
// REMOVE FROM AUDIO UNUSED IF NECESSARY
syncMusicAudioDialog();
$('#voice-inputs-unused > option:selected').remove().appendTo('#voice-inputs-selection');
});
$('#img-voice-input-remove').click(function() {
$('#voice-inputs-selection option:selected').remove().appendTo('#voice-inputs-unused');
// 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');
});
});
$('.voicechat-settings').click(function() {
@ -834,6 +888,41 @@
});
}
function syncVoiceChatDialog() {
$("#audio-inputs-unused option:selected").each(function() {
var deviceId = this.value;
var description = this.text;
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;
// TODO: ADD THIS BACK WHEN APPROPRIATE
if ($('#voice-inputs-unused > option').size() === 0) {
$('#voice-chat-device > option[value="1"]').remove();
}
}
});
}
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();
@ -844,6 +933,13 @@
}
function audioDriverChanged() {
// ensure any channels removed are restored
var keys = Object.keys(removedVoiceChatChannels);
for (var i=0; i < keys.length; i++) {
$('#voice-inputs-unused').append(removedVoiceChatChannels[keys[i]]);
delete removedVoiceChatChannels[keys[i]];
}
context.jamClient.TrackSetMusicDevice($('#audio-drivers').val());
// refresh dialog
@ -851,6 +947,13 @@
}
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);
}
@ -877,7 +980,7 @@
if (refreshLists) {
configureDriverSettingsButton();
$('#audio-drivers').empty();
// determine correct music device to preselect
@ -913,6 +1016,8 @@
initDialogData();
// TODO: FILTER OUT ANY CHANNELS SELECTED ON THE VOICE CHAT TAB
// load Unused Inputs
loadOptions($('#audio-inputs-unused'), unusedAudioInputChannels, "device_id", "name", -1);
@ -959,19 +1064,28 @@
var chatOption = $('#voice-chat-device').val();
// populate with unused session inputs
if (chatOption === "1") {
loadOptions($('#voice-inputs-unused'), unusedAudioInputChannels, "device_id", "name", -1);
var voiceChatOptions = [];
$.each(unusedAudioInputChannels, function(index, val) {
var deviceId = val.device_id;
if ($('#track1-input > option[value="' + deviceId + '"]').length === 0 &&
$('#track2-input > option[value="' + deviceId + '"]').length === 0) {
voiceChatOptions.push(val);
}
});
if (chatOption === VOICE_CHAT.SESSION) {
loadOptions($('#voice-inputs-unused'), voiceChatOptions, "device_id", "name", -1);
loadOptions($('#voice-inputs-selection'), usedChatInputChannels, "device_id", "name", -1);
}
// populate with voice devices
else if (chatOption === "0") {
else if (chatOption === VOICE_CHAT.CHAT) {
loadOptions($('#voice-inputs-unused'), unusedChatInputChannels, "device_id", "name", -1);
loadOptions($('#voice-inputs-selection'), usedChatInputChannels, "device_id", "name", -1);
}
// disable inputs
else if (chatOption === "2") {
else if (chatOption === VOICE_CHAT.MIC) {
}
}
@ -1093,7 +1207,7 @@
// TRACK 1 INSTRUMENT
var instrumentVal = $('#track1-instrument').val();
var instrumentText = $('#track1-instrument option:selected').text().toLowerCase();
var instrumentText = $('#track1-instrument > option:selected').text().toLowerCase();
logger.debug("Saving track 1 instrument = " + instrumentVal);
context.jamClient.TrackSetInstrument(ASSIGNMENT.TRACK1, instrumentVal);
@ -1113,7 +1227,7 @@
// TRACK 2 INSTRUMENT
instrumentVal = $('#track2-instrument').val();
instrumentText = $('#track2-instrument option:selected').text().toLowerCase();
instrumentText = $('#track2-instrument > option:selected').text().toLowerCase();
logger.debug("Saving track 2 instrument = " + instrumentVal);
context.jamClient.TrackSetInstrument(ASSIGNMENT.TRACK2, instrumentVal);
@ -1134,10 +1248,10 @@
}
function saveVoiceChatSettings() {
voiceChatDevice = $('#voice-chat-device').val();
currentVoiceChat = $('#voice-chat-device').val();
logger.debug("Calling TrackSetChatUsesMusic with value = " + voiceChatDevice);
context.jamClient.TrackSetChatUsesMusic(voiceChatDevice);
logger.debug("Calling TrackSetChatUsesMusic with value = " + currentVoiceChat);
context.jamClient.TrackSetChatUsesMusic(currentVoiceChat);
$("#voice-inputs-selection > option").each(function() {
logger.debug("Saving chat input = " + this.value);
@ -1148,6 +1262,9 @@
function cancelSettings() {
// reset to original device ID
context.jamClient.TrackSetMusicDevice(originalDeviceId);
// reset voice chat option to original
$('#voice-chat-device').val(originalVoiceChat);
}
function validateAudioSettings() {
@ -1159,13 +1276,13 @@
var errMsg;
// verify Track 1 Input and Instrument exist
if ($('#track1-input option').size() === 0 || $('#track1-input option').size() > 2) {
if ($('#track1-input > option').size() === 0 || $('#track1-input > option').size() > 2) {
errMsg = noTrackErrMsg;
isValid = false;
}
if (isValid) {
if ($('#track1-instrument option').size() === 0) {
if ($('#track1-instrument > option').size() === 0) {
errMsg = noInstrumentErrMsg;
isValid = false;
}
@ -1173,19 +1290,19 @@
// if Track 2 exists, verify Input and Instrument exist
if (isValid && myTrackCount > 1) {
if ($('#track2-input option').size() === 0 || $('#track2-input option').size() > 2) {
if ($('#track2-input > option').size() === 0 || $('#track2-input > option').size() > 2) {
errMsg = noTrackErrMsg;
isValid = false;
}
if (isValid && $('#track2-instrument option').size() === 0) {
if (isValid && $('#track2-instrument > option').size() === 0) {
errMsg = noInstrumentErrMsg;
isValid = false;
}
}
// verify Session Audio Output exists
if (isValid && $('#audio-output-selection option').size() !== 2) {
if (isValid && $('#audio-output-selection > option').size() !== 2) {
errMsg = outputErrMsg;
isValid = false;
}
@ -1198,19 +1315,18 @@
}
function validateVoiceChatSettings() {
return true;
var isValid = true;
var noTrackErrMsg = 'You must select a voice input.';
var errMsg;
voiceChatDevice = $('#voice-chat-device').val();
if (voiceChatDevice === "1" || voiceChatDevice === "0") {
if ($('#voice-inputs-selection option').size() === 0 || $('#voice-inputs-selection option').size() > 2) {
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 (voiceChatDevice === "2") {
else if (currentVoiceChat === VOICE_CHAT.MIC) {
// NO VALIDATION NEEDED
}