WavAudioFormatpublic class WavAudioFormat extends AudioFormat
Fields Summary |
---|
public static final int | WAVE_FORMAT_PCM | public static final int | WAVE_FORMAT_ADPCM | public static final int | WAVE_FORMAT_ALAW | public static final int | WAVE_FORMAT_MULAW | public static final int | WAVE_FORMAT_OKI_ADPCM | public static final int | WAVE_FORMAT_DIGISTD | public static final int | WAVE_FORMAT_DIGIFIX | public static final int | WAVE_FORMAT_GSM610 | public static final int | WAVE_IBM_FORMAT_MULAW | public static final int | WAVE_IBM_FORMAT_ALAW | public static final int | WAVE_IBM_FORMAT_ADPCM | public static final int | WAVE_FORMAT_DVI_ADPCM | public static final int | WAVE_FORMAT_SX7383 | public static final int | WAVE_FORMAT_DSPGROUP_TRUESPEECH | public static final int | WAVE_FORMAT_MSNAUDIO | public static final int | WAVE_FORMAT_MSG723 | public static final int | WAVE_FORMAT_MPEG_LAYER3 | public static final int | WAVE_FORMAT_VOXWARE_AC8 | public static final int | WAVE_FORMAT_VOXWARE_AC10 | public static final int | WAVE_FORMAT_VOXWARE_AC16 | public static final int | WAVE_FORMAT_VOXWARE_AC20 | public static final int | WAVE_FORMAT_VOXWARE_METAVOICE | public static final int | WAVE_FORMAT_VOXWARE_METASOUND | public static final int | WAVE_FORMAT_VOXWARE_RT29H | public static final int | WAVE_FORMAT_VOXWARE_VR12 | public static final int | WAVE_FORMAT_VOXWARE_VR18 | public static final int | WAVE_FORMAT_VOXWARE_TQ40 | public static final int | WAVE_FORMAT_VOXWARE_TQ60 | public static final int | WAVE_FORMAT_MSRT24 | protected byte[] | codecSpecificHeader | private int | averageBytesPerSecond | public static final Hashtable | formatMapper | public static final Hashtable | reverseFormatMapper |
Constructors Summary |
---|
public WavAudioFormat(String encoding)
formatMapper.put(new Integer(WAVE_FORMAT_PCM), LINEAR);
formatMapper.put(new Integer(WAVE_FORMAT_ADPCM), MSADPCM);
// formatMapper.put(new Integer(WAVE_FORMAT_DVI_ADPCM), DVI);
formatMapper.put(new Integer(WAVE_FORMAT_DVI_ADPCM), IMA4_MS);
formatMapper.put(new Integer(WAVE_FORMAT_ALAW), ALAW);
formatMapper.put(new Integer(WAVE_FORMAT_MULAW), ULAW);
formatMapper.put(new Integer(WAVE_FORMAT_GSM610), GSM_MS);
formatMapper.put(new Integer(WAVE_FORMAT_DSPGROUP_TRUESPEECH),
TRUESPEECH);
formatMapper.put(new Integer(WAVE_FORMAT_MSNAUDIO),
MSNAUDIO);
formatMapper.put(new Integer(WAVE_FORMAT_VOXWARE_AC8),
VOXWAREAC8);
formatMapper.put(new Integer(WAVE_FORMAT_VOXWARE_AC10),
VOXWAREAC10);
formatMapper.put(new Integer(WAVE_FORMAT_VOXWARE_AC16),
VOXWAREAC16);
formatMapper.put(new Integer(WAVE_FORMAT_VOXWARE_AC20),
VOXWAREAC20);
formatMapper.put(new Integer(WAVE_FORMAT_VOXWARE_METAVOICE),
VOXWAREMETAVOICE);
formatMapper.put(new Integer(WAVE_FORMAT_VOXWARE_METASOUND),
VOXWAREMETASOUND);
formatMapper.put(new Integer(WAVE_FORMAT_VOXWARE_RT29H),
VOXWARERT29H);
formatMapper.put(new Integer(WAVE_FORMAT_VOXWARE_VR12),
VOXWAREVR12);
formatMapper.put(new Integer(WAVE_FORMAT_VOXWARE_VR18),
VOXWAREVR18);
formatMapper.put(new Integer(WAVE_FORMAT_VOXWARE_TQ40),
VOXWARETQ40);
formatMapper.put(new Integer(WAVE_FORMAT_VOXWARE_TQ60),
VOXWARETQ60);
formatMapper.put(new Integer(WAVE_FORMAT_MPEG_LAYER3),
MPEGLAYER3);
formatMapper.put(new Integer(WAVE_FORMAT_MSRT24),
MSRT24);
// Reverse mappings: These will be used by FileWriters
reverseFormatMapper.put(LINEAR.toLowerCase(), new Integer(WAVE_FORMAT_PCM));
reverseFormatMapper.put(MSADPCM.toLowerCase(), new Integer(WAVE_FORMAT_ADPCM));
reverseFormatMapper.put(IMA4_MS.toLowerCase(), new Integer(WAVE_FORMAT_DVI_ADPCM));
reverseFormatMapper.put(ALAW.toLowerCase(), new Integer(WAVE_FORMAT_ALAW));
reverseFormatMapper.put(ULAW.toLowerCase(), new Integer(WAVE_FORMAT_MULAW));
reverseFormatMapper.put(GSM_MS.toLowerCase(), new Integer(WAVE_FORMAT_GSM610));
reverseFormatMapper.put(TRUESPEECH.toLowerCase(), new Integer(WAVE_FORMAT_DSPGROUP_TRUESPEECH));
reverseFormatMapper.put(MSNAUDIO.toLowerCase(), new Integer(WAVE_FORMAT_MSNAUDIO));
reverseFormatMapper.put(VOXWAREAC8.toLowerCase(), new Integer(WAVE_FORMAT_VOXWARE_AC8));
reverseFormatMapper.put(VOXWAREAC10.toLowerCase(), new Integer(WAVE_FORMAT_VOXWARE_AC10));
reverseFormatMapper.put(VOXWAREAC16.toLowerCase(), new Integer(WAVE_FORMAT_VOXWARE_AC16));
reverseFormatMapper.put(VOXWAREAC20.toLowerCase(), new Integer(WAVE_FORMAT_VOXWARE_AC20));
reverseFormatMapper.put(VOXWAREMETAVOICE.toLowerCase(), new Integer(WAVE_FORMAT_VOXWARE_METAVOICE));
reverseFormatMapper.put(VOXWAREMETASOUND.toLowerCase(), new Integer(WAVE_FORMAT_VOXWARE_METASOUND));
reverseFormatMapper.put(VOXWARERT29H.toLowerCase(), new Integer(WAVE_FORMAT_VOXWARE_RT29H));
reverseFormatMapper.put(VOXWAREVR12.toLowerCase(), new Integer(WAVE_FORMAT_VOXWARE_VR12));
reverseFormatMapper.put(VOXWAREVR18.toLowerCase(), new Integer(WAVE_FORMAT_VOXWARE_VR18));
reverseFormatMapper.put(VOXWARETQ40.toLowerCase(), new Integer(WAVE_FORMAT_VOXWARE_TQ40));
reverseFormatMapper.put(VOXWARETQ60.toLowerCase(), new Integer(WAVE_FORMAT_VOXWARE_TQ60));
reverseFormatMapper.put(MPEGLAYER3.toLowerCase(), new Integer(WAVE_FORMAT_MPEG_LAYER3));
reverseFormatMapper.put(MSRT24.toLowerCase(), new Integer(WAVE_FORMAT_MSRT24));
super(encoding);
| public WavAudioFormat(String encoding, double sampleRate, int sampleSizeInBits, int channels, int frameSizeInBits, int averageBytesPerSecond, byte[] codecSpecificHeader)
super(encoding, sampleRate, sampleSizeInBits, channels);
this.codecSpecificHeader = codecSpecificHeader;
this.averageBytesPerSecond = averageBytesPerSecond;
this.frameRate = averageBytesPerSecond;
this.frameSizeInBits = frameSizeInBits;
| public WavAudioFormat(String encoding, double sampleRate, int sampleSizeInBits, int channels, int frameSizeInBits, int averageBytesPerSecond, int endian, int signed, float frameRate, Class dataType, byte[] codecSpecificHeader)Construct a WavAudioFormat with all the given parameters.
The bit mask identifies which parameters are actually valid.
super(encoding, sampleRate, sampleSizeInBits, channels, endian, signed,
frameSizeInBits, frameRate, dataType);
this.codecSpecificHeader = codecSpecificHeader;
this.averageBytesPerSecond = averageBytesPerSecond;
this.frameRate = averageBytesPerSecond;
|
Methods Summary |
---|
public java.lang.Object | clone()Return a clone of this format.
WavAudioFormat f = new WavAudioFormat(encoding);
f.copy(this);
return f;
| protected void | copy(javax.media.Format f)Copy the attributes from the given object.
super.copy(f);
WavAudioFormat other = (WavAudioFormat) f;
averageBytesPerSecond = other.averageBytesPerSecond;
codecSpecificHeader = other.codecSpecificHeader;
| public boolean | equals(java.lang.Object format)
if (format instanceof WavAudioFormat) {
WavAudioFormat other = (WavAudioFormat) format;
if (!super.equals(format))
return false;
if (codecSpecificHeader == null && other.codecSpecificHeader == null)
return true;
if (codecSpecificHeader == null || other.codecSpecificHeader == null)
return false;
if (codecSpecificHeader.length != other.codecSpecificHeader.length)
return false;
for (int i = 0; i < codecSpecificHeader.length; i++) {
if ( codecSpecificHeader[i] != other.codecSpecificHeader[i] )
return false;
}
return true;
}
return false;
| public int | getAverageBytesPerSecond()Returns the average bytes per second.
return averageBytesPerSecond;
| public byte[] | getCodecSpecificHeader()Returns the codec specific header bytes available in the wav header.
return codecSpecificHeader;
| public javax.media.Format | intersects(javax.media.Format format)Find the common attributes of two matching formats.
If the given format does not match this one, the result is
undefined. Otherwise, it returns a format object
with its attributes set to the common attributes of the two.
Format fmt;
if ((fmt = super.intersects(format)) == null)
return null;
if (!(format instanceof WavAudioFormat))
return fmt;
WavAudioFormat other = (WavAudioFormat)format;
WavAudioFormat res = (WavAudioFormat)fmt;
res.codecSpecificHeader = (codecSpecificHeader != null ?
codecSpecificHeader : other.codecSpecificHeader);
return res;
| public boolean | matches(javax.media.Format format)Test to see if the given format matches this format.
Matches compares attributes that are defined and ignore attributes
that are unspecified.
Two formats do not have to be of the same class to be considered
a match. Say "A" are "B" are the two classes. If "A" derives "B"
or "B" derives "A", then a match is possible (after comparing
individual attributes. Otherwise, matches fails. This is to
prevent matching VideoFormat and AudioFormat, for example.
if (!super.matches(format))
return false;
if (!(format instanceof WavAudioFormat))
return true;
WavAudioFormat other = (WavAudioFormat) format;
if ( (codecSpecificHeader == null) ||
other.codecSpecificHeader == null )
return true;
if (codecSpecificHeader.length != other.codecSpecificHeader.length)
return false;
for (int i = 0; i < codecSpecificHeader.length; i++) {
if ( codecSpecificHeader[i] != other.codecSpecificHeader[i] )
return false;
}
return true;
|
|