howto: save WAV file from series of byte arrays ?
843802Jul 13 2008 — edited Jul 6 2010i've got a small app which processes audio data
i'm reading the audio data from a WAV in small chunks of about 8000 bytes, using a loop with the audioInputStream.read() method to read each chunk of data into a byte array. the app then processes the data in the byte array, then repeats the loop for each consecutive chunk of data.
i need to save the data to a new WAV file. ideally i'd like to stream the data out in a similar way as it's streaming in, so at the end of each iteration i can write the modified byte array out to the new file, and discard the data. i cannot seem to find ANY way of doing this at all.
after doing a fair bit of reading, i think i can store up all the data into one new byte array containing the entire processed audio clip, then when processing is done write this out to a file, but this is no good for very large files. some of the WAV files i need to process are over 500mb in size so storing the entire thing in system RAM is no good !
really what i need is a version of the AudioInputStream class that allows me to write to it rather than read from it (AudioOutputStream anyone?). then i could use this to write a new WAV file chunk by chunk as i need to.
i'm new to java, although i've been dabbling in various progamming languages for many years, so it's quite possible i'm simply missing something obvious. apologies if that is the case !