本文整理汇总了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;
}