本文整理匯總了Java中javax.sound.sampled.AudioFormat.Encoding方法的典型用法代碼示例。如果您正苦於以下問題:Java AudioFormat.Encoding方法的具體用法?Java AudioFormat.Encoding怎麽用?Java AudioFormat.Encoding使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.sound.sampled.AudioFormat
的用法示例。
在下文中一共展示了AudioFormat.Encoding方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: WaveFileFormat
import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
WaveFileFormat(AudioFileFormat.Type type, int lengthInBytes, AudioFormat format, int lengthInFrames) {
super(type,lengthInBytes,format,lengthInFrames);
AudioFormat.Encoding encoding = format.getEncoding();
if( encoding.equals(AudioFormat.Encoding.ALAW) ) {
waveType = WAVE_FORMAT_ALAW;
} else if( encoding.equals(AudioFormat.Encoding.ULAW) ) {
waveType = WAVE_FORMAT_MULAW;
} else if( encoding.equals(AudioFormat.Encoding.PCM_SIGNED) ||
encoding.equals(AudioFormat.Encoding.PCM_UNSIGNED) ) {
waveType = WAVE_FORMAT_PCM;
} else {
waveType = WAVE_FORMAT_UNKNOWN;
}
}
示例2: getAudioFileTypes
import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
public AudioFileFormat.Type[] getAudioFileTypes(AudioInputStream stream) {
AudioFileFormat.Type[] filetypes = new AudioFileFormat.Type[types.length];
System.arraycopy(types, 0, filetypes, 0, types.length);
// make sure we can write this stream
AudioFormat format = stream.getFormat();
AudioFormat.Encoding encoding = format.getEncoding();
if( AudioFormat.Encoding.ALAW.equals(encoding) ||
AudioFormat.Encoding.ULAW.equals(encoding) ||
AudioFormat.Encoding.PCM_SIGNED.equals(encoding) ||
AudioFormat.Encoding.PCM_UNSIGNED.equals(encoding) ) {
return filetypes;
}
return new AudioFileFormat.Type[0];
}
示例3: getAudioFileTypes
import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
@Override
public Type[] getAudioFileTypes(AudioInputStream stream) {
Type[] filetypes = new Type[types.length];
System.arraycopy(types, 0, filetypes, 0, types.length);
// make sure we can write this stream
AudioFormat format = stream.getFormat();
AudioFormat.Encoding encoding = format.getEncoding();
if (AudioFormat.Encoding.ALAW.equals(encoding)
|| AudioFormat.Encoding.ULAW.equals(encoding)
|| AudioFormat.Encoding.PCM_SIGNED.equals(encoding)
|| AudioFormat.Encoding.PCM_UNSIGNED.equals(encoding)
|| AudioFormat.Encoding.PCM_FLOAT.equals(encoding)) {
return filetypes;
}
return new Type[0];
}
示例4: getAudioFileTypes
import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
public AudioFileFormat.Type[] getAudioFileTypes(AudioInputStream stream) {
AudioFileFormat.Type[] filetypes = new AudioFileFormat.Type[types.length];
System.arraycopy(types, 0, filetypes, 0, types.length);
// make sure we can write this stream
AudioFormat format = stream.getFormat();
AudioFormat.Encoding encoding = format.getEncoding();
if( (AudioFormat.Encoding.ALAW.equals(encoding)) ||
(AudioFormat.Encoding.ULAW.equals(encoding)) ||
(AudioFormat.Encoding.PCM_SIGNED.equals(encoding)) ||
(AudioFormat.Encoding.PCM_UNSIGNED.equals(encoding)) ) {
return filetypes;
}
return new AudioFileFormat.Type[0];
}
示例5: getAudioInputStream
import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
/**
*/
public AudioInputStream getAudioInputStream(AudioFormat.Encoding targetEncoding, AudioInputStream sourceStream) {
if( isConversionSupported(targetEncoding, sourceStream.getFormat()) ) {
AudioFormat sourceFormat = sourceStream.getFormat();
AudioFormat targetFormat = new AudioFormat( targetEncoding,
sourceFormat.getSampleRate(),
sourceFormat.getSampleSizeInBits(),
sourceFormat.getChannels(),
sourceFormat.getFrameSize(),
sourceFormat.getFrameRate(),
sourceFormat.isBigEndian() );
return getAudioInputStream( targetFormat, sourceStream );
} else {
throw new IllegalArgumentException("Unsupported conversion: " + sourceStream.getFormat().toString() + " to " + targetEncoding.toString() );
}
}
示例6: main
import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
public static void main(final String[] args) {
for (final int sampleSize : new int[]{4, 8, 16, 24, 32}) {
for (final AudioFormat.Encoding enc : encodings) {
for (final Boolean endian : new boolean[]{false, true}) {
testAS(enc, endian, sampleSize);
for (final FormatConversionProvider fcp : load
(FormatConversionProvider.class)) {
testFCP(fcp, enc, endian, sampleSize);
}
}
}
}
}
示例7: getTargetFormats
import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
/**
*/
public AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat){
if( (AudioFormat.Encoding.PCM_SIGNED.equals(targetEncoding)
&& AudioFormat.Encoding.ULAW.equals(sourceFormat.getEncoding()))
||
(AudioFormat.Encoding.ULAW.equals(targetEncoding)
&& AudioFormat.Encoding.PCM_SIGNED.equals(sourceFormat.getEncoding()))) {
return getOutputFormats(sourceFormat);
} else {
return new AudioFormat[0];
}
}
示例8: getStream
import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
private static AudioInputStream getStream(final AudioFormat.Encoding enc,
final Boolean end,
final int sampleSize) {
final AudioFormat ftmt
= new AudioFormat(enc, 8000, sampleSize, 1, 1, 8000, end);
final byte[] fakedata = new byte[100];
final InputStream in = new ByteArrayInputStream(fakedata);
return new AudioInputStream(in, ftmt, fakedata.length);
}
示例9: getTargetFormats
import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
@Override
public AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat){
Objects.requireNonNull(targetEncoding);
Objects.requireNonNull(sourceFormat);
if( (AudioFormat.Encoding.PCM_SIGNED.equals(targetEncoding)
&& AudioFormat.Encoding.ULAW.equals(sourceFormat.getEncoding()))
||
(AudioFormat.Encoding.ULAW.equals(targetEncoding)
&& AudioFormat.Encoding.PCM_SIGNED.equals(sourceFormat.getEncoding()))) {
return getOutputFormats(sourceFormat);
} else {
return new AudioFormat[0];
}
}
示例10: isTargetEncodingSupported
import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
/**
* Indicates whether the format converter supports conversion to the
* specified target format encoding.
* @param targetEncoding the target format encoding for which support is queried
* @return <code>true</code> if the encoding is supported, otherwise <code>false</code>
*/
public boolean isTargetEncodingSupported(AudioFormat.Encoding targetEncoding){
AudioFormat.Encoding targetEncodings[] = getTargetEncodings();
for(int i=0; i<targetEncodings.length; i++) {
if( targetEncoding.equals( targetEncodings[i]) ) {
return true;
}
}
return false;
}
示例11: getTargetFormats
import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
@Override
public AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat){
Objects.requireNonNull(sourceFormat);
if( (targetEncoding.equals( AudioFormat.Encoding.PCM_SIGNED ) && sourceFormat.getEncoding().equals( AudioFormat.Encoding.ALAW)) ||
(targetEncoding.equals( AudioFormat.Encoding.ALAW) && sourceFormat.getEncoding().equals( AudioFormat.Encoding.PCM_SIGNED)) ) {
return getOutputFormats( sourceFormat );
} else {
return new AudioFormat[0];
}
}
示例12: getTargetEncodings
import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
/**
*/
public AudioFormat.Encoding[] getTargetEncodings(AudioFormat sourceFormat){
if( sourceFormat.getEncoding().equals( AudioFormat.Encoding.PCM_SIGNED ) ||
sourceFormat.getEncoding().equals( AudioFormat.Encoding.PCM_UNSIGNED ) ) {
AudioFormat.Encoding encs[] = new AudioFormat.Encoding[2];
encs[0] = AudioFormat.Encoding.PCM_SIGNED;
encs[1] = AudioFormat.Encoding.PCM_UNSIGNED;
return encs;
} else {
return new AudioFormat.Encoding[0];
}
}
示例13: getTargetEncodings
import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
@Override
public AudioFormat.Encoding[] getTargetEncodings() {
return getSourceEncodings();
}
示例14: getSourceEncodings
import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
/**
*/
public final AudioFormat.Encoding[] getSourceEncodings() {
AudioFormat.Encoding[] encodings = new AudioFormat.Encoding[inputEncodings.length];
System.arraycopy(inputEncodings, 0, encodings, 0, inputEncodings.length);
return encodings;
}
示例15: getTargetEncodings
import javax.sound.sampled.AudioFormat; //導入方法依賴的package包/類
/**
*/
public final AudioFormat.Encoding[] getTargetEncodings() {
AudioFormat.Encoding[] encodings = new AudioFormat.Encoding[outputEncodings.length];
System.arraycopy(outputEncodings, 0, encodings, 0, outputEncodings.length);
return encodings;
}