Java sound technology

zhaozj2021-02-08  389

Java sound technology

The sound can create an artistic conception, triggering delusions, when combined with the virtual image, more enabled the entire world full of illusion. The sound is the foundation of multimedia technology. This is why SUN's Java Media Technology Development Team is busy preparing Java Sound 1.0 API and is included in the next version of the Java development tool library. Before the Java2 platform appears, the Java language can only handle the sound of the phone sound quality, stored as the μ-Law Au file with the sampling frequency of mono 8kHz. The Java2 platform adds support for AIFF, WAV, and three MIDI file types. The three MIDI file formats support are MIDI file type 0, MIDI file type 1, and RMF. Application Interface API1.0 provides an easy-to-use toolset that allows programmers to access the underlying synthetic and playing engine to extend the application of Java sound. Two of these important areas are to create digitized audio and musical instrument command digitization interface MIDI. Since a large number of underlying support functions are provided, the programmer can enter the output sound, control the MIDI device, and can query the system operation. Sound file type Introduction The main sound file type is as follows: AU - (Extension is AU or SND) Suitable for short sound files, the general file format for Solaris and next generation machines, is also the standard audio format of the Java platform. The three typical audio formats used by the AU type file are: 8-bit μ-Law type (usually sampling frequency is 8kHz), 8-bit linear type, and 16-bit linear type. WAV - (extension WAV) is developed by Microsoft and IBM, and support for WAV has been added to Windows 95 and extends to Windows 98. WAV files can store various formats including μ-Law, A-Law and PCM ( Linear) data. They can be played by all Windows applications that support sound. AIFF - (Extension AIF or IEF) Audio Interchange File Format is a standard audio file format shared for Macintosh Computers and Silicon Graphics (SGI) computers. AIFF and AIFF-C are almost the same, except for the latter to support, for example, μ-Law and IMA ADPCM type compression. MIDI - (Extension MID) Musical instrument digital interface MIDI is a standard recognized for music manufacturing, primarily to control equipment such as synthesizer and sound card. The MIDI file does not contain digital audio sampling, but includes a series of instructions that control the synthesis of the musical sequence from different instruments. Some MIDI files contain additional instructions to program a variety of synthetic settings. Most synthesizers support MIDI standards, so music created on a synthesizer can play on another. Computers with MIDI interfaces can manipulate MIDI data to generate new music or sound effects. For example, a complete music work can be converted into a new form via a software-driven command. The Java Sound Engine supports two MIDI file types: MIDI type 0 file - contains only one sequence, all related instrument parts are included on the same logic "track". MIDI Type 1 File - Contains multiple "track" such that different instruments are logically separated, so that the operation and reunion of the sound is easier. The RMF - (extension is RMF) Mixed music format is a hybrid file type designed by Beatnik, and MIDI and audio sampling are packaged together by interactive settings. RMF is like a container of all music related files. RMF also includes support for detailed file instructions on copyright. The RMF file can contain multiple works that are stored as MIDI types or audio sampling types by different artists, each with associated copyright information. The choice of sound engine In 1997, Sun's Java Media Development Group tried to find a way to enhance sound processing capabilities and provide a solid platform for future. According to the Java Media Development Group, Michael Bundschuh said, "We want a very high quality play engine to handle all the operations from the eight μ-Law level until the CD quality sound. We want to easily cross all platforms, such as Solaris platform, Windows, Mac, etc.

