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

Use of local functions (lambdas) in Voice::process #16

Open
kmatheussen opened this issue Oct 19, 2020 · 1 comment
Open

Use of local functions (lambdas) in Voice::process #16

kmatheussen opened this issue Oct 19, 2020 · 1 comment

Comments

@kmatheussen
Copy link

Hi, I looked through your code and saw this:

auto get_samples_mono = [csample, this] (uint x, auto& fsamples)

Have you investigated how for instance gcc or clang treats this code? Because the code is very nice, and if compilers can guarantee that everything is inlined (and no heap allocations occur), I'll probably start using local lambdas too in realtime critical code.

@swesterfeld
Copy link
Owner

As far as I know, a lambda like this is not much more than a class with a few data members (captured variables) and one single method that is called when the lambda is called, so the compiler should inline it as far as I know. But I didn't do systematic benchmarking. So if you do and have results I'd be interested to hear what you found.

Also note that this is not the final optimized variant. To produce a final optimized variant all features must be there, and this code is only doing linear interpolation where it should do higher order sinc interpolation. So although I measured that this isn't slow, full optimization will have to wait until sinc interpolation is implemented.

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

No branches or pull requests

2 participants