本文整理匯總了Java中javax.sound.sampled.AudioFormat.Encoding.PCM_FLOAT屬性的典型用法代碼示例。如果您正苦於以下問題:Java Encoding.PCM_FLOAT屬性的具體用法?Java Encoding.PCM_FLOAT怎麽用?Java Encoding.PCM_FLOAT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類javax.sound.sampled.AudioFormat.Encoding
的用法示例。
在下文中一共展示了Encoding.PCM_FLOAT屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
public static void main(String[] args) throws Exception {
// 1st checks Encoding.PCM_FLOAT is available
pcmFloatEnc = Encoding.PCM_FLOAT;
Encoding[] encodings = AudioSystem.getTargetEncodings(pcmFloatEnc);
out("conversion from PCM_FLOAT to " + encodings.length + " encodings:");
for (Encoding e: encodings) {
out(" - " + e);
}
if (encodings.length == 0) {
testFailed = true;
}
test(Encoding.PCM_SIGNED);
test(Encoding.PCM_UNSIGNED);
if (testFailed) {
throw new Exception("test failed");
}
out("test passed.");
}
示例2: getTargetEncodings
@Override
public Encoding[] getTargetEncodings(AudioFormat sourceFormat) {
if (AudioFloatConverter.getConverter(sourceFormat) == null)
return new Encoding[0];
return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED,
Encoding.PCM_FLOAT };
}
示例3: getSourceEncodings
public Encoding[] getSourceEncodings() {
return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED,
Encoding.PCM_FLOAT };
}
示例4: getTargetEncodings
public Encoding[] getTargetEncodings() {
return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED,
Encoding.PCM_FLOAT };
}
示例5: internal_getAudioFileFormat
private AudioFileFormat internal_getAudioFileFormat(InputStream stream)
throws UnsupportedAudioFileException, IOException {
RIFFReader riffiterator = new RIFFReader(stream);
if (!riffiterator.getFormat().equals("RIFF"))
throw new UnsupportedAudioFileException();
if (!riffiterator.getType().equals("WAVE"))
throw new UnsupportedAudioFileException();
boolean fmt_found = false;
boolean data_found = false;
int channels = 1;
long samplerate = 1;
int framesize = 1;
int bits = 1;
while (riffiterator.hasNextChunk()) {
RIFFReader chunk = riffiterator.nextChunk();
if (chunk.getFormat().equals("fmt ")) {
fmt_found = true;
int format = chunk.readUnsignedShort();
if (format != 3) // WAVE_FORMAT_IEEE_FLOAT only
throw new UnsupportedAudioFileException();
channels = chunk.readUnsignedShort();
samplerate = chunk.readUnsignedInt();
/* framerate = */chunk.readUnsignedInt();
framesize = chunk.readUnsignedShort();
bits = chunk.readUnsignedShort();
}
if (chunk.getFormat().equals("data")) {
data_found = true;
break;
}
}
if (!fmt_found)
throw new UnsupportedAudioFileException();
if (!data_found)
throw new UnsupportedAudioFileException();
AudioFormat audioformat = new AudioFormat(
Encoding.PCM_FLOAT, samplerate, bits, channels,
framesize, samplerate, false);
AudioFileFormat fileformat = new AudioFileFormat(
AudioFileFormat.Type.WAVE, audioformat,
AudioSystem.NOT_SPECIFIED);
return fileformat;
}
示例6: getSourceEncodings
@Override
public Encoding[] getSourceEncodings() {
return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED,
Encoding.PCM_FLOAT };
}
示例7: getAudioFileFormatImpl
@Override
StandardFileFormat getAudioFileFormatImpl(final InputStream stream)
throws UnsupportedAudioFileException, IOException {
RIFFReader riffiterator = new RIFFReader(stream);
if (!riffiterator.getFormat().equals("RIFF"))
throw new UnsupportedAudioFileException();
if (!riffiterator.getType().equals("WAVE"))
throw new UnsupportedAudioFileException();
boolean fmt_found = false;
boolean data_found = false;
int channels = 1;
long samplerate = 1;
int framesize = 1;
int bits = 1;
long dataSize = 0;
while (riffiterator.hasNextChunk()) {
RIFFReader chunk = riffiterator.nextChunk();
if (chunk.getFormat().equals("fmt ")) {
fmt_found = true;
int format = chunk.readUnsignedShort();
if (format != WaveFileFormat.WAVE_FORMAT_IEEE_FLOAT) {
throw new UnsupportedAudioFileException();
}
channels = chunk.readUnsignedShort();
samplerate = chunk.readUnsignedInt();
/* framerate = */chunk.readUnsignedInt();
framesize = chunk.readUnsignedShort();
bits = chunk.readUnsignedShort();
}
if (chunk.getFormat().equals("data")) {
dataSize = chunk.getSize();
data_found = true;
break;
}
}
if (!fmt_found || !data_found) {
throw new UnsupportedAudioFileException();
}
AudioFormat audioformat = new AudioFormat(
Encoding.PCM_FLOAT, samplerate, bits, channels,
framesize, samplerate, false);
return new StandardFileFormat(AudioFileFormat.Type.WAVE, audioformat,
dataSize / audioformat.getFrameSize());
}
示例8: getTargetEncodings
public Encoding[] getTargetEncodings(AudioFormat sourceFormat) {
if (AudioFloatConverter.getConverter(sourceFormat) == null)
return new Encoding[0];
return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED,
Encoding.PCM_FLOAT };
}