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

java.lang.IllegalArgumentException while run this project. #7

Open
lcsongxp opened this issue Feb 26, 2018 · 6 comments
Open

java.lang.IllegalArgumentException while run this project. #7

lcsongxp opened this issue Feb 26, 2018 · 6 comments

Comments

@lcsongxp
Copy link

Hi,
I'm a rookie on pcm process, would you please help resolve the issue in your project?
Thanks
Alex
Logs are following:

file name is /mono_short_test.wav
channels is 1
frame size is 2
frame rate is 44100.0
Exception in thread "Thread-0" java.lang.IllegalArgumentException
at java.nio.Buffer.limit(Unknown Source)
at vavi.sound.pcm.resampling.ssrc.SSRC.downsample(SSRC.java:1579)
at vavi.sound.pcm.resampling.ssrc.SSRC.(SSRC.java:2440)
at com.jssrc.resample.JSSRCResampler$1.run(JSSRCResampler.java:66)
at java.lang.Thread.run(Unknown Source)

file name is /stereo_long_test.wav
channels is 2
frame size is 4
frame rate is 44100.0
Exception in thread "Thread-3" java.lang.IllegalArgumentException
at java.nio.Buffer.limit(Unknown Source)
at vavi.sound.pcm.resampling.ssrc.SSRC.upsample(SSRC.java:648)
at vavi.sound.pcm.resampling.ssrc.SSRC.(SSRC.java:2438)
at com.jssrc.resample.JSSRCResampler$1.run(JSSRCResampler.java:66)
at java.lang.Thread.run(Unknown Source)

@djos06
Copy link

djos06 commented Jul 2, 2018

I met this problem too ! Did you find a solution ?

@djos06
Copy link

djos06 commented Jul 2, 2018

I found this into the SSRC class source code :

rawoutbuf.limit((int) (dbps * nch * (Math.floor((double) sumread * dfrq / sfrq) + 2 + sumwrite + nsmplwrt2 - delay))); //TODO fails with short signals (think that fixed this)

@djos06
Copy link

djos06 commented Jul 2, 2018

Any idea to fix this ByteBuffer limit calculation ?

@hutm
Copy link
Owner

hutm commented May 30, 2019

pull requests are welcome

@hubin858130
Copy link

I solved this problem:

int limit = bps * nch * toberead;
if (limit > rawinbuf.capacity()) {
rawinbuf.clear();
rawinbuf = ByteBuffer.allocate(limit);
}
rawinbuf.position(0);
rawinbuf.limit(limit);

@hutm
Copy link
Owner

hutm commented Oct 10, 2022

@hubin858130 , can you create a pull request?

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

4 participants