tag:blogger.com,1999:blog-7227407500212291254.post7883097822010797377..comments2022-05-26T23:22:59.872+02:00Comments on Sangorrin: Manually parsing a wave file in JavaSangorrinhttp://www.blogger.com/profile/13773761503933579563noreply@blogger.comBlogger9125tag:blogger.com,1999:blog-7227407500212291254.post-49171801533765577032017-10-19T19:03:10.778+02:002017-10-19T19:03:10.778+02:00Can anyone suggest how to convert the .wav (audio ...Can anyone suggest how to convert the .wav (audio file) to a text file and vice-versa in Java?<br />I want to convert the audio file to a text file in java i.e first the audio file will be played and after it is played it will copy the lyrics into a text file, and vice versa, in java. But, I don't know from where I will start it, so, can anyone tell me how to do that?RMBS Rockhttps://www.blogger.com/profile/11332861705630005482noreply@blogger.comtag:blogger.com,1999:blog-7227407500212291254.post-73715655201263396442015-08-22T13:50:37.008+02:002015-08-22T13:50:37.008+02:00The numbers on the X axis are just the sample'...The numbers on the X axis are just the sample's number. So the first sample is the one that appears at x=0 and so on. You can multiply these numbers by the sampling period if you want the X axis to appear in seconds. <br /><br />The data is stored in the variable data[]. And the function that reads it from the file is read(). The variable bytes gives you the amount of bytes read (up to the size of data[]). Also, if you use 16bits you need to modify the code. Maybe you can try to run it 8000/8bit/mono as in the example and see if it works. Thanks.Sangorrinhttps://www.blogger.com/profile/13773761503933579563noreply@blogger.comtag:blogger.com,1999:blog-7227407500212291254.post-15868274149739488302015-08-22T12:19:12.605+02:002015-08-22T12:19:12.605+02:00Great..i understand the y-axis. however i have tro...Great..i understand the y-axis. however i have trouble understanding "The distance between two consecutive samples is the sample period, in this case 1/8000s." I am unable to replicate your results(the graph). I have been able to obtain the samples<br /><br />as i read it from the info given above, <br />0000024 8000 0 8000 samples/sec. <br /><br />Note: I am using 44100 samples/sec. the total samples are 44100X2sec=88200 samples. The values that your (similar) code gives me is double[] ...=1490 number of samples. I dont understand how the 88200 samples are supposed to be retrieved. Where this information is stored and how to access it. For example in Matlab the audioread() function generates the 88200 samples but in java it appears to be a nightmare. any help will be really appreciated.<br /><br />Thanks<br /><br />Anonymoushttps://www.blogger.com/profile/09345694210929391332noreply@blogger.comtag:blogger.com,1999:blog-7227407500212291254.post-21967241864170877052015-08-21T16:08:47.686+02:002015-08-21T16:08:47.686+02:00This comment has been removed by the author.Sangorrinhttps://www.blogger.com/profile/13773761503933579563noreply@blogger.comtag:blogger.com,1999:blog-7227407500212291254.post-67438567898413977942015-08-21T16:05:41.223+02:002015-08-21T16:05:41.223+02:00fix: data.txt, not pepe.txtfix: data.txt, not pepe.txtSangorrinhttps://www.blogger.com/profile/13773761503933579563noreply@blogger.comtag:blogger.com,1999:blog-7227407500212291254.post-22824304491561900052015-08-21T16:02:38.955+02:002015-08-21T16:02:38.955+02:00Hi Sam,
Ok, I think I understood you this time. T...Hi Sam,<br /><br />Ok, I think I understood you this time. The samples are just 8/16 bit numbers that digitally represent the audio wave's amplitude. So in the example the Y axis consists of numbers from 0 to 255 (the wave amplitude). The X axis represents time. The distance between two consecutive samples is the sample period, in this case 1/8000s. <br />About the 128bytes, if you notice I am printing the samples' value to the standard output inside a while. Then, I redirect the stdout to a text file (pepe.txt) which contains all of the samples. If you want the red line as an array change the size of the data buffer so that you can store all samples inside.<br />Do you understand now?<br /><br />Thanks,Sangorrinhttps://www.blogger.com/profile/13773761503933579563noreply@blogger.comtag:blogger.com,1999:blog-7227407500212291254.post-16062788982867744222015-08-20T19:59:52.892+02:002015-08-20T19:59:52.892+02:00Please accept my apologies for not being able to e...Please accept my apologies for not being able to explain the issue. First, let me say that you work (this blog) is highly commendable and helped me in the right direction in many issues. You have presented the Header and Data Chunk in a very methodical way which is easy to understand. Having said that, i have searched extensively the problem of what you have actually demonstrated graphically using the pepe.wav. I am trying to extract a valid audio signal (16 bit, mono(Channel-1), Duration: 2sec, Sampling Rate 44100). This amounts to 44100X2sec= 88200 samples. I need to collect/extract these samples and graph them. The problem is really really reached a dead end. What are these samples? How these are computed? <br /><br />Now let me point towards your graph. In your graph, the red line represents the audio signal and the y axis represents the sampling (rate) scale. The x-axis represents the signal data. Each signal is identified as (x,y) i.e.,y-axis (byte, int, float etc.) while the x-axis is the sampling rate from 0 to 40,000. Now in your code the <br />byte[] data = new byte[128]; So the length is 128. the iteration only runs as far as 128 bytes. How you have been able to transform the 128 bytes into 8000 audio samples and plot it.<br />In summary, i dont need to graph but i need the RED LINE signal as array. Can you help me how to do it?<br /><br />Thanks <br /> Anonymoushttps://www.blogger.com/profile/09345694210929391332noreply@blogger.comtag:blogger.com,1999:blog-7227407500212291254.post-91628074622338179122015-08-20T16:26:29.157+02:002015-08-20T16:26:29.157+02:00Hi sam, not sure I understood you. What do you mea...Hi sam, not sure I understood you. What do you mean by "the data of the line"?Sangorrinhttps://www.blogger.com/profile/13773761503933579563noreply@blogger.comtag:blogger.com,1999:blog-7227407500212291254.post-37898917714804624262015-08-19T12:24:41.261+02:002015-08-19T12:24:41.261+02:00The pic and the code does not sum up. Can you plea...The pic and the code does not sum up. Can you please explain the data for the line is stored in which variable? if not how can we access the data of the line?<br /><br />hope that you will respond.<br /><br />samAnonymoushttps://www.blogger.com/profile/09345694210929391332noreply@blogger.com