| I have just completed a few simple tests of the suitability of Java for
software sound synthesis. Results are encouraging.
The following table reports some basic results, which come from
implementing a rudimentary frequency modulation wavetable instrument, with
two interpolating oscillators, in Java, C++, and Csound, and using it to
synthesize a 60 second, 80 decibel tone at middle C in a 16-bit, 44,100 Hz
stereo WAV soundfile on a Pentium 166 MHz computer with 40 megabytes of RAM
and an enhanced IDE disk drive. For Java and C++ the computation time was
measured from just before seeking in the soundfile to begin writing sound,
to just after flushing the final buffer of sound to the disk. For Csound
the total execution time was measured, but the time required to load the
program and parse the orchestra and score are small in comparison to the
time required to write the soundfile. My version of Csound and my C++
program were both built using Microsoft Visual C++ version 5.0, optimizing
for speed on a "blend" of processor types, with inlining turned on, using
the single-threaded library. The Java program was made using Symantec
Visual Cafe version 1.0 and its just-in-time compiler, which is faster than
Microsoft's.
Language Seconds of computation per second of sound
Csound .230
C++ .242
Java .314
These results are highly suggestive, even if they do not yet reflect the
complexity of actual music production. I found that removing the soundfile
write (only) from the Java test cut its time in half. Note that Csound is
somewhat faster than the C++ test program, and about a third faster than
the Java test. Of course, Csound is faster if a higher control sample to
audio sample ratio is used (ksmps 100 = .152).
Preliminary indications are that for sound synthesis, Java with a
just-in-time compiler is about one third slower than optimized, compiled C
code. Yet Java has definite, and large, advantages. These include much
simpler and safer syntax, complete platform-independence, built-in
networking, and a built-in graphics toolkit. In my experience, and I have
written about a dozen Java programs by now, Java programming takes about
half as long as C++, mainly due to Java's simpler syntax and faster
compiler.
I would be very interested to hear from anyone else who has experience with
Java and sound synthesis. I will report any results I obtain with more
complex and realistic Java synthesis software.
|