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

Adding audio level stat that can be used to compute averages. #221

Merged
merged 3 commits into from
Jun 14, 2017

Conversation

taylor-b
Copy link
Contributor

@taylor-b taylor-b commented May 11, 2017

Fixes #220.

It's slightly different than most of the stats of this sort, since the
application needs to compute "sqrt(a/b)", not just "a/b". But the
concept is the same.

for each audio sample sent/received for this object (and
counted by <code><a>totalSamplesSent</a></code> or
<code><a>totalSamplesReceived</a></code>), add the square of
the sample's value divided by the highest-intensity encodable
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this too ambiguous? It's meant to mean square(sample/max), not square(sample)/max.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the expression below and the explanation in the text here in sync?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, I think I get what you mean.

The first paragraph is about how totalAudioEnergy is computed. And the second paragraph is how it could be used by an application.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's clear but you could clarify with a formula at the end of the sentence, (sampleEnergy^2/maxEnergy)*sampleDuration.

@taylor-b
Copy link
Contributor Author

@vr000m, @henbos, can you take a look?

@taylor-b
Copy link
Contributor Author

taylor-b commented Jun 6, 2017

@vr000m @henbos Ping.

Copy link
Contributor

@vr000m vr000m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

for each audio sample sent/received for this object (and
counted by <code><a>totalSamplesSent</a></code> or
<code><a>totalSamplesReceived</a></code>), add the square of
the sample's value divided by the highest-intensity encodable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@henbos henbos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM % nits

<code>Math.sqrt(totalAudioEnergy/totalSamplesDuration)</code>
becomes <code>Math.sqrt(0.0026/0.02) = 0.36</code>, which is
the same value that would be obtained by doing an RMS
calculation over the contiguous 20ms segment of audio.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Can you change this example to include two getStats calls so that people don't get confused about where to do the sqrt?

This can be used to obtain a root mean square (RMS) value
that uses the same units as <code><a>audioLevel</a></code>,
using the formula
<code>Math.sqrt(totalAudioEnergy/totalSamplesDuration)</code>.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Can you also have the RFC reference here? (Same as the audioLevel reference)

for each audio sample sent/received for this object (and
counted by <code><a>totalSamplesSent</a></code> or
<code><a>totalSamplesReceived</a></code>), add the square of
the sample's value divided by the highest-intensity encodable
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's clear but you could clarify with a formula at the end of the sentence, (sampleEnergy^2/maxEnergy)*sampleDuration.

@vr000m
Copy link
Contributor

vr000m commented Jun 13, 2017

@taylor-b if you can make the changes (and merge) in the forthcoming days, I will make a new editor's release.

taylor-b added 3 commits June 13, 2017 23:00
Fixes w3c#220.

It's slightly different than most of the stats of this sort, since the
application needs to compute "sqrt(a)/b", not just "a/b". But the
concept is the same.
This now takes a sample's duration into account when adding it to
`totalAudioEnergy`, which prevents higher-frequency samples from
being weighted more significantly than lower-frequency samples.
@taylor-b taylor-b force-pushed the issue_220_averaged_audio_level branch from 33f6d86 to 61b82d1 Compare June 14, 2017 06:00
@taylor-b
Copy link
Contributor Author

Updated and fixed merge conflicts.

@vr000m vr000m merged commit c3109a3 into w3c:master Jun 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants