本文整理汇总了Java中javax.sound.sampled.AudioFileFormat.Type方法的典型用法代码示例。如果您正苦于以下问题:Java AudioFileFormat.Type方法的具体用法?Java AudioFileFormat.Type怎么用?Java AudioFileFormat.Type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.sound.sampled.AudioFileFormat
的用法示例。
在下文中一共展示了AudioFileFormat.Type方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: WaveFileFormat
import javax.sound.sampled.AudioFileFormat; //导入方法依赖的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.AudioFileFormat; //导入方法依赖的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: write
import javax.sound.sampled.AudioFileFormat; //导入方法依赖的package包/类
@Override
public int write(AudioInputStream stream, AudioFileFormat.Type fileType, OutputStream out) throws IOException {
Objects.requireNonNull(stream);
Objects.requireNonNull(fileType);
Objects.requireNonNull(out);
//$$fb the following check must come first ! Otherwise
// the next frame length check may throw an IOException and
// interrupt iterating File Writers. (see bug 4351296)
// throws IllegalArgumentException if not supported
AiffFileFormat aiffFileFormat = (AiffFileFormat)getAudioFileFormat(fileType, stream);
// we must know the total data length to calculate the file length
if( stream.getFrameLength() == AudioSystem.NOT_SPECIFIED ) {
throw new IOException("stream length not specified");
}
return writeAiffFile(stream, aiffFileFormat, out);
}
示例4: getAudioFileTypes
import javax.sound.sampled.AudioFileFormat; //导入方法依赖的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: AuFileFormat
import javax.sound.sampled.AudioFileFormat; //导入方法依赖的package包/类
AuFileFormat(AudioFileFormat.Type type, int lengthInBytes, AudioFormat format, int lengthInFrames) {
super(type,lengthInBytes,format,lengthInFrames);
AudioFormat.Encoding encoding = format.getEncoding();
auType = -1;
if( AudioFormat.Encoding.ALAW.equals(encoding) ) {
if( format.getSampleSizeInBits()==8 ) {
auType = AU_ALAW_8;
}
} else if( AudioFormat.Encoding.ULAW.equals(encoding) ) {
if( format.getSampleSizeInBits()==8 ) {
auType = AU_ULAW_8;
}
} else if( AudioFormat.Encoding.PCM_SIGNED.equals(encoding) ) {
if( format.getSampleSizeInBits()==8 ) {
auType = AU_LINEAR_8;
} else if( format.getSampleSizeInBits()==16 ) {
auType = AU_LINEAR_16;
} else if( format.getSampleSizeInBits()==24 ) {
auType = AU_LINEAR_24;
} else if( format.getSampleSizeInBits()==32 ) {
auType = AU_LINEAR_32;
}
}
}
示例6: JSStreamingSampleRecorder
import javax.sound.sampled.AudioFileFormat; //导入方法依赖的package包/类
/**
*
* @param fileName
* @param fileType
* @param fileFormat
*/
JSStreamingSampleRecorder(JSMinim sys,
String fileName,
AudioFileFormat.Type fileType,
AudioFormat fileFormat,
int bufferSize)
{
name = fileName;
type = fileType;
format = fileFormat;
system = sys;
try
{
aos = AudioSystemShadow.getAudioOutputStream( type, format,
AudioSystem.NOT_SPECIFIED,
new File(name) );
}
catch (IOException e)
{
system.error("Error obtaining new output stream: " + e.getMessage());
}
catch (IllegalArgumentException badarg)
{
system.error("Error obtaining new output stream for " + fileName + " with type "
+ type.toString() + " format " + format.toString()
+ " and bufferSize " + bufferSize + ".\n"
+ "The reason is " + badarg.getMessage());
}
fsb = new FloatSampleBuffer(format.getChannels(),
bufferSize,
format.getSampleRate());
recording = false;
}
示例7: isFileTypeSupported
import javax.sound.sampled.AudioFileFormat; //导入方法依赖的package包/类
/**
* Indicates whether file writing support for the specified file type is provided
* by this audio file writer.
* @param fileType the file type for which write capabilities are queried
* @return <code>true</code> if the file type is supported,
* otherwise <code>false</code>
*/
public boolean isFileTypeSupported(AudioFileFormat.Type fileType) {
AudioFileFormat.Type types[] = getAudioFileTypes();
for(int i=0; i<types.length; i++) {
if( fileType.equals( types[i] ) ) {
return true;
}
}
return false;
}
示例8: write
import javax.sound.sampled.AudioFileFormat; //导入方法依赖的package包/类
public int write(AudioInputStream stream, AudioFileFormat.Type fileType, OutputStream out) throws IOException {
// we must know the total data length to calculate the file length
//$$fb 2001-07-13: fix for bug 4351296: do not throw an exception
//if( stream.getFrameLength() == AudioSystem.NOT_SPECIFIED ) {
// throw new IOException("stream length not specified");
//}
// throws IllegalArgumentException if not supported
AuFileFormat auFileFormat = (AuFileFormat)getAudioFileFormat(fileType, stream);
int bytesWritten = writeAuFile(stream, auFileFormat, out);
return bytesWritten;
}
示例9: write
import javax.sound.sampled.AudioFileFormat; //导入方法依赖的package包/类
public int write(AudioInputStream stream, AudioFileFormat.Type fileType, File out) throws IOException {
// throws IllegalArgumentException if not supported
WaveFileFormat waveFileFormat = (WaveFileFormat)getAudioFileFormat(fileType, stream);
// first write the file without worrying about length fields
FileOutputStream fos = new FileOutputStream( out ); // throws IOException
BufferedOutputStream bos = new BufferedOutputStream( fos, bisBufferSize );
int bytesWritten = writeWaveFile(stream, waveFileFormat, bos );
bos.close();
// now, if length fields were not specified, calculate them,
// open as a random access file, write the appropriate fields,
// close again....
if( waveFileFormat.getByteLength()== AudioSystem.NOT_SPECIFIED ) {
int dataLength=bytesWritten-waveFileFormat.getHeaderSize();
int riffLength=dataLength + waveFileFormat.getHeaderSize() - 8;
RandomAccessFile raf=new RandomAccessFile(out, "rw");
// skip RIFF magic
raf.skipBytes(4);
raf.writeInt(big2little( riffLength ));
// skip WAVE magic, fmt_ magic, fmt_ length, fmt_ chunk, data magic
raf.skipBytes(4+4+4+WaveFileFormat.getFmtChunkSize(waveFileFormat.getWaveType())+4);
raf.writeInt(big2little( dataLength ));
// that's all
raf.close();
}
return bytesWritten;
}
示例10: SunFileWriter
import javax.sound.sampled.AudioFileFormat; //导入方法依赖的package包/类
/**
* Constructs a new SunParser object.
*/
SunFileWriter(AudioFileFormat.Type types[]) {
this.types = types;
}
示例11: test
import javax.sound.sampled.AudioFileFormat; //导入方法依赖的package包/类
static void test(AudioFileFormat.Type fileType, int length) {
test(fileType, length, false);
test(fileType, length, true);
}
示例12: WaveFileWriter
import javax.sound.sampled.AudioFileFormat; //导入方法依赖的package包/类
/**
* Constructs a new WaveFileWriter object.
*/
public WaveFileWriter() {
super(new AudioFileFormat.Type[]{AudioFileFormat.Type.WAVE});
}
示例13: AiffFileWriter
import javax.sound.sampled.AudioFileFormat; //导入方法依赖的package包/类
/**
* Constructs a new AiffFileWriter object.
*/
public AiffFileWriter() {
super(new AudioFileFormat.Type[]{AudioFileFormat.Type.AIFF});
}
示例14: AuFileWriter
import javax.sound.sampled.AudioFileFormat; //导入方法依赖的package包/类
/**
* Constructs a new AuFileWriter object.
*/
public AuFileWriter() {
super(new AudioFileFormat.Type[]{AudioFileFormat.Type.AU});
}
示例15: getAudioFileTypes
import javax.sound.sampled.AudioFileFormat; //导入方法依赖的package包/类
@Override
public final AudioFileFormat.Type[] getAudioFileTypes(){
AudioFileFormat.Type[] localArray = new AudioFileFormat.Type[types.length];
System.arraycopy(types, 0, localArray, 0, types.length);
return localArray;
}