91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 10KB
    文件類型: .java
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2021-06-12
  • 語言: Java
  • 標簽: vox??java??wav??

資源簡介

很牛逼的算法,網(wǎng)上很難找到。我找了好久才找到的,希望大家支持~~

資源截圖

代碼片段和文件信息

import?java.io.File;
import?java.io.FileInputStream;
import?java.io.FileOutputStream;
import?java.io.FileWriter;

public?class?VoxConvert?{

private?int?convertFormat?=?1;

private?int?convertRate?=?8000;

private?int?convertBits?=?1;

private?final?int?WAV_HEAD?=?36;//?wav文件頭長度

private?static?final?int?VF_ADPCM?=?1;//?編碼格式

private?static?final?int?BIT_RATE_VB_8?=?1;//?每個樣本位數(shù)

private?static?final?int?BIT_RATE_VB_16?=?2;//?每個樣本位數(shù)

private?final?int?RESET_VALUE?=?48;

private?byte?out_val;

/**
?*?
?*?@param?inFile
?*?@param?outFile
?*?@param?voxFormat
?*????????????格式?取值范圍:VF_ADPCM?=?1?VF_MULAW?=?2?VF_ALAW?=?3
?*?@param?voxRate
?*????????????采樣率?取值范圍:VR_6K?=?6000?VR_8K?=?8000
?*?@param?bit_rate
?*????????????位數(shù)?取值范圍:VB_8?=?1?VB_16?=?2
?*?@return
?*/
public?VoxConvert(String?inFile?String?outFile?int?voxFormat
int?voxRate?int?bit_rate)?throws?Exception?{
if?(voxFormat?!=?0)?{
convertFormat?=?voxFormat;
}
if?(voxRate?!=?0)?{
convertRate?=?voxRate;
}
if?(bit_rate?!=?0)?{
convertBits?=?bit_rate;
}
if?(outFile?==?null)?{
outFile?=?inFile.substring(0?inFile.length()?-?3);
outFile?=?outFile?+?“wav“;
}

File?outF?=?new?File(outFile);
File?inF?=?new?File(inFile);

long?inFileSize?=?inF.length();
if?(voxFormat?==?VF_ADPCM)?{?//?if?using?ADPCM?input?format...
inFileSize?=?inFileSize?*?2;
}//?change?from?bytes?to?samples

FileOutputStream?filewriter?=?new?FileOutputStream(outF?false);
String?wavBegin?=?“RIFF“;
filewriter.write(wavBegin.getBytes());//?WAV?文件頭

long?wavLength?=?inFileSize?*?bit_rate?+?WAV_HEAD;
byte[]?tmpArr?=?new?byte[4];
longToIntBinary(wavLength?tmpArr?0);
filewriter.write(tmpArr);//?文件總長度

String?wavTag?=?“WAVEfmt?“;
filewriter.write(wavTag.getBytes());//?WAV?文件標識

int?headLength?=?16;
tmpArr?=?new?byte[4];
longToIntBinary(headLength?tmpArr?0);
filewriter.write(tmpArr);//?size?of?.WAV?file?header

int?wFormatTag?=?1;?//?format?tag?(01?=?Windows?PCM)
tmpArr?=?new?byte[2];
toShortBinary(wFormatTag?tmpArr?0);
filewriter.write(tmpArr);//?format?tag?(01?=?Windows?PCM)

int?nChannels?=?1;?//?channels?(1=mono?2=stereo)
tmpArr?=?new?byte[2];
toShortBinary(nChannels?tmpArr?0);
filewriter.write(tmpArr);//?channels?(1=mono?2=stereo)

int?nSamplesPerSec?=?voxRate;?//?samples?per?second
tmpArr?=?new?byte[4];
longToIntBinary(nSamplesPerSec?tmpArr?0);
filewriter.write(tmpArr);

int?nAvgBytesPerSec?=?voxRate?*?bit_rate;?//?bytes?per?second
//?during?play
tmpArr?=?new?byte[4];
longToIntBinary(nAvgBytesPerSec?tmpArr?0);
filewriter.write(tmpArr);

int?nBlockAlign?=?bit_rate;?//?bytes?per?sample
tmpArr?=?new?byte[2];
toShortBinary(nBlockAlign?tmpArr?0);
filewriter.write(tmpArr);//?bytes?per?sample

int?wBitsPerSample?=?8?*?bit_rate;?//?bits?per?sample
tmpArr?=?new?byte[2];
toShortBinary(

評論

共有 條評論