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

How Much Data was Written to dataOut? #143

Closed
tortis opened this issue Aug 15, 2024 · 3 comments
Closed

How Much Data was Written to dataOut? #143

tortis opened this issue Aug 15, 2024 · 3 comments
Labels
bug Something isn't working question Further information is requested

Comments

@tortis
Copy link
Contributor

tortis commented Aug 15, 2024

Summary

I'm using the full API with a reused buffer which is much larger than the expected number of samples.

After I run:

resampler.full(inputSamples, resampleBuffer);

How do I know how much data is in the resampleBuffer. I looked at the source briefly and it doesn't appear to slice the Float32Array or return the number of samples in any other way.

Is there a way to deal with this, or does the library need to be updated to support this use case?

@tortis tortis added the question Further information is requested label Aug 15, 2024
@aolsenjazz
Copy link
Owner

Hey, thanks for submitting this issue. After reviewing the implementation, I think you're correct in identifying that I didn't provide what you would need to properly read dataOut. I imagine the best way to do this would be to add a third argument, something like outLength: { length: number } = { length: 0 } that we could reference following a call to full to determine how much to slice. I wouldn't want to break the existing API by change the return val.

I don't have time in the nearish future to implement this, but if you're able and have the time, I think it'd be great to add this.

@tortis
Copy link
Contributor Author

tortis commented Aug 16, 2024

I like it, I just opened PR with this change. I did a build/pack and installed it into my project and was able to use it successfully.

I opted to include sample and frame count just for convenience and clarity, but we can change it back to just length if you'd prefer.

@aolsenjazz
Copy link
Owner

Fixed in #144. 2.1.2 is live on NPM.

Thanks for your contributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants