📄 audioformat.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc on Thu Apr 27 23:37:56 PDT 2000 --><TITLE>Java 2 Platform SE v1.3: Class AudioFormat</TITLE><LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style"></HEAD><BODY BGCOLOR="white"><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/AudioFormat.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Std. Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../javax/sound/sampled/AudioFileFormat.Type.html"><B>PREV CLASS</B></A> <A HREF="../../../javax/sound/sampled/AudioFormat.Encoding.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="AudioFormat.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: <A HREF="#inner_class_summary">INNER</A> | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">javax.sound.sampled</FONT><BR>Class AudioFormat</H2><PRE><A HREF="../../../java/lang/Object.html">java.lang.Object</A> | +--<B>javax.sound.sampled.AudioFormat</B></PRE><HR><DL><DT>public class <B>AudioFormat</B><DT>extends <A HREF="../../../java/lang/Object.html">Object</A></DL><P><code>AudioFormat</code> is the class that specifies a particular arrangement of data in a sound stream. By examing the information stored in the audio format, you can discover how to interpret the bits in the binary sound data. <p> Every data line has an audio format associated with its data stream. The audio format of a source (playback) data line indicates what kind of data the data line expects to receive for output. For a target (capture) data line, the audio format specifies the kind of the data that can be read from the line. Sound files also have audio formats, of course. The <code><A HREF="../../../javax/sound/sampled/AudioFileFormat.html"><CODE>AudioFileFormat</CODE></A></code> class encapsulates an <code>AudioFormat</code> in addition to other, file-specific information. Similarly, an <code><A HREF="../../../javax/sound/sampled/AudioInputStream.html"><CODE>AudioInputStream</CODE></A></code> has an <code>AudioFormat</code>. <p> The <code>AudioFormat</code> class accommodates a number of common sound-file encoding techniques, including pulse-code modulation (PCM), mu-law encoding, and a-law encoding. These encoding techniques are predefined, but service providers can create new encoding types. The encoding that a specific format uses is named by its <code>encoding</code> field. <p> In addition to the encoding, the audio format includes other properties that further specify the exact arrangement of the data. These include the number of channels, sample rate, sample size, byte order, frame rate, and frame size. Sounds may have different numbers of audio channels: one for mono, two for stereo. The sample rate measures how many "snapshots" (samples) of the sound pressure are taken per second, per channel. (If the sound is stereo rather than mono, two samples are actually measured at each instant of time: one for the left channel, and another for the right channel; however, the sample rate still measures the number per channel, so the rate is the same regardless of the number of channels. This is the standard use of the term.) The sample size indicates how many bits are used to store each snapshot; 8 and 16 are typical values. For 16-bit samples (or any other sample size larger than a byte), byte order is important; the bytes in each sample are arranged in either the "little-endian" or "big-endian" style. For encodings like PCM, a frame consists of the set of samples for all channels at a given point in time, and so the size of a frame (in bytes) is always equal to the size of a sample (in bytes) times the number of channels. However, with some other sorts of encodings a frame can contain a bundle of compressed data for a whole series of samples, as well as additional, non-sample data. For such encodings, the sample rate and sample size refer to the data after it is decoded into PCM, and so they are completely different from the frame rate and frame size.<P><DL><DT><B>Since: </B><DD>1.3</DD><DT><B>See Also: </B><DD><A HREF="../../../javax/sound/sampled/DataLine.html#getFormat()"><CODE>DataLine.getFormat()</CODE></A>, <A HREF="../../../javax/sound/sampled/AudioInputStream.html#getFormat()"><CODE>AudioInputStream.getFormat()</CODE></A>, <A HREF="../../../javax/sound/sampled/AudioFileFormat.html"><CODE>AudioFileFormat</CODE></A>, <A HREF="../../../javax/sound/sampled/spi/FormatConversionProvider.html"><CODE>FormatConversionProvider</CODE></A></DL><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><A NAME="inner_class_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Inner Class Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static class</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/sound/sampled/AudioFormat.Encoding.html">AudioFormat.Encoding</A></B></CODE><BR> The <code>Encoding</code> class names the specific type of data representation used for an audio stream.</TD></TR></TABLE> <!-- =========== FIELD SUMMARY =========== --><A NAME="field_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Field Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/sound/sampled/AudioFormat.html#bigEndian">bigEndian</A></B></CODE><BR> Indicates whether the audio data is stored in big-endian or little-endian order.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/sound/sampled/AudioFormat.html#channels">channels</A></B></CODE><BR> The number of audio channels in this format (1 for mono, 2 for stereo).</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected <A HREF="../../../javax/sound/sampled/AudioFormat.Encoding.html">AudioFormat.Encoding</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/sound/sampled/AudioFormat.html#encoding">encoding</A></B></CODE><BR> The audio encoding technique used by this format.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected float</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/sound/sampled/AudioFormat.html#frameRate">frameRate</A></B></CODE><BR> The number of frames played or recorded per second, for sounds that have this format.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/sound/sampled/AudioFormat.html#frameSize">frameSize</A></B></CODE><BR> The number of bytes in each frame of a sound that has this format.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected float</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/sound/sampled/AudioFormat.html#sampleRate">sampleRate</A></B></CODE><BR> The number of samples played or recorded per second, for sounds that have this format.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/sound/sampled/AudioFormat.html#sampleSizeInBits">sampleSizeInBits</A></B></CODE><BR> The number of bits in each sample of a sound that has this format.</TD></TR></TABLE> <!-- ======== CONSTRUCTOR SUMMARY ======== --><A NAME="constructor_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Constructor Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../../javax/sound/sampled/AudioFormat.html#AudioFormat(javax.sound.sampled.AudioFormat.Encoding, float, int, int, int, float, boolean)">AudioFormat</A></B>(<A HREF="../../../javax/sound/sampled/AudioFormat.Encoding.html">AudioFormat.Encoding</A> encoding, float sampleRate, int sampleSizeInBits, int channels, int frameSize, float frameRate, boolean bigEndian)</CODE><BR> Constructs an <code>AudioFormat</code> with the given parameters.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../../javax/sound/sampled/AudioFormat.html#AudioFormat(float, int, int, boolean, boolean)">AudioFormat</A></B>(float sampleRate, int sampleSizeInBits, int channels, boolean signed, boolean bigEndian)</CODE><BR> Constructs an <code>AudioFormat</code> with a linear PCM encoding and the given parameters.</TD></TR></TABLE> <!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Method Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/sound/sampled/AudioFormat.html#getChannels()">getChannels</A></B>()</CODE><BR> Obtains the number of channels.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../../javax/sound/sampled/AudioFormat.Encoding.html">AudioFormat.Encoding</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/sound/sampled/AudioFormat.html#getEncoding()">getEncoding</A></B>()</CODE><BR> Obtains the type of encoding for sounds in this format.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> float</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/sound/sampled/AudioFormat.html#getFrameRate()">getFrameRate</A></B>()</CODE><BR> Obtains the frame rate in frames per second.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/sound/sampled/AudioFormat.html#getFrameSize()">getFrameSize</A></B>()</CODE><BR> Obtains the frame size in bytes.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> float</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/sound/sampled/AudioFormat.html#getSampleRate()">getSampleRate</A></B>()</CODE><BR> Obtains the sample rate.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/sound/sampled/AudioFormat.html#getSampleSizeInBits()">getSampleSizeInBits</A></B>()</CODE><BR> Obtains the size of a sample.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/sound/sampled/AudioFormat.html#isBigEndian()">isBigEndian</A></B>()</CODE><BR> Indicates whether the audio data is stored in big-endian or little-endian byte order.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/sound/sampled/AudioFormat.html#matches(javax.sound.sampled.AudioFormat)">matches</A></B>(<A HREF="../../../javax/sound/sampled/AudioFormat.html">AudioFormat</A> format)</CODE><BR> Indicates whether this format matches the one specified.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/sound/sampled/AudioFormat.html#toString()">toString</A></B>()</CODE>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -