Java Sound

Java Sound (javax.sound) is a core API of the Java platform, meaning that it is part of all Java runtime environments that support Java 1.3 and later. The Java Sound API is low-level, concerning itself with the input and output plus processing of both sampled audio and MIDI (Musical Instrument Digital Interface) data.

The Java Sounds API provides the lowest-level of sound support on the Java platform, which incorporates explicit control over the resources concerned with sound input and output. Among the abilities provided by the API are direct access to system resources such as MIDI synthesizers, audio mixers, audio and MIDI devices, converters between sound formats, and file-based I/O.

The capabilities provided by Java Sound partially overlap with those of the JMF, although their target audiences are different. The JMF is larger, encompassing video and sound, and also high-level, providing a unified architecture for handling, processing, and transporting time-based media. On the other hand, Java Sound is both more specialized and lower level. It is concerned only with audio, but provides far finer control over the audio parameters of a system. In particular, Java Sound's MIDI functionality is considerably more sophisticated than that of the JMF (which has limited playback only as of 2.1.1), as well as providing the ability to control aspects such as buffering and mixing.

Java Sound is a large API. The programmer's guide from Sun can currently be found at http://java.sun.com/products/java-media/sound/index.html, and it runs more than 150 pages. If it has moved, do a search on the main Java Web page http://java.sun.com. This short section serves to inform you of the existence of the API. A number of audio-only applications are better suited to Java Sound than the JMF, and those developing a time-based application that is audio only should contrast the features of both APIs as to which is most suitable for the application.

Java Sound divides its MIDI and sampled audio support into two separate packages, with an additional two packages for service providers:

javax.sound.sampled— Classes for playing, capturing, and processing (mixing) of digital (sampled) audio

javax.sound.midi— Classes for MIDI synthesis, sequencing, and event transport

javax.sound.sampled.spi— Service provider's package for sampled audio

javax.sound.midi.spi— Service provider's package for MIDI sound

Implementations of the Java Sound API provide a basic set of audio services. The Service Provider Interface (SPI) packages are provided as a means for third-party software developers to develop new services. These new services then become another aspect of Java Sound.

The Java Sound API employs a similar approach to management of the services it provides to that of the JMF. Two central management classes act as registries or database managers for the audio components and audio resources on the system. Those management classes are AudioSystem for sampled audio and MidiSystem for MIDI resources. These classes act as access points for obtaining the services provided by Java Sound. For instance, the AudioSystem class provides a means of obtaining mixers, lines, format converters, and I/O functionality for sampled audio data.

The reader wanting to know more about Java Sound should consult Sun's “Java Sound API Programmer's Guide,” as well as the API documentation. Both can be found at the Java Sound documentation page: http://java.sun.com/j2se/1.3/docs/guide/sound/.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset