Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[audio-button-response] Fix undefined startTime #1194

Closed
wants to merge 1 commit into from
Closed

[audio-button-response] Fix undefined startTime #1194

wants to merge 1 commit into from

Conversation

esolitos
Copy link

In the plugin audio-button-response when the audio is started and context is already defined a startAudio variable is used, but never defined, this causes e JS error: Uncaught ReferenceError: startTime is not defined.

This fixes the issue by inlining the variable since this was not reused anywhere else.

In the plugin `audio-button-response` when the audio is started and `context` is already defined a `startAudio` variable is used, but never defined, this causes e JS error: `Uncaught ReferenceError: startTime is not defined`.

This commit fixes the issue by inlining the variable since this was not reused anywhere else.
@becky-gilbert
Copy link
Collaborator

@esolitos thanks very much for catching this!

@jodeleeuw is this due to a start_time/startTime typo?
In the audio-slider-response plugin, startTime is a performance.now timestamp and is overwritten with a WebAudio timestamp if WebAudio is used:

var startTime = performance.now();
// start audio
if(context !== null){
startTime = context.currentTime;
source.start(startTime);

And then startTime is compared to either performance.now or context.currentTime to get the RT:
var endTime = performance.now();
var rt = endTime - startTime;
if(context !== null){
endTime = context.currentTime;
rt = Math.round((endTime - startTime) * 1000);
}

Whereas in this audio-button-response plugin, the performance.now timestamp is given a different variable name (start_time), so it's not overwritten in the WebAudio case:
var start_time = performance.now();
// start audio
if(context !== null){
startTime = context.currentTime;
source.start(startTime);

and the response time is always logged with a performance.now timestamp:
var end_time = performance.now();
var rt = end_time - start_time;

Should the audio-button-response plugin also collect an RT based on the WebAudio clock (when WebAudio is used)?

@jodeleeuw
Copy link
Member

Great catch @esolitos. @becky-gilbert I think you've identified the root cause. I'm not sure how the plugins ended up being different, but your solution seems absolutely correct here.

@becky-gilbert
Copy link
Collaborator

@jodeleeuw thanks!
@esolitos did you want to update your pull request with the above changes, i.e. so that the audio-button-response RT method is the same as that used in audio-slider-response? No problem if not - I can close this PR and make the changes.

@becky-gilbert becky-gilbert added this to the 6.2 milestone Nov 18, 2020
@esolitos
Copy link
Author

Sure @becky-gilbert I can take care of that. :)

@becky-gilbert
Copy link
Collaborator

@esolitos fantastic, thank you!!

@becky-gilbert
Copy link
Collaborator

Hi @esolitos, just checking on the status of this PR. We're releasing v6.2 soon and want to include this change to the audio-button-response plugin. But I can make the changes if you don't have time to do it. Thanks again!

@esolitos
Copy link
Author

esolitos commented Dec 1, 2020 via email

@becky-gilbert
Copy link
Collaborator

Fixed this issue in commit 074aca7 so I'll close this pull request now. Thanks again for flagging this @esolitos!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants