Note: The Java Sound API is a low-level interface to sound, and the default implementation does not support compressed formats such as MP3. In these sections we'll be working with simple audio files, with types such as .wav, .aiff, and .au. Although Java Sound supports the recording of sounds, there is no recording example in this chapter: setup and configuration problems on different platforms make sound recording a topic beyond the scope of this chapter. |
Invoke PlaySound with the URL of a sound file as its sole argument. If you are using a local file, be sure to prefix the filename with the file: protocol. The types of sound files supported depend on the Java implementation. Sun's default implementation supports .wav, .aiff, and .au files for sampled sound, .mid files for MIDI, and even .rmf files for the MIDI-related, proprietary "Rich Music Format" defined by Beatnik. [1] |
The Java? Sound API enables Java developers to integrate audio into their applications. In this tutorial, Java developer and musician Jonathan Simon shows you how to play and record audio in your applications and discusses more advanced audio functionality. Using the working example source code and fundamentals covered in the tutorial, you will gain a fundamental understanding of the Java Sound API and how to apply it in your own projects. |
Once you change the AuditoryCues.playList setting, the new set of audio cues is available. When a particular action happens, the UI Manager examines the playlist for the key associated to the action. The UI Manager then uses that key to find the sound file to load and play. If no key is present in the cue array, no sound is played. |
From the perspective of the Java Sound API, the word Sound takes on a somewhat different meaning. However, it is probably fair to say that the ultimate purpose of the Sound API is to assist you in writing programs that will cause sound pressure waves impinge upon the ears of targeted individuals at specific times. |
The previous lesson showed you how to use the Java Sound API to write programs to capture microphone data into audio files types of your own choosing. At that time, I told you that you should be able to play the audio files back using readily available media players, such as the Windows Media Player. |
All that has changed with the incorporation of the Java Sound engine in Java 2. Another step forward has been taken with the beta release of Java 2 v1.3, which exposes the Java Sound API. Java Sound can be made available to earlier Java 1.x platforms through the use of the Java Media Framework 2.0. |
|
The Java Sound API implements a basic level of MIDI functionality and allows for the creation of more sophisticated services via the use of the Service Provider Interfaces (SPI). The new services can be integrated in the same way as the existing services and can function transparently to the application. |
This series of lessons is designed to teach you how to use the Java Sound API. The first lesson in the series was entitled Java Sound, An Introduction. The previous lesson was entitled Java Sound, Getting Started, Part 1, Playback. This lesson, entitled Java Sound, Getting Started, Part 2, Capture using Specified Mixer, is a follow-on to the previous lesson. |
This is the second lesson in a series of lessons designed to teach you how to use the Java Sound API. The first lesson in the series was entitled Java Sound, An Introduction. |
This series of lessons is designed to teach you how to use the Java Sound API. The first lesson in the series was entitled Java Sound, An Introduction. The previous lesson was entitled Java Sound, Audio File Conversion. |
Java SDK 1.4.1 allows sample sizes of eight bits or 16 bits. Using signed PCM encoding, (which I elected to use), an 8-bit sample can record a dynamic range of only 127 to 1. In other words, the loudest sound can only be 127 times as loud as the quietest sound, assuming that the range of sounds is perfectly balanced within the allowable range of the digitizer. |
This series of lessons is designed to teach you how to use the Java Sound API. The first lesson in the series was entitled Java Sound, An Introduction. The previous lesson was entitled Java Sound, Playing Back Audio Files using Java. |
The previous two lessons showed you how to capture audio data from a microphone, store it in a memory buffer, and play the data back on demand. As you will see in this lesson, because of the relatively high-level support for writing audio files in Java, the code required to store the captured data in an audio file is somewhat simpler than the code required to store the data in a memory buffer. |
This series of lessons is designed to teach you how to use the Java Sound API. The first lesson in the series was entitled Java Sound, An Introduction. The previous lesson was entitled Java Sound, Using Audio Line Events. |
You can use the SourceDataLine just like an output stream, since it is one. Playing audio data is as simple as writing to the stream: |
Returning once more to the main method, the code in Listing 9 illustrates the bottom line on audio file conversion in Java. |
I'm often struck when application areas appear to be so complex that only someone with superhuman intelligence could master them! For some reason, sound engineering has often seemed like one of these fields. It's similar to when Richard Feynman once remarked that even rocket science isn't rocket science! So, I was surprised to learn so much about sound engineering when I studied the Java Sound API. |
On a lower level than these global media trends, the Java Sound API allows the individual programmer to raise his game. Ultimately, this API provides a lot of programmatic control over sound recording, synthesis, and playback. In this article, I’ll show you how to move to the next level of use of this important API. |