We also want to be highly developed with MIDI capabilities that can span different platforms. For the above object, reasonable choice is the BEATNIK's audio engine (from before, it is headspace.) "SUN gets the BEATNIK's audio engine usage license, treat it as the basis of the Java sound application interface API .Thomas Dolby Robertson-Beatnik Introduction to 90 Prior to the beginning of the year, Thomas Dolby Robertson's career is completely in music. The "she uses science to illuminate me" in 1982 is an early MTV masterpiece. Whole 80s, he is constantly composing and recording, use A non-structured music production software. But at 1990, he started thinking about whether to do some of the music production capabilities through a demonstration of the Guggenheim Museum, he began to do some work that improved music production. "I was in the shoulder of the C programmer at the time." And I suddenly realized that I made a lot of work for doing records, but I didn't do anything for the interaction of performance. "With this idea, Robertson established Headspace in 1992, hired Moonlight Components to help achieve his point. Beatnik. Java sound audio engine Java sound engine is now created for multimedia in 1996. Also considering the game design and releases web content. Use standard MIDI files, RMF files, and / or sampling from any source, the engine will play music or manufacturing sound effects, while using CPUs as little as possible. It provides full playback Control, the ability to mix the sound and respond to the user's input in real time. Java sound engine is a software MIDI synthesizer, sampling player, and a 16-bit stereo hybrid. It supports mixing until 64-bit stereo MIDI sound and audio sampling. It supports MIDI type 0 and type 1 files and synthesis from 8-bit devices to 16-bit instruments. The engine supports all universal MIDI controllers and contains echo processing, LFO (control filter or stereo equipment) Features, as well as ADSR envelopes (plastic samples when playing). That is, the Java sound engine also takes no more than 30% of the CPU time on a 90MHz Pentium computer. It can also disable no need by selectively disabled The characteristics make it more efficient. In addition, it released the rich content stored in the compressed RMF music file. "She uses science to illuminate me", a 7-minute 21 seconds of "Tomas Dolby Robertson" Songs, such as files that are stored as CD, take up 70M byte space. If you store only about 636 kB in RMF format, it is 120: 1 reduction, and does not minus quality. For more information about Beatnik, please Look at Beatnik's Web Site. The brief history of the Java platform sound is under JDK 1.0.x and JDK 1.1.x, the Audioclip interface provides the following functions: l AudioClip interface playback loop stop recovery and play the simpler method to play the sound of the APPLET class () Method. Calling the Play () method has the following two ways: play () - with a parameter, a URL object, loading and playing the sound piece stored in the URL .play () - With two parameters, basics URL and folder path name, loading and playing sound files. The first parameter is often called getCodeBase () or getDocumentbase (). The following code segment illustrates the method of directly playing Hello.au.Au files and applets The same folder or directory. Play (getcodebase (), "hello.au"); play () Once you are called immediately start recovery and play sound . If the sound file cannot be found, there will be no error information, just silence. Start and stop the sound file, or loop play, you must load it into the AudioClip object with the Applet's GetAudioClip method, similar to the parameters of the above () method, the GetAudioclip method uses one or two parameters as the indication of the playback.

The first or unique parameter is the URL parameter, used to indicate the location of the sound file, the second parameter is the folder path pointer. The following code line example will now describe the loading sound file into the cliphedu: audioclip co = getAudioClip (getcodebase (), "horns.wav"); getaudioclip () method can only be called within the applet. As Java2 introduces, the application can also load the sound file with the Newaudioclip method of the Applet class. The former example can rewrite the following for Java applications: audioclip co = newaudioclip ("HORns.wav"); after you have created an AudioClip object, you can call Play (), loop (), and stop () method. If the getaudioclip or newaudioclip method does not find the specified sound file, the value of the Audioclip object will be empty. Trying to play an empty object will result in an error, so the standard process is first detected. Next is a complete programming example, the program will generate an applet, which will play Flute HRN MRMBA.Au music sample when the mouse is pressed within the applet range. This Au sample file is in the same directory or folder. import java.applet *;. import java.awt.event *;. public class PlayAudio extends Appletimplements MouseListener {AudioClip audio; public void init () {audio = getAudioClip (getDocumentBase (), "flute hrn mrmba.au") ; addMouseListener (this);} public void mousePressed (MouseEvent evt) {if (audio = null!) audio.play ();} public void mouseEntered (MouseEvent me) {} public void mouseExited (MouseEvent me) {} public void mouseClicked (MouseEvent Me) {} public void mousereleased (MouseEvent Me) {}} Note: In many Java2 technical books, the mousedown () method is indeed part of the Java 1.0 event model. This method is used to have a certain risk because the method may not be supported in the future. Combining MouseListener and MousePressed in Java2 platform is preferred. API 1.0-Quality Leap Note: The following note is based on the earlier version 0.86 of Java API. Although most of the objects and concepts discussed here are consistent with the past, some changes may exist because the API version has terminated. Java Sound 1.0 API defines a complete set of basic underlying audio processing functions for the Java platform. It provides the following interfaces to: audio capture and play IDi synthesis and serialization These two main functional modules are provided in their respective packages. Javax.media.sound.sampled-This package explicitly illustrates the interface of capture, mix, and playback digital sampling audio. Javax.media.sound.midi- This package provides interfaces that MIDI synthesis, serialization, and event transfer.

Java 1.0 API has the following features: Digital Audio

Frequency capture - data capture from the input source such as the microphone. Tone and replay - mix the sound of various input sources and replay. System and Coding - Adjusting Gain, Positioning, Echo Processing, etc., and format conversion. State and its prompt - When replay start and end, the device is opened or closed and other related events will receive events. Support for MIDI

MIDI Message - Exchange Message (Tool Notes, Close Mins, etc.) Synthesis - Put the instrument from the MIDI data and generate sound. Serialization - Load a MIDI sequence, start and stop playback, and adjust the rhythm. tool

Part Enter Output - Read and write universal audio files such as WAV, AIFF, and MIDI set-query systems to get information for components and devices; install or cancel coding, file analyzers, and devices.

Digital Audio Channel Kara Kytle, Java Sound API Director Engineer and System Designer said: "Channel is the basic functional component in the audio pipe." Implementing the class of the Channel interface represents an element of the "pipe", such as a hardware device, a sound synthesizer, or a single audio stream. InputChannel and OutputChannel inherit the Channel, which is used to read the captured data and to write data. The sub-interface CLIP supports cyclic play and repositioning of pre-installed audio data. Device represents any hardware or software devices for capture, play or mix audio. The hierarchy of this interface is shown below. Reference javax.media.sound.sampled. When a Channel is turned on, it retains system resources for yourself, and when it ends, these resources are released to other applications and objects. Use the isopen () method to query Channel whether it is open or off. The processing of data is typically started by sub-interface methods such as a READ () method, which is described in the INPUTCHANNEL interface description (see the Java Sound API manual). The processing method makes the Channel are in the state where the audio data is entered or output. Use the isactive method to identify if the Channel is in this state. By calling the PAUSE () method, the channel can be paused, this state can be discriminated by the ispaused () method. When the channel is suspended, there are three options: retention data (default), discard the data in the inner buffer with a flush () method, or use the DRAIN () method to make the data in the internal cache immediately processed. Objects can be registered in advance, so that it can receive advertisement information whenever the channel state changes. The registration object must implement the Channel.Listener interface, which contains only one method update (). This method will be called when Channel opens, ends, start, and stops. START or STOP events will be generated when Channel starts or stops activity and starting or stopping capturing data. Input Channel INPUTCHANNEL is the source of the captured audio data. This interface provides a method to read the captured data from the InputChannel buffer, and determine the currently readable amount of data. If the application tries to read too much data, the reading method is blocked until the required read data is reached. Output channel OutputChannel receives audio data for playback. This interface provides a method that writes the data to be played into the buffer of OutputChannel, and can determine the amount of data that the channel is uninterruptible. If the application tries to write excessive data, the reading method blocks until there is enough data. The clip CLIP interface represents a special channel that can be loaded into audio data before playing. Since the data is pre-installed, the Clip can support continuous queries, loop play, and reposition playback. The device DEVICE interface is a class that represents the audio device. The audio device can be shared or exclusive system resources, which can be hardware, or software, but also based on both. It can be repeatedly opened and closed, which can often explain its intrinsic characteristics and supported audio formats. At the same time, it also provides an information object to describe the device. Java Sound API further describes three devices sub-interfaces: The InputDeviceInputDevice interface provides a method GetInputChannel to get an InputChannel object that captures readable audio data. The OutputDeviceOutputDevice interface provides a method GetputPutChannel to get an OutputChannel object, and audio data can be written to the output channel and play it. MixerMixer supports multiple InputChannel and / or CLIPs. In addition, it provides a query method that can be obtained from the number of channels it supports, which also provides a method of supporting synchronous pause and awakening multiple channel playback. Control channels and audio ports (such as speakers and microphones) typically support a set of controls such as gain and positioning.

By passing it as a parameter to getControl () method, the channel object and port object of Java Sound API can get a special control. Encoder CODECs can encode and decode audio data, allow conversion between different formats and codes. The Java Sound API provides advanced interfaces for these conversions through the Audiosystem class. If a special audio stream is given, the application queries the audio system to find the corresponding conversion, resulting in an audio stream in the specified format. Files and rogue flows are input streams associated with audio data format and data length, and the file stream is an input stream associated with file type and data length. The Java Sound API provides an interface between the conversion between the audio file and the audio stream in the Audiosystem class. Query and Access the Installation Components Audiosystem class acts as a role of the sampling audio system resource entry. This class allows programmers to query and access input devices, output devices, and installed mixers. In addition, AUDIOSYSTEM contains many methods of conversion between different audio data formats. It also provides some methods such that the input channel or output channel is directly obtained without the direct operation of the device. System Configuration - Service Provider Interface (SPI) The configuration of the sampling audio system is done by javax.media.sound.sampled.spi package. Through the AudioConfig class, you can install or uninstall the device in the system, and the default state can be established. Service providers can want to provide and install their own encoders and analyzers. This package provides a mechanism to complete this function. The following figure depicts the audio input and the output function stream. Midijavax.media.sound.midi package describes MIDI event transfer, synthesis, and serialization interfaces. The main concepts used in the package are described below. Transfer the basic MIDI transfer interface is MIDIDEVICE. All devices provide a method for the pre-supporting mode and query the current mode. The device supports the listener, you can listen to various events such as opening and closing the event, and there is an information object to describe the device status. Typically, the device is one of the transmitters or receivers of the MIDI event. The transmitter interface provides some ways to set and query the receiver, which receives the MIDI event transmitted by the transmitter. The receiver provides a method for receiving the MIDI event. The basic MIDIEVENT object is an event type, data length, and status through a message. It also provides accurate timing signals for devices involving MIDI timing, such as sequencer. The synthesizer synthesizer interface is a special type of receiver that generates sound. It also provides some ways to manage sound libraries and instruments. In addition, the synthesizer can support a set of global non-MIDI controls such as gain and positioning. It also provides access to a group of MIDI channels, in fact, the sound is generated by these channels. The Midichannel interface provides a set of methods to express public MIDI sound messages such as Noteon, Noteoff, and ControlChange. Also supports queries for current channel status. The serialization Sequencer interface inherits MIDIDEVICE, which provides a method of completing basic MIDI serialization operations. The sequencer can load and play a sequence, query, and set the rhythm, and control the master from synchronization. An application can also notify yourself by registering that you will notify yourself when processing device units and controller events. Files and serialized sequences represent a MIDI sequence from one or more tracks and related timing information. A track object contains a series of plus time tagged MIDI events. Java Sound API provides advanced interfaces for transitions between MIDI files and serialized objects in the MIDISystem class. Query and access the installed component MIDISystem class act as the role of the MIDI music system entry. It provides information about related devices and access it, including transmitters, receivers, synthesizers, and sequencers. It also provides access to the SoundBank object. System Configuration - Service Provider Interface (SPI) MIDI system is completed by javax.media.sound.midi.spi package. With the MIDICONFIG class, the device can be installed in the system or uninstall it from it, and the default state can be established. Service providers can want to provide and install their own files and sound library analyzers. The SPI package includes the mechanism of completing this function.

Let us now see what can do with these classes and methods. Please check it carefully. The TOYSYNTH application TOYSYNTH application tests the way to access the Java sound API, mainly by providing a range of device settings, including MIDI channel selection, volume control, stereo positioning, echo processing, and other options. You can play the song using the specified device by tapping the keyboard, and these devices are all achieved through the Java sound engine. Complete ToySynth.java code sample. Downloading the Java Sound API can get an exemplary application and its source code. Java Sound API's Market Target Java Sound API provides sound support for a wide range of applications. Some possible applications are listed below. Communication framework convened remote conferences on a computer to implement phone function content publishing system music information streaming media distribution interactive application game Web site generates dynamic content tool set content

What can we do on this basis? Java 2 accesses the Java sound audio engine via the AudioClip interface. With the release of 1.0 API, we have explored the developers provided to all local developers. "Now, we started the computer desktop multimedia market by joining the support of the real sound in the Java2 platform. In the future, we will see our Java sound API technology is widely used in professionals, ordinary users, and audio applications on the Internet." Michael Bundschuh said. Movies and tape companies can get professional quality audio effects by using Java sound API technology. Implementing 24-bit audio and multi-channel configurations in the Java sound engine will encourage professionals to develop advanced sound editing and playing applications. According to Kara Kytle, support for more audio data, such as MP3, has been mentioned to agenda. "Another agenda is captured from external devices. This will be realized quickly." She said. "Java Sound API technology can be well applicable to audio playback through web." Bundschuh said. "But we always track the latest technology and develop techniques such as MP3, while also protecting the security transfer of music files. We plan to provide support for the above techniques in the future version of the Java Sound API." With the development of the recent market, like playing a web-based competition strategy, everyone has placed the development of digital sounds in the center. The new media technology continues to emerge, and the sound will play the core role. Java Sound 1.0 API will join the new key application development ranks in a timely manner. You can get the TOYSYNTH.JAVA program code This program represents a synthesizer as a graphic image, and it is played by the mouse to play the music. You can change the tone of the sound by sound settings and other options. Enjoy playing. Related URLSJAVA Sound API - Description, Download Information, Related Data Sheet, FAQ Http://www.java.sun.com/products/java-media/sound/ beatnikhtp://www.beatnik.com Java Media Framework API (JMF) http://www.java.sun.com/products/ java 3D APIHTTP: //www.java.sun.com/products/java-media/3D/

Welcome to contact us: Webmaster@prc.sun.com Copyright 1997-1998 Sun (China) Company, 16th Floor, Jianwei Building, No. 66 Beijing Nanke Road

转载请注明原文地址:https://www.9cbs.com/read-886.html

New Post(0)