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

resampleAudio implementation has bug when starttime and enttime is not nil #191

Closed
Josscii opened this issue Aug 5, 2024 · 6 comments · Fixed by #195
Closed

resampleAudio implementation has bug when starttime and enttime is not nil #191

Josscii opened this issue Aug 5, 2024 · 6 comments · Fixed by #195

Comments

@Josscii
Copy link

Josscii commented Aug 5, 2024

should not comparing audioFile.framePosition with inputFrameCount , but something like this:

let endFrame = AVAudioFrameCount(audioFile.framePosition) + inputFrameCount

while audioFile.framePosition < inputFrameCount {
let remainingFrames = inputFrameCount - AVAudioFrameCount(audioFile.framePosition)

@ZachNagengast
Copy link
Contributor

Thanks for the report, would you be able to post the specific exception? Or whatever test code you are using to reproduce the error?

@Josscii
Copy link
Author

Josscii commented Aug 7, 2024

just the logic is wrong, when the audioFile is seeked to startTime, which changes its framePosition, and we should read from the frameposition until it reaches the framePosition + frameCount.

@ZachNagengast
Copy link
Contributor

I think I see what you mean, so we need to calculate the ending framePosition for cases where the starting framePosition is not 0, does that sound right?

@Josscii
Copy link
Author

Josscii commented Aug 7, 2024

yes, I'm using the loadAudio function to load audio buffer from time1 to time2, and found that the resampleAudio is not entering the while loop.

@ZachNagengast
Copy link
Contributor

@Josscii I've fixed some of the logic in #195, please try it out and see if it works for your use case.

@Josscii
Copy link
Author

Josscii commented Aug 11, 2024

Thanks for your work, I checked the code, and I think it fixed the bug.

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 a pull request may close this issue.

2 participants