本文整理匯總了Java中javax.sound.sampled.AudioFormat.Encoding.equals方法的典型用法代碼示例。如果您正苦於以下問題:Java Encoding.equals方法的具體用法?Java Encoding.equals怎麽用?Java Encoding.equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.sound.sampled.AudioFormat.Encoding
的用法示例。
在下文中一共展示了Encoding.equals方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getAudioInputStream
import javax.sound.sampled.AudioFormat.Encoding; //導入方法依賴的package包/類
public AudioInputStream getAudioInputStream(Encoding targetEncoding,
AudioInputStream sourceStream) {
if (sourceStream.getFormat().getEncoding().equals(targetEncoding))
return sourceStream;
AudioFormat format = sourceStream.getFormat();
int channels = format.getChannels();
Encoding encoding = targetEncoding;
float samplerate = format.getSampleRate();
int bits = format.getSampleSizeInBits();
boolean bigendian = format.isBigEndian();
if (targetEncoding.equals(Encoding.PCM_FLOAT))
bits = 32;
AudioFormat targetFormat = new AudioFormat(encoding, samplerate, bits,
channels, channels * bits / 8, samplerate, bigendian);
return getAudioInputStream(targetFormat, sourceStream);
}
示例2: getAudioInputStream
import javax.sound.sampled.AudioFormat.Encoding; //導入方法依賴的package包/類
@Override
public AudioInputStream getAudioInputStream(Encoding targetEncoding,
AudioInputStream sourceStream) {
if (!isConversionSupported(targetEncoding, sourceStream.getFormat())) {
throw new IllegalArgumentException(
"Unsupported conversion: " + sourceStream.getFormat()
.toString() + " to " + targetEncoding.toString());
}
if (sourceStream.getFormat().getEncoding().equals(targetEncoding))
return sourceStream;
AudioFormat format = sourceStream.getFormat();
int channels = format.getChannels();
Encoding encoding = targetEncoding;
float samplerate = format.getSampleRate();
int bits = format.getSampleSizeInBits();
boolean bigendian = format.isBigEndian();
if (targetEncoding.equals(Encoding.PCM_FLOAT))
bits = 32;
AudioFormat targetFormat = new AudioFormat(encoding, samplerate, bits,
channels, channels * bits / 8, samplerate, bigendian);
return getAudioInputStream(targetFormat, sourceStream);
}
示例3: getAudioInputStream
import javax.sound.sampled.AudioFormat.Encoding; //導入方法依賴的package包/類
public AudioInputStream getAudioInputStream(Encoding targetEncoding,
AudioInputStream sourceStream) {
if (!isConversionSupported(targetEncoding, sourceStream.getFormat())) {
throw new IllegalArgumentException(
"Unsupported conversion: " + sourceStream.getFormat()
.toString() + " to " + targetEncoding.toString());
}
if (sourceStream.getFormat().getEncoding().equals(targetEncoding))
return sourceStream;
AudioFormat format = sourceStream.getFormat();
int channels = format.getChannels();
Encoding encoding = targetEncoding;
float samplerate = format.getSampleRate();
int bits = format.getSampleSizeInBits();
boolean bigendian = format.isBigEndian();
if (targetEncoding.equals(Encoding.PCM_FLOAT))
bits = 32;
AudioFormat targetFormat = new AudioFormat(encoding, samplerate, bits,
channels, channels * bits / 8, samplerate, bigendian);
return getAudioInputStream(targetFormat, sourceStream);
}
示例4: getAudioInputStream
import javax.sound.sampled.AudioFormat.Encoding; //導入方法依賴的package包/類
public AudioInputStream getAudioInputStream(Encoding targetEncoding,
AudioInputStream sourceStream) {
if (sourceStream.getFormat().getEncoding().equals(targetEncoding))
return sourceStream;
AudioFormat format = sourceStream.getFormat();
int channels = format.getChannels();
Encoding encoding = targetEncoding;
float samplerate = format.getSampleRate();
int bits = format.getSampleSizeInBits();
boolean bigendian = format.isBigEndian();
if (targetEncoding.equals(AudioFloatConverter.PCM_FLOAT))
bits = 32;
AudioFormat targetFormat = new AudioFormat(encoding, samplerate, bits,
channels, channels * bits / 8, samplerate, bigendian);
return getAudioInputStream(targetFormat, sourceStream);
}
示例5: isConversionSupported
import javax.sound.sampled.AudioFormat.Encoding; //導入方法依賴的package包/類
public boolean isConversionSupported(Encoding targetEncoding,
AudioFormat sourceFormat) {
if (AudioFloatConverter.getConverter(sourceFormat) == null)
return false;
for (int i = 0; i < formats.length; i++) {
if (targetEncoding.equals(formats[i]))
return true;
}
return false;
}
示例6: test
import javax.sound.sampled.AudioFormat.Encoding; //導入方法依賴的package包/類
static boolean test(Encoding enc) {
out("conversion " + enc + " -> PCM_FLOAT:");
Encoding[] encodings = AudioSystem.getTargetEncodings(enc);
for (Encoding e: encodings) {
if (e.equals(pcmFloatEnc)) {
out(" - OK");
return true;
}
}
out(" - FAILED (not supported)");
testFailed = true;
return false;
}
示例7: isConversionSupported
import javax.sound.sampled.AudioFormat.Encoding; //導入方法依賴的package包/類
@Override
public boolean isConversionSupported(Encoding targetEncoding,
AudioFormat sourceFormat) {
Objects.requireNonNull(targetEncoding);
if (AudioFloatConverter.getConverter(sourceFormat) == null)
return false;
for (int i = 0; i < formats.length; i++) {
if (targetEncoding.equals(formats[i]))
return true;
}
return false;
}
示例8: isConversionSupported
import javax.sound.sampled.AudioFormat.Encoding; //導入方法依賴的package包/類
public boolean isConversionSupported(Encoding targetEncoding,
AudioFormat sourceFormat) {
Objects.requireNonNull(targetEncoding);
if (AudioFloatConverter.getConverter(sourceFormat) == null)
return false;
for (int i = 0; i < formats.length; i++) {
if (targetEncoding.equals(formats[i]))
return true;
}
return false;
}
示例9: getTargetFormats
import javax.sound.sampled.AudioFormat.Encoding; //導入方法依賴的package包/類
public AudioFormat[] getTargetFormats(Encoding targetEncoding,
AudioFormat sourceFormat) {
if (AudioFloatConverter.getConverter(sourceFormat) == null)
return new AudioFormat[0];
int channels = sourceFormat.getChannels();
ArrayList<AudioFormat> formats = new ArrayList<AudioFormat>();
if (targetEncoding.equals(Encoding.PCM_SIGNED))
formats.add(new AudioFormat(Encoding.PCM_SIGNED,
AudioSystem.NOT_SPECIFIED, 8, channels, channels,
AudioSystem.NOT_SPECIFIED, false));
if (targetEncoding.equals(Encoding.PCM_UNSIGNED))
formats.add(new AudioFormat(Encoding.PCM_UNSIGNED,
AudioSystem.NOT_SPECIFIED, 8, channels, channels,
AudioSystem.NOT_SPECIFIED, false));
for (int bits = 16; bits < 32; bits += 8) {
if (targetEncoding.equals(Encoding.PCM_SIGNED)) {
formats.add(new AudioFormat(Encoding.PCM_SIGNED,
AudioSystem.NOT_SPECIFIED, bits, channels, channels
* bits / 8, AudioSystem.NOT_SPECIFIED, false));
formats.add(new AudioFormat(Encoding.PCM_SIGNED,
AudioSystem.NOT_SPECIFIED, bits, channels, channels
* bits / 8, AudioSystem.NOT_SPECIFIED, true));
}
if (targetEncoding.equals(Encoding.PCM_UNSIGNED)) {
formats.add(new AudioFormat(Encoding.PCM_UNSIGNED,
AudioSystem.NOT_SPECIFIED, bits, channels, channels
* bits / 8, AudioSystem.NOT_SPECIFIED, true));
formats.add(new AudioFormat(Encoding.PCM_UNSIGNED,
AudioSystem.NOT_SPECIFIED, bits, channels, channels
* bits / 8, AudioSystem.NOT_SPECIFIED, false));
}
}
if (targetEncoding.equals(Encoding.PCM_FLOAT)) {
formats.add(new AudioFormat(Encoding.PCM_FLOAT,
AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4,
AudioSystem.NOT_SPECIFIED, false));
formats.add(new AudioFormat(Encoding.PCM_FLOAT,
AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4,
AudioSystem.NOT_SPECIFIED, true));
formats.add(new AudioFormat(Encoding.PCM_FLOAT,
AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8,
AudioSystem.NOT_SPECIFIED, false));
formats.add(new AudioFormat(Encoding.PCM_FLOAT,
AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8,
AudioSystem.NOT_SPECIFIED, true));
}
return formats.toArray(new AudioFormat[formats.size()]);
}
示例10: getTargetFormats
import javax.sound.sampled.AudioFormat.Encoding; //導入方法依賴的package包/類
@Override
public AudioFormat[] getTargetFormats(Encoding targetEncoding,
AudioFormat sourceFormat) {
Objects.requireNonNull(targetEncoding);
if (AudioFloatConverter.getConverter(sourceFormat) == null)
return new AudioFormat[0];
int channels = sourceFormat.getChannels();
ArrayList<AudioFormat> formats = new ArrayList<>();
if (targetEncoding.equals(Encoding.PCM_SIGNED))
formats.add(new AudioFormat(Encoding.PCM_SIGNED,
AudioSystem.NOT_SPECIFIED, 8, channels, channels,
AudioSystem.NOT_SPECIFIED, false));
if (targetEncoding.equals(Encoding.PCM_UNSIGNED))
formats.add(new AudioFormat(Encoding.PCM_UNSIGNED,
AudioSystem.NOT_SPECIFIED, 8, channels, channels,
AudioSystem.NOT_SPECIFIED, false));
for (int bits = 16; bits < 32; bits += 8) {
if (targetEncoding.equals(Encoding.PCM_SIGNED)) {
formats.add(new AudioFormat(Encoding.PCM_SIGNED,
AudioSystem.NOT_SPECIFIED, bits, channels, channels
* bits / 8, AudioSystem.NOT_SPECIFIED, false));
formats.add(new AudioFormat(Encoding.PCM_SIGNED,
AudioSystem.NOT_SPECIFIED, bits, channels, channels
* bits / 8, AudioSystem.NOT_SPECIFIED, true));
}
if (targetEncoding.equals(Encoding.PCM_UNSIGNED)) {
formats.add(new AudioFormat(Encoding.PCM_UNSIGNED,
AudioSystem.NOT_SPECIFIED, bits, channels, channels
* bits / 8, AudioSystem.NOT_SPECIFIED, true));
formats.add(new AudioFormat(Encoding.PCM_UNSIGNED,
AudioSystem.NOT_SPECIFIED, bits, channels, channels
* bits / 8, AudioSystem.NOT_SPECIFIED, false));
}
}
if (targetEncoding.equals(Encoding.PCM_FLOAT)) {
formats.add(new AudioFormat(Encoding.PCM_FLOAT,
AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4,
AudioSystem.NOT_SPECIFIED, false));
formats.add(new AudioFormat(Encoding.PCM_FLOAT,
AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4,
AudioSystem.NOT_SPECIFIED, true));
formats.add(new AudioFormat(Encoding.PCM_FLOAT,
AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8,
AudioSystem.NOT_SPECIFIED, false));
formats.add(new AudioFormat(Encoding.PCM_FLOAT,
AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8,
AudioSystem.NOT_SPECIFIED, true));
}
return formats.toArray(new AudioFormat[formats.size()]);
}
示例11: getTargetFormats
import javax.sound.sampled.AudioFormat.Encoding; //導入方法依賴的package包/類
public AudioFormat[] getTargetFormats(Encoding targetEncoding,
AudioFormat sourceFormat) {
Objects.requireNonNull(targetEncoding);
if (AudioFloatConverter.getConverter(sourceFormat) == null)
return new AudioFormat[0];
int channels = sourceFormat.getChannels();
ArrayList<AudioFormat> formats = new ArrayList<AudioFormat>();
if (targetEncoding.equals(Encoding.PCM_SIGNED))
formats.add(new AudioFormat(Encoding.PCM_SIGNED,
AudioSystem.NOT_SPECIFIED, 8, channels, channels,
AudioSystem.NOT_SPECIFIED, false));
if (targetEncoding.equals(Encoding.PCM_UNSIGNED))
formats.add(new AudioFormat(Encoding.PCM_UNSIGNED,
AudioSystem.NOT_SPECIFIED, 8, channels, channels,
AudioSystem.NOT_SPECIFIED, false));
for (int bits = 16; bits < 32; bits += 8) {
if (targetEncoding.equals(Encoding.PCM_SIGNED)) {
formats.add(new AudioFormat(Encoding.PCM_SIGNED,
AudioSystem.NOT_SPECIFIED, bits, channels, channels
* bits / 8, AudioSystem.NOT_SPECIFIED, false));
formats.add(new AudioFormat(Encoding.PCM_SIGNED,
AudioSystem.NOT_SPECIFIED, bits, channels, channels
* bits / 8, AudioSystem.NOT_SPECIFIED, true));
}
if (targetEncoding.equals(Encoding.PCM_UNSIGNED)) {
formats.add(new AudioFormat(Encoding.PCM_UNSIGNED,
AudioSystem.NOT_SPECIFIED, bits, channels, channels
* bits / 8, AudioSystem.NOT_SPECIFIED, true));
formats.add(new AudioFormat(Encoding.PCM_UNSIGNED,
AudioSystem.NOT_SPECIFIED, bits, channels, channels
* bits / 8, AudioSystem.NOT_SPECIFIED, false));
}
}
if (targetEncoding.equals(Encoding.PCM_FLOAT)) {
formats.add(new AudioFormat(Encoding.PCM_FLOAT,
AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4,
AudioSystem.NOT_SPECIFIED, false));
formats.add(new AudioFormat(Encoding.PCM_FLOAT,
AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4,
AudioSystem.NOT_SPECIFIED, true));
formats.add(new AudioFormat(Encoding.PCM_FLOAT,
AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8,
AudioSystem.NOT_SPECIFIED, false));
formats.add(new AudioFormat(Encoding.PCM_FLOAT,
AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8,
AudioSystem.NOT_SPECIFIED, true));
}
return formats.toArray(new AudioFormat[formats.size()]);
}
示例12: getTargetFormats
import javax.sound.sampled.AudioFormat.Encoding; //導入方法依賴的package包/類
public AudioFormat[] getTargetFormats(Encoding targetEncoding,
AudioFormat sourceFormat) {
if (AudioFloatConverter.getConverter(sourceFormat) == null)
return new AudioFormat[0];
int channels = sourceFormat.getChannels();
ArrayList<AudioFormat> formats = new ArrayList<AudioFormat>();
if (targetEncoding.equals(Encoding.PCM_SIGNED))
formats.add(new AudioFormat(Encoding.PCM_SIGNED,
AudioSystem.NOT_SPECIFIED, 8, channels, channels,
AudioSystem.NOT_SPECIFIED, false));
if (targetEncoding.equals(Encoding.PCM_UNSIGNED))
formats.add(new AudioFormat(Encoding.PCM_UNSIGNED,
AudioSystem.NOT_SPECIFIED, 8, channels, channels,
AudioSystem.NOT_SPECIFIED, false));
for (int bits = 16; bits < 32; bits += 8) {
if (targetEncoding.equals(Encoding.PCM_SIGNED)) {
formats.add(new AudioFormat(Encoding.PCM_SIGNED,
AudioSystem.NOT_SPECIFIED, bits, channels, channels
* bits / 8, AudioSystem.NOT_SPECIFIED, false));
formats.add(new AudioFormat(Encoding.PCM_SIGNED,
AudioSystem.NOT_SPECIFIED, bits, channels, channels
* bits / 8, AudioSystem.NOT_SPECIFIED, true));
}
if (targetEncoding.equals(Encoding.PCM_UNSIGNED)) {
formats.add(new AudioFormat(Encoding.PCM_UNSIGNED,
AudioSystem.NOT_SPECIFIED, bits, channels, channels
* bits / 8, AudioSystem.NOT_SPECIFIED, true));
formats.add(new AudioFormat(Encoding.PCM_UNSIGNED,
AudioSystem.NOT_SPECIFIED, bits, channels, channels
* bits / 8, AudioSystem.NOT_SPECIFIED, false));
}
}
if (targetEncoding.equals(AudioFloatConverter.PCM_FLOAT)) {
formats.add(new AudioFormat(AudioFloatConverter.PCM_FLOAT,
AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4,
AudioSystem.NOT_SPECIFIED, false));
formats.add(new AudioFormat(AudioFloatConverter.PCM_FLOAT,
AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4,
AudioSystem.NOT_SPECIFIED, true));
formats.add(new AudioFormat(AudioFloatConverter.PCM_FLOAT,
AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8,
AudioSystem.NOT_SPECIFIED, false));
formats.add(new AudioFormat(AudioFloatConverter.PCM_FLOAT,
AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8,
AudioSystem.NOT_SPECIFIED, true));
}
return formats.toArray(new AudioFormat[formats.size()]);
}