public AudioFileFormat getAudioFileFormat(Sequence seq)
throws UnsupportedAudioFileException, IOException {
long totallen = seq.getMicrosecondLength() / 1000000;
long len = (long) (format.getFrameRate() * (totallen + 4));
return new AudioFileFormat(MIDI, format, (int) len);
}
java类javax.sound.sampled.AudioFileFormat的实例源码
SoftMidiAudioFileReader.java 文件源码
项目:OpenJSharp
阅读 13
收藏 0
点赞 0
评论 0
AuFileWriter.java 文件源码
项目:OpenJSharp
阅读 17
收藏 0
点赞 0
评论 0
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;
}
AuFileFormat.java 文件源码
项目:openjdk-jdk10
阅读 14
收藏 0
点赞 0
评论 0
AuFileFormat(final AudioFileFormat.Type type, final long byteLength,
final AudioFormat format, final long frameLength) {
super(type, byteLength, format, frameLength);
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;
}
} else if (AudioFormat.Encoding.PCM_FLOAT.equals(encoding)) {
if (format.getSampleSizeInBits() == 32) {
auType = AU_FLOAT;
}
}
}
AuFileFormat.java 文件源码
项目:OpenJSharp
阅读 15
收藏 0
点赞 0
评论 0
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;
}
}
}
WaveFloatFileReader.java 文件源码
项目:OpenJSharp
阅读 24
收藏 0
点赞 0
评论 0
public AudioFileFormat getAudioFileFormat(URL url)
throws UnsupportedAudioFileException, IOException {
InputStream stream = url.openStream();
AudioFileFormat format;
try {
format = getAudioFileFormat(new BufferedInputStream(stream));
} finally {
stream.close();
}
return format;
}
WaveFloatFileReader.java 文件源码
项目:OpenJSharp
阅读 16
收藏 0
点赞 0
评论 0
public AudioFileFormat getAudioFileFormat(File file)
throws UnsupportedAudioFileException, IOException {
InputStream stream = new FileInputStream(file);
AudioFileFormat format;
try {
format = getAudioFileFormat(new BufferedInputStream(stream));
} finally {
stream.close();
}
return format;
}
WaveExtensibleFileReader.java 文件源码
项目:OpenJSharp
阅读 20
收藏 0
点赞 0
评论 0
public AudioFileFormat getAudioFileFormat(InputStream stream)
throws UnsupportedAudioFileException, IOException {
stream.mark(200);
AudioFileFormat format;
try {
format = internal_getAudioFileFormat(stream);
} finally {
stream.reset();
}
return format;
}
WaveExtensibleFileReader.java 文件源码
项目:OpenJSharp
阅读 17
收藏 0
点赞 0
评论 0
public AudioFileFormat getAudioFileFormat(File file)
throws UnsupportedAudioFileException, IOException {
InputStream stream = new FileInputStream(file);
AudioFileFormat format;
try {
format = getAudioFileFormat(new BufferedInputStream(stream));
} finally {
stream.close();
}
return format;
}
WriteAuUnspecifiedLength.java 文件源码
项目:openjdk-jdk10
阅读 16
收藏 0
点赞 0
评论 0
public static void main(String argv[]) throws Exception {
AudioFormat format = new AudioFormat(44100, 16, 2, true, true);
InputStream is = new ByteArrayInputStream(new byte[1000]);
AudioInputStream ais = new AudioInputStream(is, format, AudioSystem.NOT_SPECIFIED);
AudioSystem.write(ais, AudioFileFormat.Type.AU, new ByteArrayOutputStream());
System.out.println("Test passed.");
}
AuFileWriter.java 文件源码
项目:openjdk-jdk10
阅读 17
收藏 0
点赞 0
评论 0
/**
* Returns the AudioFileFormat describing the file that will be written from this AudioInputStream.
* Throws IllegalArgumentException if not supported.
*/
private AudioFileFormat getAudioFileFormat(Type type, AudioInputStream stream) {
if (!isFileTypeSupported(type, stream)) {
throw new IllegalArgumentException("File type " + type + " not supported.");
}
AudioFormat streamFormat = stream.getFormat();
AudioFormat.Encoding encoding = streamFormat.getEncoding();
if (AudioFormat.Encoding.PCM_UNSIGNED.equals(encoding)) {
encoding = AudioFormat.Encoding.PCM_SIGNED;
}
// We always write big endian au files, this is by far the standard
AudioFormat format = new AudioFormat(encoding,
streamFormat.getSampleRate(),
streamFormat.getSampleSizeInBits(),
streamFormat.getChannels(),
streamFormat.getFrameSize(),
streamFormat.getFrameRate(), true);
int fileSize;
if (stream.getFrameLength() != AudioSystem.NOT_SPECIFIED) {
fileSize = (int)stream.getFrameLength()*streamFormat.getFrameSize() + AuFileFormat.AU_HEADERSIZE;
} else {
fileSize = AudioSystem.NOT_SPECIFIED;
}
return new AuFileFormat(Type.AU, fileSize, format,
(int) stream.getFrameLength());
}