Java sound processing
There are many species of digital audio format, and its quality is related to sampling frequency and sampling accuracy. Frequency table
The unit is Hertz [Hz], which means the number of samples per second. The higher the sampling frequency, the better the sound quality. sampling
Accuracy is the amount of data stored at each sample, which determines the discrete amplitude that can be represented by each digital signal
quantity. The more data that stores each sample, the better the sound quality. But high quality sound needs to take up
The amount of memory and disk space. Considering the network bandwidth, it takes a long time to transfer in the Internet connection.
time. For Applet, the minimization of the sound file is extremely important.
Java can support the following four sound formats:
◆ au
◆ AIFF
◆ Wave
◆ MIDI
The first sound format AU is the only sound format supported by previous Java 1.1 versions. Sampling frequency is 80
00 Hertz, sampling accuracy is 8 bits. AIFF and WAVE are used in the AU format used to represent digital sounds.
Among them, Wave format provides a wider range of sound quality. MIDI format is dedicated to music, and with musical notes and music
The sound is not a digital sound to describe the sound.
About the creation of sound: The most spoken sound wearing key tools for standard applications in Windows 9x - recording
machine. The recorded format is WAVE. There are also many professional applications, science samples and editing numbers.
The sound of the sound, and the conversion of formats.
Resource demand:
■ Hardware resource requirements:
(1) sound card
(2) speaker
# If you need to record sound, this also needs a microphone.
■ Software resource requirements:
(1) Windows9X operating system
(2) Web browser
(3) Java plugin / running time environment
Treatment plan
Java2 begins, Java language can support the above four sound formats. Simple method is to pass A in Java
The AUDIOCLIP () interface of the Pplet class is loaded. This interface is a common method for sound pieces.
, With minimal support for playing sound pieces.
This interface defines the following method:
■ play ()
Grammar: void play ()
Function: Start playing sound pieces.
Regardless of whether the sound piece is already playing, it is played from the beginning. Play over, but not repeated.
■ loop ()
Grammar: void loop ()
Function: Cyclic play sound pieces.
Calling this method is to start playing from the head regardless of whether the sound piece is already playing.
■ STOP ()
Grammar: void stop ()
Function: Stop playing sound pieces.
AUDIOCLIP interface can get sound pieces through GetAudioclip () and getCodeBase () methods and
URL address.
This method can be utilized to play the specified sound piece in the web page.
# Demand: Based on the development environment of JDK1.2 or later. If only play the sound file in the AU format, JDK1
.1 can be. 1.
Addition: Soundtest.html Source Code
HTML Test Page
Title>
HEAD>