Skip to content

no_std support #2

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

Merged
merged 3 commits into from
Jul 15, 2025
Merged

no_std support #2

merged 3 commits into from
Jul 15, 2025

Conversation

CBJamo
Copy link
Contributor

@CBJamo CBJamo commented Nov 19, 2023

This is a draft to add no_std support. I simply added the #[no_std] directive and fixed compiler errors, swapped all floats to f32, and added micromath to provide float operations. The tests still pass, and the example encode/decode program works the same. I have not tested against the original codec2 implementation, though I would be quite surprised if it didn't work.

@scriptjunkie
Copy link
Owner

This seems good, move out of draft when you're ready.

@CBJamo
Copy link
Contributor Author

CBJamo commented Nov 20, 2023

I did a little additional testing, using the C reference, this no_std, and the existing implementation to check if there are differences in the outputs. Here are all the versions in an audacity project.

I don't know audacity well enough to do anything but compare them visually, but to my eye the the no_std encode must produce similar output to the reference and existing impls, but the no_std decode introduces more noise. I can't tell the difference by ear, however.

In my mind that's an acceptable outcome, but if you want exactly the same performance I'll dig deeper. I suspect the micromath approximations only effect decoding and that switching to a slower but more accurate approach would fix the perf difference.

@CBJamo CBJamo marked this pull request as ready for review February 20, 2024 02:39
@CBJamo
Copy link
Contributor Author

CBJamo commented Feb 20, 2024

I feel like more testing should be done, but moving micromath/no_std behind a feature feels like an ok middle road. FYI, I'm going to look into getting rid of alloc as well, though I think that will be difficult.

@Ralith
Copy link

Ralith commented Jul 4, 2025

@scriptjunkie friendly ping? This would be nice to have!

@CBJamo
Copy link
Contributor Author

CBJamo commented Jul 5, 2025

Thanks for the review and good catches Ralith, all fixed.

@scriptjunkie scriptjunkie merged commit c80c0c4 into scriptjunkie:main Jul 15, 2025
@scriptjunkie
Copy link
Owner

Pardon the long delay!

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