tag:blogger.com,1999:blog-8219113377173546175.post8029659066693450317..comments2023-11-07T13:29:54.725+00:00Comments on GT's Blog: Java extract amplitude array from recorded waveGThttp://www.blogger.com/profile/16923656636145211711noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-8219113377173546175.post-72776610044173498062013-08-07T17:52:49.177+01:002013-08-07T17:52:49.177+01:00Think I found a bug for 8 bit unsigned samples in ...Think I found a bug for 8 bit unsigned samples in the code above.<br /><br />Java regards a byte-variable as a signed variable, so we can't just subtract 128 for all sample-values. For "negative" values we must instead add 128, I think.<br /><br />E.g. the sampled unsigned value 10000000 (128 unsigned) should mean that we are in the middle of the value-range. It should actually mean 0, but java sees it as -128, and if we subtract 128 we'll get -256, which isn't what we want at all.<br /><br />And the "highest" sample-value possible with 8 bits, 11111111, means -1 to java if it's in a byte-variable. We'd get the value -129 here with the old method, but we would expect 127.<br /><br />For all "positive" values 00000000 - 01111111 it works fine to subtract 128 as before, so something like this would work better:<br /><br /> // PCM_UNSIGNED<br /> for (int i = 0; i < audioBytes.length; i++)<br /> {<br /> if (audioBytes[i] >= 0)<br /> _audioData[i] = audioBytes[i] - 128;<br /> else<br /> _audioData[i] = audioBytes[i] + 128;<br /> }<br /> <br />(Or e.g. you could "shift" the byte-value into an int-variable before subtracting 128.)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8219113377173546175.post-57539652206446629672013-06-07T09:06:42.003+01:002013-06-07T09:06:42.003+01:00Hey guys, I just saw this code and I was wondering...Hey guys, I just saw this code and I was wondering, anyone knows how to write a java program that allows us to open a wav file, change the amplitude and save it as a new wav file? I would appreciate any help.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8219113377173546175.post-29063469102685716522012-06-07T04:28:35.870+01:002012-06-07T04:28:35.870+01:00Could you please add some break points (or sysout)...Could you please add some break points (or sysout) in code and debug the code? This code should work for all settings.<br /><br />As far as i remember I had run this code with 16KHz, 16 bit. Could you please try using this setting instead.GThttps://www.blogger.com/profile/16923656636145211711noreply@blogger.comtag:blogger.com,1999:blog-8219113377173546175.post-68642080700375772482012-06-06T22:33:51.234+01:002012-06-06T22:33:51.234+01:00Nor working dude.
Im working with a PCM, 8000hz, 1...Nor working dude.<br />Im working with a PCM, 8000hz, 16bit, littleEndian, 1 channel audio stream (AudioInputStream) and the int[] audioData[] that function is returning me is the array fill only with zero.<br /><br />What am i doing wrong? or do i have to change something? work with a restriction??<br /><br />Im working on a Java vowel recognizer through sound sampling. I need the audioData to perform on it the FFT and get the frequency spectrum.<br /><br />Need some help to get first the audioData.<br /><br />Thnks.hIUGhttps://www.blogger.com/profile/10583826502937604900noreply@blogger.com