本文整理汇总了Java中javax.sound.sampled.AudioFormat.toString方法的典型用法代码示例。如果您正苦于以下问题:Java AudioFormat.toString方法的具体用法?Java AudioFormat.toString怎么用?Java AudioFormat.toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.sound.sampled.AudioFormat
的用法示例。
在下文中一共展示了AudioFormat.toString方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAudioInputStream
import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
public AudioInputStream getAudioInputStream(AudioFormat targetFormat,
AudioFloatInputStream sourceStream) {
if (!isConversionSupported(targetFormat, sourceStream.getFormat()))
throw new IllegalArgumentException("Unsupported conversion: "
+ sourceStream.getFormat().toString() + " to "
+ targetFormat.toString());
if (targetFormat.getChannels() != sourceStream.getFormat()
.getChannels())
sourceStream = new AudioFloatInputStreamChannelMixer(sourceStream,
targetFormat.getChannels());
if (Math.abs(targetFormat.getSampleRate()
- sourceStream.getFormat().getSampleRate()) > 0.000001)
sourceStream = new AudioFloatInputStreamResampler(sourceStream,
targetFormat);
return new AudioInputStream(new AudioFloatFormatConverterInputStream(
targetFormat, sourceStream), targetFormat, sourceStream
.getFrameLength());
}
示例2: getAudioInputStream
import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
@Override
public AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInputStream sourceStream){
if (!isConversionSupported(targetFormat, sourceStream.getFormat()))
throw new IllegalArgumentException("Unsupported conversion: "
+ sourceStream.getFormat().toString() + " to "
+ targetFormat.toString());
return getConvertedStream( targetFormat, sourceStream );
}
示例3: getAudioInputStream
import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
@Override
public AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInputStream sourceStream){
if (!isConversionSupported(targetFormat, sourceStream.getFormat()))
throw new IllegalArgumentException("Unsupported conversion: "
+ sourceStream.getFormat().toString() + " to "
+ targetFormat.toString());
return getConvertedStream(targetFormat, sourceStream);
}
示例4: AlawCodecStream
import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
AlawCodecStream(AudioInputStream stream, AudioFormat outputFormat) {
super(stream, outputFormat, -1);
AudioFormat inputFormat = stream.getFormat();
// throw an IllegalArgumentException if not ok
if ( ! (isConversionSupported(outputFormat, inputFormat)) ) {
throw new IllegalArgumentException("Unsupported conversion: " + inputFormat.toString() + " to " + outputFormat.toString());
}
//$$fb 2002-07-18: fix for 4714846: JavaSound ULAW (8-bit) encoder erroneously depends on endian-ness
boolean PCMIsBigEndian;
// determine whether we are encoding or decoding
if (AudioFormat.Encoding.ALAW.equals(inputFormat.getEncoding())) {
encode = false;
encodeFormat = inputFormat;
decodeFormat = outputFormat;
PCMIsBigEndian = outputFormat.isBigEndian();
} else {
encode = true;
encodeFormat = outputFormat;
decodeFormat = inputFormat;
PCMIsBigEndian = inputFormat.isBigEndian();
tempBuffer = new byte[tempBufferSize];
}
if (PCMIsBigEndian) {
tabByte1 = ALAW_TABH;
tabByte2 = ALAW_TABL;
highByte = 0;
lowByte = 1;
} else {
tabByte1 = ALAW_TABL;
tabByte2 = ALAW_TABH;
highByte = 1;
lowByte = 0;
}
// set the AudioInputStream length in frames if we know it
if (stream instanceof AudioInputStream) {
frameLength = ((AudioInputStream)stream).getFrameLength();
}
// set framePos to zero
framePos = 0;
frameSize = inputFormat.getFrameSize();
if( frameSize==AudioSystem.NOT_SPECIFIED ) {
frameSize=1;
}
}
示例5: open
import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
public void open(AudioFormat format, byte[] data, int offset, int bufferSize)
throws LineUnavailableException {
synchronized (control_mutex) {
if (isOpen()) {
throw new IllegalStateException(
"Clip is already open with format " + getFormat()
+ " and frame lengh of " + getFrameLength());
}
if (AudioFloatConverter.getConverter(format) == null)
throw new IllegalArgumentException("Invalid format : "
+ format.toString());
if (bufferSize % format.getFrameSize() != 0)
throw new IllegalArgumentException(
"Buffer size does not represent an integral number of sample frames!");
if (data != null) {
this.data = Arrays.copyOf(data, data.length);
}
this.offset = offset;
this.bufferSize = bufferSize;
this.format = format;
this.framesize = format.getFrameSize();
loopstart = 0;
loopend = -1;
loop_sg = true;
if (!mixer.isOpen()) {
mixer.open();
mixer.implicitOpen = true;
}
outputformat = mixer.getFormat();
out_nrofchannels = outputformat.getChannels();
in_nrofchannels = format.getChannels();
open = true;
mixer.getMainMixer().openLine(this);
}
}
示例6: UlawCodecStream
import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
UlawCodecStream(AudioInputStream stream, AudioFormat outputFormat) {
super(stream, outputFormat, AudioSystem.NOT_SPECIFIED);
AudioFormat inputFormat = stream.getFormat();
// throw an IllegalArgumentException if not ok
if (!(isConversionSupported(outputFormat, inputFormat))) {
throw new IllegalArgumentException("Unsupported conversion: " + inputFormat.toString() + " to " + outputFormat.toString());
}
//$$fb 2002-07-18: fix for 4714846: JavaSound ULAW (8-bit) encoder erroneously depends on endian-ness
boolean PCMIsBigEndian;
// determine whether we are encoding or decoding
if (AudioFormat.Encoding.ULAW.equals(inputFormat.getEncoding())) {
encode = false;
encodeFormat = inputFormat;
decodeFormat = outputFormat;
PCMIsBigEndian = outputFormat.isBigEndian();
} else {
encode = true;
encodeFormat = outputFormat;
decodeFormat = inputFormat;
PCMIsBigEndian = inputFormat.isBigEndian();
tempBuffer = new byte[tempBufferSize];
}
// setup tables according to byte order
if (PCMIsBigEndian) {
tabByte1 = ULAW_TABH;
tabByte2 = ULAW_TABL;
highByte = 0;
lowByte = 1;
} else {
tabByte1 = ULAW_TABL;
tabByte2 = ULAW_TABH;
highByte = 1;
lowByte = 0;
}
// set the AudioInputStream length in frames if we know it
if (stream instanceof AudioInputStream) {
frameLength = ((AudioInputStream)stream).getFrameLength();
}
// set framePos to zero
framePos = 0;
frameSize = inputFormat.getFrameSize();
if (frameSize == AudioSystem.NOT_SPECIFIED) {
frameSize = 1;
}
}
示例7: AlawCodecStream
import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
AlawCodecStream(AudioInputStream stream, AudioFormat outputFormat) {
super(stream, outputFormat, -1);
AudioFormat inputFormat = stream.getFormat();
// throw an IllegalArgumentException if not ok
if ( ! (isConversionSupported(outputFormat, inputFormat)) ) {
throw new IllegalArgumentException("Unsupported conversion: " + inputFormat.toString() + " to " + outputFormat.toString());
}
//$$fb 2002-07-18: fix for 4714846: JavaSound ULAW (8-bit) encoder erroneously depends on endian-ness
boolean PCMIsBigEndian;
// determine whether we are encoding or decoding
if (AudioFormat.Encoding.ALAW.equals(inputFormat.getEncoding())) {
encode = false;
encodeFormat = inputFormat;
decodeFormat = outputFormat;
PCMIsBigEndian = outputFormat.isBigEndian();
} else {
encode = true;
encodeFormat = outputFormat;
decodeFormat = inputFormat;
PCMIsBigEndian = inputFormat.isBigEndian();
tempBuffer = new byte[tempBufferSize];
}
if (PCMIsBigEndian) {
tabByte1 = ALAW_TABH;
tabByte2 = ALAW_TABL;
highByte = 0;
lowByte = 1;
} else {
tabByte1 = ALAW_TABL;
tabByte2 = ALAW_TABH;
highByte = 1;
lowByte = 0;
}
// set the AudioInputStream length in frames if we know it
if (stream instanceof AudioInputStream) {
frameLength = stream.getFrameLength();
}
// set framePos to zero
framePos = 0;
frameSize = inputFormat.getFrameSize();
if( frameSize==AudioSystem.NOT_SPECIFIED ) {
frameSize=1;
}
}
示例8: open
import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
@Override
public void open(AudioFormat format, byte[] data, int offset, int bufferSize)
throws LineUnavailableException {
synchronized (control_mutex) {
if (isOpen()) {
throw new IllegalStateException(
"Clip is already open with format " + getFormat()
+ " and frame lengh of " + getFrameLength());
}
if (AudioFloatConverter.getConverter(format) == null)
throw new IllegalArgumentException("Invalid format : "
+ format.toString());
Toolkit.validateBuffer(format.getFrameSize(), bufferSize);
if (data != null) {
this.data = Arrays.copyOf(data, data.length);
}
this.offset = offset;
this.bufferSize = bufferSize;
this.format = format;
this.framesize = format.getFrameSize();
loopstart = 0;
loopend = -1;
loop_sg = true;
if (!mixer.isOpen()) {
mixer.open();
mixer.implicitOpen = true;
}
outputformat = mixer.getFormat();
out_nrofchannels = outputformat.getChannels();
in_nrofchannels = format.getChannels();
open = true;
mixer.getMainMixer().openLine(this);
}
}
示例9: UlawCodecStream
import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
UlawCodecStream(AudioInputStream stream, AudioFormat outputFormat) {
super(stream, outputFormat, AudioSystem.NOT_SPECIFIED);
AudioFormat inputFormat = stream.getFormat();
// throw an IllegalArgumentException if not ok
if (!(isConversionSupported(outputFormat, inputFormat))) {
throw new IllegalArgumentException("Unsupported conversion: " + inputFormat.toString() + " to " + outputFormat.toString());
}
//$$fb 2002-07-18: fix for 4714846: JavaSound ULAW (8-bit) encoder erroneously depends on endian-ness
boolean PCMIsBigEndian;
// determine whether we are encoding or decoding
if (AudioFormat.Encoding.ULAW.equals(inputFormat.getEncoding())) {
encode = false;
encodeFormat = inputFormat;
decodeFormat = outputFormat;
PCMIsBigEndian = outputFormat.isBigEndian();
} else {
encode = true;
encodeFormat = outputFormat;
decodeFormat = inputFormat;
PCMIsBigEndian = inputFormat.isBigEndian();
tempBuffer = new byte[tempBufferSize];
}
// setup tables according to byte order
if (PCMIsBigEndian) {
tabByte1 = ULAW_TABH;
tabByte2 = ULAW_TABL;
highByte = 0;
lowByte = 1;
} else {
tabByte1 = ULAW_TABL;
tabByte2 = ULAW_TABH;
highByte = 1;
lowByte = 0;
}
// set the AudioInputStream length in frames if we know it
if (stream instanceof AudioInputStream) {
frameLength = stream.getFrameLength();
}
// set framePos to zero
framePos = 0;
frameSize = inputFormat.getFrameSize();
if (frameSize == AudioSystem.NOT_SPECIFIED) {
frameSize = 1;
}
}
示例10: printFormat
import javax.sound.sampled.AudioFormat; //导入方法依赖的package包/类
public static String printFormat(AudioFormat format) {
return format.toString()+" "+(format.isBigEndian()?"big":"little")+" endian";
}