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

Always treat waveform as List<Float> #1663

Merged
merged 3 commits into from
Oct 27, 2023
Merged

Conversation

julioromano
Copy link
Contributor

MSC3246 specifies the waveform as a list of ints because:

Because floating point numbers are not allowed in Matrix events

Though DSP on audio data is almost always done using their floating point representation.
This PR brings the float<->int rescaling in the matrix module so that the application code can always work with float waveform samples.

@julioromano julioromano self-assigned this Oct 27, 2023
@julioromano julioromano requested a review from a team as a code owner October 27, 2023 12:01
@julioromano julioromano requested review from bmarty and removed request for a team October 27, 2023 12:01
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

Just a small mistake (please fix before merging!), else LGTM

*
* https://github.com/matrix-org/matrix-spec-proposals/blob/travis/msc/audio-waveform/proposals/3246-audio-waveform.md
*/
internal fun List<Float>.toMSC3246range(): List<UShort> = map { (it / 1024).toInt().toUShort() }
Copy link
Member

Choose a reason for hiding this comment

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

I think you want to write it * 1024 instead of it / 1024?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed :(

@julioromano julioromano enabled auto-merge (squash) October 27, 2023 12:19
@github-actions
Copy link
Contributor

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/BkVWhd

@sonarcloud
Copy link

sonarcloud bot commented Oct 27, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@julioromano julioromano merged commit 0e41418 into develop Oct 27, 2023
13 checks passed
@julioromano julioromano deleted the julioromano/waveform_float2 branch October 27, 2023 12:50
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.

None yet

2 participants