hutm / JSSRC

Java SSRC Audio Resampler
Other
149 stars 62 forks source link

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

Open lcsongxp opened 6 years ago

lcsongxp commented 6 years ago

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 commented 6 years ago

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

djos06 commented 6 years ago

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 commented 6 years ago

Any idea to fix this ByteBuffer limit calculation ?

hutm commented 5 years ago

pull requests are welcome

hubin858130 commented 2 years ago

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 commented 2 years ago

@hubin858130 , can you create a pull request?