I’m looking into writing a audio syntesizer in Java, and was wondering if anybody has any advice or good resources for writing such a program. I’m looking for info on generating raw sound waves, how to output them into a usable form (playing over speakers), as well as general theory on the topic. Thanks guys.
I’m looking into writing a audio syntesizer in Java, and was wondering if anybody
Share
This problem is basically about mapping functions to arrays of numbers. A language that supports first-class functions would come in really handy here.
Check out http://www.harmony-central.com/Computer/Programming and http://www.developer.com/java/other/article.php/3071021 for some Java-related info.
If you don’t know the basic concepts of encoding sound data, then read http://en.wikipedia.org/wiki/Sampling_rate
The canonical WAVE format is very simple, see http://www.lightlink.com/tjweber/StripWav/Canon.html. A header (first 44 bytes) + the wave-data. You don’t need any library to implement that.
In C/C++, the corresponding data structure would look something like this:
I’m not sure about Java. I guess you’ll have to substitute ‘struct’ with ‘class’ and ‘void* data’ with ‘char[] data’ or ‘short[] data’ or ‘int[] data’, corresponding to the number of bits per sample, as defined in the field bipsa.
To fill it with data, you would use something like that in C/C++:
Again, I’m not sure about Java but the conversion should be straightforward if you convert the void-pointer to an array corresponding to the bitrate.
Then simply write the entire structure to a file to get a playable wave file.