You might need to know, for example, how many bits constitute one sample (the representation of the shortest instant of sound), and similarly you might need to know the sound's sample rate (how fast the samples are supposed to follow one another). The Java Sound API distinguishes between data formats and file formats.Ī data format tells you how to interpret a series of bytes of "raw" sampled audio data, such as samples that have already been read from a sound file, or samples that have been captured from the microphone input. Each of these is explained below.įormatted audio data refers to sound in any of a number of standard formats. To play or capture sound using the Java Sound API, you need at least three things: formatted audio data, a mixer, and a line. Is discussed in Chapter 5, " Capturing Audio." The Essentials: Format, Mixer, and Line In Chapter 4, " Playing Back Audio." Buffered recording These two models for playback are discussed further Looped (cycled) or set to arbitrary positions in the data. In addition, the in-memory, unbuffered model allows sounds to be easily To the buffered model, where the playback has to wait for the first buffer toįill. Sound data is loaded in advance, playback can start immediatelyfor example,Īs soon as the user clicks a Start button. Instead, the entire soundĬan be preloaded at once into memory for subsequent playback. Real-time approach is still available if desired. Need for the application program to buffer the audio, although the buffered, Hand and it is not too large to fit in memory. In the case of playback only, assuming you already have all the audio data at The Java Sound API also permits unbuffered transport Mechanisms are provided that make it easy to know how much data to deliver in each chunk. In other words, you deliver your audio bytes to the sound engine in chunks, and it takes care of playing each sample at the right time. In the case of audio output (playback), you also need to buffer data if the sound you want to play is too large to fit in memory all at once. You simply handle one buffer of audio data at a time, until the operation is halted. In the streaming model, particularly in the case of audio input rather than audio output, you do not necessarily know in advance how long the sound is and when it will finish arriving. Operations on the bytes commence before all the data has arrived. In other words, a stream of audio is simply a continuous set of audio bytes that arrive more or less at the same rate that they are to be handled (played, recorded, etc.). "Streaming" is used here in a general sense to refer to real-time handling of audio bytes it does not refer to the specific, well-known case of sending audio over the Internet in a certain format. The Java Sound API can handle audio transport in both a streaming, buffered fashion and an in-memory, unbuffered fashion. Third-party service providers can supply modules that "plug in" to an existing implementation to support additional file types and conversions.īuffered and Unbuffered Handling of Audio A particular implementation of the Java Sound API need not support an extensive set of file types or data format conversions. However, it does not attempt to be a comprehensive sound-file toolkit. To support this focus on basic audio input and output, the Java Sound API provides methods for converting between various audio data formats, and for reading and writing common types of sound files. That the flow of sound be started, paused, resumed, or stopped. Into or out of the system has to be correctly handled when the user requests Of audio into one stream (whether for input or output). It can also involve mixing multiple streams Task involves opening audio input and output devices and managing buffers that Is how to move bytes of formatted audio data into and out of the system. The central task that the Java Sound API addresses The package is fundamentallyĬoncerned with audio transportin other words, the Java Sound API focuses Th e Line interface and its subinterfaces are introduced briefly.īefore examining the elements of the Java Sound API, it helps to understand the orientation of the package. Then this chapter describes the three fundamental components required for playback or capture: an audio data format, a line, and a mixer. First, an explanation is given of the package's focus: playback and capture of formatted audio data. This chapter provides an introduction to the Java TM Sound API's digital audio architecture, which is accessed through the package. Chapter 2: Overview of the Sampled Package
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |