How can I write a WAV file from byte array in java? [closed]

I have used this in the past for going from Wav -> byte[] and byte[] -> Wav package GlobalUtilities; import java.applet.Applet; import java.applet.AudioClip; import java.net.URISyntaxException; import java.util.logging.Level; import java.util.logging.Logger; import java.io.*; import java.io.File; import java.net.MalformedURLException; import java.net.URL; import javax.sound.sampled.*; /** * This class handles the reading, writing, and playing of wav files. It is * … Read more

Decrease bitrate on WAV file created with recorderjs

In my case Chrome records audio at 96kHz and Firefox at 44.1kHz, that makes huge WAV files. I implemented a downsampling function inside recorderWorker.js where you can select the sample ratio you want, like 16000. function downsampleBuffer(buffer, rate) { if (rate == sampleRate) { return buffer; } if (rate > sampleRate) { throw “downsampling rate … Read more

Creating a WAV file from raw PCM data using the Android SDK

OK, I’ve got this figured out. This post was crucial in helping me: http://computermusicblog.com/blog/2008/08/29/reading-and-writing-wav-files-in-java Basically, I used ByteArrayOutputStream to write the raw PCM data from AudioRecord, which then lets me get the byte array and its size when the process is done. I can then use that data in conjunction with the SampleRate, BitRate, and … Read more

Writing musical notes to a wav file

You’re on the right track. Let’s take a look at your example: for(int i = 0; i < data.Length; i++) data[i] = (byte)(256 * Math.Sin(i)); OK, you’ve got 11025 samples per second. You’ve got 60 seconds worth of samples. Each sample is a number between 0 and 255 which represents a small change in air … Read more