Mute button works. Better ties to music hardware (less hard-coding)

This commit is contained in:
Jonathon Wilson 2013-01-31 09:32:32 -07:00
parent e4f6975dc4
commit 04fb3844ff
5 changed files with 97 additions and 27 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -79,7 +79,8 @@
function SessionGetControlState(mixerIds) {
var response = [];
for (var i=0; i<mixerIds.length; i++) {
response.append({
response.push({
client_id: "",
group_id: 0,
id: mixerIds[i],
master: true,
@ -116,11 +117,17 @@
function doCallbacks() {
var names = ["left_vu", "right_vu"];
var ids = ["FW AP Multi_2_10200", "FW AP Multi_0_10000"];
var js = '';
for (var i=0; i<names.length; i++) {
js = eventCallbackName + '("' + names[i] + '", "' + ids[i] + '",' + vuValue + ')';
eval(js);
var args = [];
for (var i=0; i<ids.length; i++) {
for (var j=0; j<names.length; j++) {
args.push('"' + names[j] + '"');
args.push('"' + ids[i] + '"');
args.push(vuValue);
}
}
var js = eventCallbackName + '(' + args.join(',') + ')';
eval(js);
vuValue += vuChange;
if (vuValue > 10 || vuValue < -70) { vuChange = vuChange * -1; }
}

View File

@ -92,26 +92,36 @@
// Get the latest list of underlying audio mixer channels
function _updateMixers() {
mixers = context.jamClient.SessionGetIDs();
var mixerIds = context.jamClient.SessionGetIDs();
mixers = context.jamClient.SessionGetControlState(mixerIds);
logger.debug("Mixers updated:");
logger.debug(mixers);
}
// Given a clientId, return a dictionary of mixer ids which
// correspond to that client's tracks
// TODO - this is hard-coded. Need fix from Nat
function _mixersForTrack(clientId) {
return {
left: "FW AP Multi_2_10200.l",
right: "FW AP Multi_2_10200.r"
};
function _inputMixerForClient(clientId) {
// Iterate over the mixers, but simply return the first
// mixer in the AudioInputMusicGroup
var mixer = null;
for (var i=0; i<mixers.length; i++) {
mixer = mixers[i];
if (mixer.group_id === 2) {
return mixer.id;
}
}
return null; // no audio input music mixers.
}
function _renderTracks() {
var participantCount = 0;
var inputMixer = null;
$.each(session.participants, function(index, value) {
if (!(this.client_id in tracks)) {
var user = users[this.user.id];
// TODO - handle multiple tracks for one user
mixers = _mixersForTrack(this.client_id);
inputMixer = _inputMixerForClient(this.client_id);
var trackData = {
clientId: this.client_id,
name: user.first_name + ' ' + user.last_name,
@ -121,8 +131,7 @@
vu: 0.0,
gain: 0.5,
mute: false,
leftMixerId: mixers.left,
rightMixerId: mixers.right
mixerId: inputMixer
};
_addTrack(trackData);
}
@ -147,6 +156,8 @@
// Given a mixerID and a value between 0.0-1.0,
// light up the proper VU lights.
function _updateVU(mixerId, value) {
// Minor tweak to support VU values -- the mixerId here will
// have a suffix added _vul or _vur to indicate the channel.
// There are 13 VU lights. Figure out how many to
// light based on the incoming value.
var i = 0;
@ -156,7 +167,7 @@
var $light = null;
var colorClass = 'vu-green-';
// Remove all light classes from all lights
var allLightsSelector = '.session-mytracks table[mixer-id="' + mixerId + '"] td.vulight';
var allLightsSelector = '#tracks table[mixer-id="' + mixerId + '"] td.vulight';
$(allLightsSelector).removeClass('vu-green-off vu-green-on vu-red-off vu-red-on');
// Set the lights
@ -169,7 +180,7 @@
if (i >= lights) {
state = 'off';
}
selector = '.session-mytracks table[mixer-id="' + mixerId + '"] td.vu' + i;
selector = '#tracks table[mixer-id="' + mixerId + '"] td.vu' + i;
$light = $(selector);
$light.addClass(colorClass + state);
}
@ -211,11 +222,15 @@
// value is a DB value from -80 to 20. Convert to float from 0.0-1.0
vuVal = (value + 80) / 100;
if (eventName === 'left_vu') {
mixerId = mixerId + ".l";
mixerId = mixerId + "_vul";
} else {
mixerId = mixerId + ".r";
mixerId = mixerId + "_vur";
}
_updateVU(mixerId, vuVal);
} else {
// Examples of other events
// Add media file track: "add", "The_Abyss_4T", 0
logger.debug('non-vu event: ' + eventName + ',' + mixerId + ',' + value);
}
}
}
@ -232,8 +247,45 @@
}
}
function _toggleVisualMuteControl($control, muting) {
if (muting) {
$control.removeClass('enabled');
$control.addClass('muted');
} else {
$control.removeClass('muted');
$control.addClass('enabled');
}
}
function _toggleAudioMute(mixerId, muting) {
// 'fill' the trackVolume object volumes from what's in the
// corresponding mixer.
var mixer = null;
for (var i=0; i<mixers.length; i++) {
mixer = mixers[i];
if (mixer.id === mixerId) {
context.trackVolumeObject.volL = mixer.volume_left;
context.trackVolumeObject.volR = mixer.volume_right;
break;
}
}
context.trackVolumeObject.mute = muting;
logger.debug("Set Control State:");
logger.debug(context.trackVolumeObject);
context.jamClient.SessionSetControlState(mixerId);
}
function toggleMute(evt) {
var $control = $(evt.currentTarget);
var mixerId = $control.attr('mixer-id');
var muting = ($control.hasClass('enabled'));
_toggleVisualMuteControl($control, muting);
_toggleAudioMute(mixerId, muting);
}
function events() {
$('#session-contents').on("click", '[action="delete"]', deleteSession);
$('#tracks').on('click', 'div[control="mute"]', toggleMute);
}
this.initialize = function() {

View File

@ -376,9 +376,21 @@ table.vu td {
}
.track-icon-mute {
cursor: pointer;
position:absolute;
top:230px;
left:29px;
width: 20px;
height: 18px;
background-image:url('/assets/content/icon_mute.png');
background-repeat:no-repeat;
}
.track-icon-mute.muted {
background-position: 0px 0px;
}
.track-icon-mute.enabled {
background-position: -20px 0px;
}
.session-livetracks .track-icon-mute, .session-recordings .track-icon-mute {

View File

@ -29,6 +29,7 @@
<!-- end session controls -->
<!-- content scrolling area -->
<div id="tracks">
<div class="content-scroller">
<!-- content wrapper -->
@ -52,15 +53,16 @@
</div> <!-- end content wrapper -->
</div> <!-- end of content wrapper -->
</div> <!-- end of #tracks -->
</div> <!-- end of screen -->
<!-- Track Template -->
<script type="text/template" id="template-session-track">
<div class="session-track track" client-id="{clientId}">
<table class="track-vu-left vu" mixer-id="{leftMixerId}">
<table class="track-vu-left vu" mixer-id="{mixerId}_vul">
{left-vu}
</table>
<table class="track-vu-right vu" mixer-id="{rightMixerId}">
<table class="track-vu-right vu" mixer-id="{mixerId}_vur">
{right-vu}
</table>
<div class="track-label">{name}</div>
@ -79,18 +81,15 @@
<div class="track-gain">
<div class="track-gain-wrapper">
<div class="track-gain-slider pos50"
left-mixer-id="{leftMixerId}"
right-mixer-id="{rightMixerId}">
mixer-id="{mixerId}">
<%= image_tag "content/slider_gain_vertical.png",
{:width => 28, :height => 11} %>
</div>
</div>
</div>
<div class="track-icon-mute"
left-mixer-id="{leftMixerId}"
right-mixer-id="{rightMixerId}">
<%= image_tag "content/icon_mute.png",
{:width => 20, :height => 18} %>
<div class="track-icon-mute enabled"
control="mute"
mixer-id="{mixerId}">
</div>
<div class="track-icon-settings">
<%= image_tag "content/icon_settings_lg.png",