本文整理匯總了Java中javax.sound.sampled.AudioFormat.matches方法的典型用法代碼示例。如果您正苦於以下問題:Java AudioFormat.matches方法的具體用法?Java AudioFormat.matches怎麽用?Java AudioFormat.matches使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.sound.sampled.AudioFormat
的用法示例。
在下文中一共展示了AudioFormat.matches方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isConversionSupported
import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
/**
* Indicates whether the format converter supports conversion to one
* particular format from another.
* @param targetFormat desired format of outgoing data
* @param sourceFormat format of the incoming data
* @return <code>true</code> if the conversion is supported, otherwise <code>false</code>
*/
public boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat){
AudioFormat targetFormats[] = getTargetFormats( targetFormat.getEncoding(), sourceFormat );
for(int i=0; i<targetFormats.length; i++) {
if( targetFormat.matches( targetFormats[i] ) ) {
return true;
}
}
return false;
}
示例2: getConvertedStream
import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
/**
* Opens the codec with the specified parameters.
* @param stream stream from which data to be processed should be read
* @param outputFormat desired data format of the stream after processing
* @return stream from which processed data may be read
* @throws IllegalArgumentException if the format combination supplied is
* not supported.
*/
private AudioInputStream getConvertedStream(AudioFormat outputFormat, AudioInputStream stream) {
AudioInputStream cs = null;
AudioFormat inputFormat = stream.getFormat();
if( inputFormat.matches(outputFormat) ) {
cs = stream;
} else {
cs = new AlawCodecStream(stream, outputFormat);
}
return cs;
}
示例3: isFormatSupportedInHardware
import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
public boolean isFormatSupportedInHardware(AudioFormat format) {
if (format == null) return false;
for (int i = 0; i < hardwareFormats.length; i++) {
if (format.matches(hardwareFormats[i])) {
return true;
}
}
return false;
}
示例4: getConvertedStream
import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
/**
* Opens the codec with the specified parameters.
* @param stream stream from which data to be processed should be read
* @param outputFormat desired data format of the stream after processing
* @return stream from which processed data may be read
* @throws IllegalArgumentException if the format combination supplied is
* not supported.
*/
private AudioInputStream getConvertedStream(AudioFormat outputFormat, AudioInputStream stream) {
AudioInputStream cs = null;
AudioFormat inputFormat = stream.getFormat();
if( inputFormat.matches(outputFormat) ) {
cs = stream;
} else {
cs = new UlawCodecStream(stream, outputFormat);
}
return cs;
}
示例5: isContains
import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
private static boolean isContains(AudioFormat obj, AudioFormat[] array) {
for (final AudioFormat format : array) {
if (obj.matches(format)) {
return true;
}
}
return false;
}
示例6: open
import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
public final void open(AudioFormat format, int bufferSize) throws LineUnavailableException {
//$$fb 2001-10-09: Bug #4517739: avoiding deadlock by synchronizing to mixer !
synchronized (mixer) {
if (Printer.trace) Printer.trace("> AbstractDataLine.open(format, bufferSize) (class: "+getClass().getName());
// if the line is not currently open, try to open it with this format and buffer size
if (!isOpen()) {
// make sure that the format is specified correctly
// $$fb part of fix for 4679187: Clip.open() throws unexpected Exceptions
Toolkit.isFullySpecifiedAudioFormat(format);
if (Printer.debug) Printer.debug(" need to open the mixer...");
// reserve mixer resources for this line
//mixer.open(this, format, bufferSize);
mixer.open(this);
try {
// open the data line. may throw LineUnavailableException.
implOpen(format, bufferSize);
// if we succeeded, set the open state to true and send events
setOpen(true);
} catch (LineUnavailableException e) {
// release mixer resources for this line and then throw the exception
mixer.close(this);
throw e;
}
} else {
if (Printer.debug) Printer.debug(" dataline already open");
// if the line is already open and the requested format differs from the
// current settings, throw an IllegalStateException
//$$fb 2002-04-02: fix for 4661602: Buffersize is checked when re-opening line
if (!format.matches(getFormat())) {
throw new IllegalStateException("Line is already open with format " + getFormat() +
" and bufferSize " + getBufferSize());
}
//$$fb 2002-07-26: allow changing the buffersize of already open lines
if (bufferSize > 0) {
setBufferSize(bufferSize);
}
}
if (Printer.trace) Printer.trace("< AbstractDataLine.open(format, bufferSize) completed");
}
}
示例7: getConvertedStream
import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
/**
* Opens the codec with the specified parameters.
* @param stream stream from which data to be processed should be read
* @param outputFormat desired data format of the stream after processing
* @return stream from which processed data may be read
* @throws IllegalArgumentException if the format combination supplied is
* not supported.
*/
private AudioInputStream getConvertedStream(AudioFormat outputFormat, AudioInputStream stream) {
AudioInputStream cs = null;
AudioFormat inputFormat = stream.getFormat();
if( inputFormat.matches(outputFormat) ) {
cs = stream;
} else {
cs = new PCMtoPCMCodecStream(stream, outputFormat);
}
return cs;
}