/******************************************************************************
* *
* Copyright (c) 1999-2004 Wimba S.A., All Rights Reserved. *
* *
* COPYRIGHT: *
* This software is the property of Wimba S.A. *
* This software is redistributed under the Xiph.org variant of *
* the BSD license. *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* - Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* - Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* - Neither the name of Wimba, the Xiph.org Foundation nor the names of *
* its contributors may be used to endorse or promote products derived *
* from this software without specific prior written permission. *
* *
* WARRANTIES: *
* This software is made available by the authors in the hope *
* that it will be useful, but without any warranty. *
* Wimba S.A. is not liable for any consequence related to the *
* use of the provided software. *
* *
* Class: RawWriter.java *
* *
* Author: Marc GIMPEL *
* *
* Date: 6th January 2004 *
* *
******************************************************************************/
/* $Id: AudioFileWriter.java,v 1.1 2011/12/27 04:39:13 gauss Exp $ */
package com.gauss.writer.speex;
import java.io.DataOutput;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
/**
* Abstract Class that defines an Audio File Writer.
*
* @author Marc Gimpel, Wimba S.A. (mgimpel@horizonwimba.com)
* @version $Revision: 1.1 $
*/
public abstract class AudioFileWriter
{
/**
* Closes the output file.
* @exception IOException if there was an exception closing the Audio Writer.
*/
public abstract void close()
throws IOException;
/**
* Open the output file.
* @param file - file to open.
* @exception IOException if there was an exception opening the Audio Writer.
*/
public abstract void open(File file)
throws IOException;
/**
* Open the output file.
* @param filename - file to open.
* @exception IOException if there was an exception opening the Audio Writer.
*/
public abstract void open(String filename)
throws IOException;
/**
* Writes the header pages that start the Ogg Speex file.
* Prepares file for data to be written.
* @param comment description to be included in the header.
* @exception IOException
*/
public abstract void writeHeader(String comment)
throws IOException;
/**
* Writes a packet of audio.
* @param data audio data
* @param offset the offset from which to start reading the data.
* @param len the length of data to read.
* @exception IOException
*/
public abstract void writePacket(byte[] data, int offset, int len)
throws IOException;
/**
* Writes an Ogg Page Header to the given byte array.
* @param buf the buffer to write to.
* @param offset the from which to start writing.
* @param headerType the header type flag
* (0=normal, 2=bos: beginning of stream, 4=eos: end of stream).
* @param granulepos the absolute granule position.
* @param streamSerialNumber
* @param pageCount
* @param packetCount
* @param packetSizes
* @return the amount of data written to the buffer.
*/
public static int writeOggPageHeader(byte[] buf, int offset, int headerType,
long granulepos, int streamSerialNumber,
int pageCount, int packetCount,
byte[] packetSizes)
{
writeString(buf, offset, "OggS"); // 0 - 3: capture_pattern
buf[offset+4] = 0; // 4: stream_structure_version
buf[offset+5] = (byte) headerType; // 5: header_type_flag
writeLong(buf, offset+6, granulepos); // 6 - 13: absolute granule position
writeInt(buf, offset+14, streamSerialNumber); // 14 - 17: stream serial number
writeInt(buf, offset+18, pageCount); // 18 - 21: page sequence no
writeInt(buf, offset+22, 0); // 22 - 25: page checksum
buf[offset+26] = (byte) packetCount; // 26: page_segments
System.arraycopy(packetSizes, 0, // 27 - x: segment_table
buf, offset+27, packetCount);
return packetCount+27;
}
/**
* Builds and returns an Ogg Page Header.
* @param headerType the header type flag
* (0=normal, 2=bos: beginning of stream, 4=eos: end of stream).
* @param granulepos the absolute granule position.
* @param streamSerialNumber
* @param pageCount
* @param packetCount
* @param packetSizes
* @return an Ogg Page Header.
*/
public static byte[] buildOggPageHeader(int headerType, long granulepos,
int streamSerialNumber, int pageCount,
int packetCount, byte[] packetSizes)
{
byte[] data = new byte[packetCount+27];
writeOggPageHeader(data, 0, headerType, granulepos, streamSerialNumber,
pageCount, packetCount, packetSizes);
return data;
}
/**
* Writes a Speex Header to the given byte array.
* @param buf the buffer to write to.
* @param offset the from which to start writing.
* @param sampleRate
* @param mode
* @param channels
* @param vbr
* @param nframes
* @return the amount of data written to the buffer.
*/
public static int writeSpeexHeader(byte[] buf, int offset, int sampleRate,
int mode, int channels, boolean vbr,
int nframes)
{
writeString(buf, offset, "Speex "); // 0 - 7: speex_string
writeString(buf, offset+8, "speex-1.2rc"); // 8 - 27: speex_version
System.arraycopy(new byte[11], 0, buf, offset+17, 11); // : speex_version (fill in up to 20 bytes)
writeInt(buf, offset+28, 1); // 28 - 31: speex_version_id
writeInt(buf, offset+32, 80); // 32 - 35: header_size
writeInt(buf, offset+36, sampleRate); // 36 - 39: rate
writeInt(buf, offset+40, mode); // 40 - 43: mode (0=NB, 1=WB, 2=UWB)
writeInt(buf, offset+44, 4); // 44 - 47: mode_bitstream_version
writeInt(buf, offset+48, channels); // 48 - 5
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
android 录音机采用speex编解码 (480个子文件)
Makefile.am 2KB
Makefile.am 358B
Makefile.am 17B
resources.ap_ 10KB
GaussRecorder.apk 251KB
nb_celp.c 61KB
sb_celp.c 46KB
mdf.c 43KB
preprocess.c 41KB
resample.c 40KB
jitter.c 29KB
ltp.c 24KB
filters.c 23KB
smallft.c 23KB
lsp.c 18KB
cb_search.c 18KB
kiss_fft.c 16KB
kiss_fftr.c 10KB
bits.c 10KB
stereo.c 10KB
quant_lsp.c 10KB
fftwrap.c 9KB
vbr.c 9KB
modes.c 8KB
scal.c 8KB
lsp_tables_nb.c 8KB
filterbank.c 7KB
speex.c 6KB
modes_wb.c 6KB
exc_5_256_table.c 6KB
hexc_table.c 6KB
speex_header.c 6KB
window.c 5KB
lpc.c 5KB
high_lsp_tables.c 5KB
exc_8_128_table.c 5KB
buffer.c 5KB
speex_callbacks.c 4KB
vq.c 4KB
testenc.c 4KB
gain_table.c 4KB
testenc_wb.c 4KB
exc_20_32_table.c 3KB
testenc_uwb.c 3KB
hexc_10_32_table.c 3KB
exc_5_64_table.c 3KB
exc_10_32_table.c 3KB
exc_10_16_table.c 2KB
gain_table_lbr.c 2KB
testjitter.c 2KB
testecho.c 1KB
testdenoise.c 1KB
proguard.cfg 1KB
AudioFileWriter.class 4KB
AudioFileWriter.class 4KB
OggSpeexWriter.class 4KB
OggSpeexWriter.class 4KB
SpeexEncoder.class 4KB
SpeexEncoder.class 4KB
SpeexWriter.class 4KB
SpeexWriter.class 3KB
GaussRecorderActivity.class 3KB
SpeexRecorder.class 3KB
SpeexRecorder.class 3KB
SpeexPlayer$RecordPlayThread.class 3KB
SpeexWriteClient.class 2KB
GaussRecorderActivity.class 2KB
SpeexWriteClient.class 2KB
SpeexPlayer.class 2KB
SpeexWriter$processedData.class 1KB
SpeexEncoder$ReadData.class 1KB
Speex.class 1KB
Speex.class 1KB
SpeexWriter$processedData.class 996B
SpeexEncoder$ReadData.class 973B
OggCrc.class 824B
OggCrc.class 824B
R.class 489B
R.class 489B
R$string.class 427B
R$string.class 427B
R$drawable.class 400B
R$drawable.class 400B
R$layout.class 394B
R$layout.class 394B
R$attr.class 340B
R$attr.class 340B
.classpath 358B
convert.cpp 5KB
convert.cpp 5KB
convert.cpp 5KB
TestSpeex.cpp 5KB
TestSpeex.cpp 5KB
TestSpeex.cpp 5KB
speex_jni.cpp 3KB
sb_celp.o.d 8KB
sb_celp.o.d 8KB
nb_celp.o.d 8KB
nb_celp.o.d 8KB
modes_wb.o.d 8KB
共 480 条
- 1
- 2
- 3
- 4
- 5
kingsha工作室
- 粉丝: 0
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页