From fd57f3f01e473afdfe249b6ce569673931f2f72f Mon Sep 17 00:00:00 2001 From: Jonathon Wilson Date: Sun, 6 Jan 2013 13:34:48 -0700 Subject: [PATCH] Finish FTUE functional, but bugs in bridge prevent test. Checking in to let Nat see test code. Re-include TestLatency on fakeJamClient to fix failing test. --- app/assets/javascripts/fakeJamClient.js | 6 +-- app/assets/javascripts/ftue.js | 70 ++++++++++++++++++++++++- app/views/clients/_ftue3.html.erb | 20 ++++++- 3 files changed, 91 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/fakeJamClient.js b/app/assets/javascripts/fakeJamClient.js index 30870ee57..e6eda0fed 100644 --- a/app/assets/javascripts/fakeJamClient.js +++ b/app/assets/javascripts/fakeJamClient.js @@ -53,9 +53,8 @@ function StopRecording(map) { dbg('StopRecording' + JSON.stringify(arguments)); } function TestASIOLatency(s) { dbg('TestASIOLatency' + JSON.stringify(arguments)); } - - function testLatency(clientID, callbackFunctionName) { - logger.debug("Fake JamClient: testLatency called with client, " + clientID + " and callback function name: " + callbackFunctionName); + function TestLatency(clientID, callbackFunctionName) { + logger.debug("Fake JamClient: TestLatency called with client, " + clientID + " and callback function name: " + callbackFunctionName); var response = { clientID: clientID, latency: 50 @@ -95,6 +94,7 @@ this.StopPlayTest = StopPlayTest; this.StopRecording = StopRecording; this.TestASIOLatency = TestASIOLatency; + this.TestLatency = TestLatency; this.connected = true; }; diff --git a/app/assets/javascripts/ftue.js b/app/assets/javascripts/ftue.js index bba94d464..04b28b73e 100644 --- a/app/assets/javascripts/ftue.js +++ b/app/assets/javascripts/ftue.js @@ -11,6 +11,8 @@ context.JK.FTUEScreen = function(app) { var logger = context.JK.logger; var jamClient = context.jamClient; + var playbackTestRunning = false; + var recordingTestRunning = false; function beforeShow(data) { loadDevices(); @@ -60,6 +62,10 @@ $('#choose-output-audio-device select').html(outputOptions.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('.'); @@ -72,8 +78,66 @@ parseInt(output[2], 10)); } + function testLatency() { + $('#latency-testing p').html("Testing latency..."); + context.jamClient.TestASIOLatency("JK.latencyTestingComplete"); + } + + function latencyTestingComplete() { + logger.debug("latencyTestingComplete. Arguments:"); + logger.debug(arguments); + $('#latency-testing p').html("Done."); + } + + function playbackButtonHandler(evt) { + if (playbackTestRunning) { + $('#playback-testing p').html('Test stopped by user'); + $('#playbackTestingButton').html('Start Playback Test'); + playbackTestRunning = false; + context.jamClient.StopPlayTest(); + } else { + $('#playback-testing p').html('Playback test in progress... Click the button below when things start to sound crappy'); + $('#playbackTestingButton').html('Click when things sound bad...'); + playbackTestRunning = true; + context.jamClient.StartPlayTest('JK.playbackTestComplete'); + } + } + + function playbackTestComplete() { + logger.debug('playbackTestComplete. Arguments:'); + logger.debug(arguments); + $('#playback-testing p').html('Done'); + $('#playbackTestingButton').html('Start Playback Test'); + playbackTestRunning = false; + } + + function recordingButtonHandler(evt) { + if (recordingTestRunning) { + $('#recording-testing p').html('Recording complete.'); + $('#recordingTestingButton').html('Start Recording Test'); + recordingTestRunning = false; + context.jamClient.RecordTestEnd(); + } else { + $('#recording-testing p').html('Recording in progress... Click the button below to stop recording'); + $('#recordingTestingButton').html('Stop Recording'); + recordingTestRunning = true; + context.jamClient.RecordTestBegin(); + } + } + + function recordingPlaybackButtonHandler(evt) { + context.jamClient.RecordTestPlayback(); + } + function events() { - $('#enableDevices').click(enableAudioDevices); + $('#enableDevices').click(function() { + enableAudioDevices(); + testLatency(); + }); + + $('#playbackTestingButton').click(playbackButtonHandler); + $('#recordingTestingButton').click(recordingButtonHandler); + $('#recordingTestPlaybackButton').click(recordingPlaybackButtonHandler); } function initialize() { @@ -85,6 +149,10 @@ // Expose publics this.initialize = initialize; + // Expose callbacks for the bridge on the global namespace + context.JK.latencyTestingComplete = latencyTestingComplete; + context.JK.playbackTestComplete = playbackTestComplete; + return this; }; diff --git a/app/views/clients/_ftue3.html.erb b/app/views/clients/_ftue3.html.erb index 4211b532d..f921b9d3a 100644 --- a/app/views/clients/_ftue3.html.erb +++ b/app/views/clients/_ftue3.html.erb @@ -15,7 +15,25 @@ - + + + +
+

Latency Testing

+

+
+ +
+

Playback Testing

+

Click the button below to start a playback test. We'll start with safe settings, and then lower the values for better latency. When things begin to sound bad, click the button again.

+ +
+ +
+

Recording Testing

+

When ready, click the button below to enable recording of your audio input. When done, click the button again, and use the other button for playback to see how things sound.

+ +

If everything looks good, then WE'RE DONE.