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

Upsampler crashes on very short audio sequence #4

Open
heebtob opened this issue Mar 21, 2018 · 1 comment
Open

Upsampler crashes on very short audio sequence #4

heebtob opened this issue Mar 21, 2018 · 1 comment
Assignees
Labels

Comments

@heebtob
Copy link

heebtob commented Mar 21, 2018

I have a very short audio sequence with 13093 samples. It's a Linear PCM Wave with 44100 hz Mono 16bits.
I'd like to upsample it to 48000 hz.

It crashes at the following line because the result of the calculation is negative.

SSRC.java:1006
rawoutbuf.limit((int) (dbps * nch * (Math.floor((double) sumread * dfrq / sfrq) + 2 - sumwrite - delay)));

java.lang.IllegalArgumentException: null
	at java.nio.Buffer.limit(Buffer.java:275) ~[na:1.8.0_161]
	at vavi.sound.pcm.resampling.ssrc.SSRC$Upsampler.resample(SSRC.java:1006) ~[na:na]
	at vavi.sound.pcm.resampling.ssrc.SSRC.io(SSRC.java:2431) ~[na:na]
	at vavi.sound.pcm.resampling.ssrc.SSRCInputStream$1.run(SSRCInputStream.java:88) ~[na:na]

Are such short sequences generally not supported or is it a corner case which you do not need in your applications?
Could you give me a hint how to fix this?

Thank you!

@umjammer umjammer added the bug label Mar 26, 2018
@umjammer umjammer self-assigned this Mar 26, 2018
@umjammer
Copy link
Owner

the original c source compares the calculated value and the bytes written,
then aborts when the comparison is failure.

https://github.com/shibatch/SSRC/blob/master/ssrc.c#L677

could you try to ignore when the calculated value is negative?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants