From b4eb54fe41eaf7e2aaa7baa651b318a7f3705399 Mon Sep 17 00:00:00 2001 From: Jonathon Wilson Date: Sat, 1 Jun 2013 18:12:54 -0600 Subject: [PATCH] FTUE: Wire up new ASIO controls --- app/assets/javascripts/fakeJamClient.js | 11 ++++--- app/assets/javascripts/ftue.js | 36 ++++++++++++++++++++++ app/assets/javascripts/mixer.js | 41 +++++++++++++++++++++++++ app/views/clients/_ftue.html.erb | 20 ++++++------ 4 files changed, 94 insertions(+), 14 deletions(-) create mode 100644 app/assets/javascripts/mixer.js diff --git a/app/assets/javascripts/fakeJamClient.js b/app/assets/javascripts/fakeJamClient.js index cdae1d572..e2699b345 100644 --- a/app/assets/javascripts/fakeJamClient.js +++ b/app/assets/javascripts/fakeJamClient.js @@ -31,14 +31,14 @@ return 2; } function FTUESetInputLatency(latency) { - dbg("FTUESetInputLatency"); + dbg("FTUESetInputLatency:" + latency); } function FTUEGetOutputLatency() { dbg("FTUEGetOutputLatency"); return 2; } function FTUESetOutputLatency(latency) { - dbg("FTUESetOutputLatency"); + dbg("FTUESetOutputLatency:" + latency); } function FTUEGetVolumeRanges () { dbg("FTUEGetVolumeRanges"); @@ -58,7 +58,7 @@ return frameSize; } function FTUESetFrameSize(newSize) { - dbg("FTUESetFrameSize"); + dbg("FTUESetFrameSize:" + newSize); // one of 2.5, 5 or 10 frameSize = newSize; } @@ -175,6 +175,7 @@ // Session Functions function SessionAddTrack() {} function SessionGetControlState(mixerIds) { + dbg("SessionGetControlState") var groups = [0, 1, 2, 3, 7, 9]; var names = [ "FW AP Multi", @@ -230,7 +231,9 @@ callbackTimer = context.setInterval(doCallbacks, eventCallbackRate); } } - function SessionSetControlState(stringValue) {} + function SessionSetControlState(stringValue) { + dbg('SessionSetControlState: ' + stringValue); + } function SessionSetRecordingFilename(filename) {} function SessionSetRecordingFolder(folderName) {} function SessionStartPlay() {} diff --git a/app/assets/javascripts/ftue.js b/app/assets/javascripts/ftue.js index f11d1dd3e..ce81eb606 100644 --- a/app/assets/javascripts/ftue.js +++ b/app/assets/javascripts/ftue.js @@ -74,6 +74,16 @@ function settingsInit() { context.jamClient.FTUEInit(); + // Set all mixer levels to -80 + // Using the Session* apis to do so. + var trackIds = jamClient.SessionGetIDs(); + var controlStates = jamClient.SessionGetControlState(trackIds); + $.each(controlStates, function(index, value) { + context.JK.Mixer.fillTrackVolume(value, false); + context.trackVolumeObject.volL = -80; + context.trackVolumeObject.volR = -80; + context.jamClient.SessionSetControlState(trackIds[index]); + }); } function updateGauge() { @@ -115,10 +125,31 @@ context.jamClient.FTUEOpenControlPanel(); } + function asioResync(evt) { + context.jamClient.FTUESave(); + } + + function setAsioFrameSize(evt) { + var val = $(evt.currentTarget).val(); + context.jamClient.FTUESetFrameSize(val); + } + function setAsioInputLatency(evt) { + var val = $(evt.currentTarget).val(); + context.jamClient.FTUESetInputLatency(val); + } + function setAsioOutputLatency(evt) { + var val = $(evt.currentTarget).val(); + context.jamClient.FTUESetOutputLatency(val); + } + function events() { $('[layout-wizard-step="2"] .settings-driver select').on('change', audioDriverChanged); $('[layout-wizard-step="2"] .settings-controls select').on('change', audioDeviceChanged); $('#btn-asio-control-panel').on('click', openASIOControlPanel); + $('#btn-asio-resync').on('click', asioResync); + $('#asio-framesize').on('change', setAsioFrameSize); + $('#asio-input-latency').on('change', setAsioInputLatency); + $('#asio-output-latency').on('change', setAsioOutputLatency); } /** @@ -150,6 +181,11 @@ context._.each(sortedDeviceKeys, deviceOptionFunc); $select.html(optionsHtml); $select.removeAttr("disabled"); + $('[layout-wizard-step="2"] .settings-asio select').removeAttr("disabled"); + // Set selects to lowest possible values to start: + $('#asio-framesize').val('2.5').change(); + $('#asio-input-latency').val('120').change(); + $('#asio-output-latency').val('120').change(); } } diff --git a/app/assets/javascripts/mixer.js b/app/assets/javascripts/mixer.js new file mode 100644 index 000000000..e855d08b9 --- /dev/null +++ b/app/assets/javascripts/mixer.js @@ -0,0 +1,41 @@ +/** +* Static functions for controlling underlying jamClient mixer +* functions. +*/ +(function(context, $) { + + /** + * We'll want to move control over mixer functions out of the session.js + * file and into here, as it is becoming apparent we'll need better + * audio control globally. + */ + + "use strict"; + + context.JK = context.JK || {}; + + context.JK.Mixer = { + + /** + * Fill the track volume object, given a controlState structure. + * Provide a boolean for broadcast indicating whether the change + * should go out over the network + */ + fillTrackVolume: function(controlState, broadcast) { + context.trackVolumeObject.clientID = controlState.client_id; + context.trackVolumeObject.broadcast = broadcast; + context.trackVolumeObject.master = controlState.master; + context.trackVolumeObject.monitor = controlState.monitor; + context.trackVolumeObject.mute = controlState.mute; + context.trackVolumeObject.name = controlState.name; + context.trackVolumeObject.record = controlState.record; + context.trackVolumeObject.volL = controlState.volume_left; + context.trackVolumeObject.volR = controlState.volume_right; + // trackVolumeObject doesn't have a place for range min/max + //currentMixerRangeMin = mixer.range_low; + //currentMixerRangeMax = mixer.range_high; + } + + }; + +})(window, jQuery); \ No newline at end of file diff --git a/app/views/clients/_ftue.html.erb b/app/views/clients/_ftue.html.erb index b672da64a..75fde0d81 100644 --- a/app/views/clients/_ftue.html.erb +++ b/app/views/clients/_ftue.html.erb @@ -63,7 +63,7 @@
Frame:
- @@ -72,27 +72,27 @@
Buffer/In:
- - - - + + +
Buffer/Out:
- - - - + + +
ASIO SETTINGS - +