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

Improved performance #1

Merged
merged 1 commit into from
Feb 24, 2023
Merged

Conversation

Amjad50
Copy link
Contributor

@Amjad50 Amjad50 commented Feb 24, 2023

Methods to improve performance

Trying to improve further

@Amjad50 Amjad50 force-pushed the improve_performance branch from a1ee283 to ffe012e Compare February 24, 2023 18:02
@Amjad50 Amjad50 marked this pull request as ready for review February 24, 2023 18:06
@Amjad50
Copy link
Contributor Author

Amjad50 commented Feb 24, 2023

I think this is a good improvement, we can do better, but we would need to change hound, as the slowness right now is from hound reading samples.

Encode:
image

Decode:
image

As you can see, most of the time is spent on reading the samples, for encoding, its 50/50 between reading from hound and writing to the file, so I think its okay.

But we can make this very fast by using a simple wav writer, and we can do optimization when reading/writing

Copy link
Owner

@TheAwiteb TheAwiteb left a comment

Choose a reason for hiding this comment

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

Thank you @Amjad50 for this useful improvement

@TheAwiteb
Copy link
Owner

But we can make this very fast by using a simple wav writer, and we can do optimization when reading/writing

I'll check it

@TheAwiteb TheAwiteb merged commit 234b22e into TheAwiteb:master Feb 24, 2023
@Amjad50
Copy link
Contributor Author

Amjad50 commented Feb 24, 2023

Another interesting detail/cheat, we can do this extremely easily and make it insanely fast.

the wav file stores the PCM samples directly as bytes, without any compression, so it means the file content are actually stored in bytes, and this is true, as u can see here.

original file
image

wav
image

So we can add just a header for wav and just copy the whole file, which should be fast

@TheAwiteb
Copy link
Owner

TheAwiteb commented Feb 24, 2023

So we can add just a header for wav and just copy the whole file, which should be fast

Wow, is that really possible!! How can we get the header? Is it the same in all files or does it change?

@Amjad50
Copy link
Contributor Author

Amjad50 commented Feb 24, 2023

Hound uses this library: https://docs.rs/wav/latest/wav/index.html

this library allows u to write the header, so yeah, would be interesting to try.

The header looks like it has basic info, like filesize, sample rate, format, etc....

@Amjad50 Amjad50 deleted the improve_performance branch February 26, 2023 13:04
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.

2 participants