资源简介
wav格式文件截取指定时间段内容,精确到毫秒级
使用方法
WavFileCut_Console.exe 原始文件.wav 新生成文件.wav 开始时间毫秒数 结束时间毫秒数

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace WavFileCut
{
public class WavFormat
{
public int _bitsPerSample;
public int _channels;
public int _sampleRate;
public long _byteRate;
}
public class WavFile
{
private WavFormat _wavFormat;
private long _fileLength;
private string _filePath;
private byte[] _audioData;
public WavFile(string filePath)
{
_filePath = filePath;
}
public WavFormat WavFormat
{
get
{
if (_wavFormat == null)
{
_wavFormat = GetWavFormat();
}
return _wavFormat;
}
set
{
_wavFormat = value;
}
}
public long FileLength
{
get
{
if (_wavFormat == null)
{
_wavFormat = GetWavFormat();
}
return _fileLength;
}
set
{
_fileLength = value;
}
}
public long PlayTime
{
get
{
if (_wavFormat == null)
{
_wavFormat = GetWavFormat();
}
return _audioData.Length / _wavFormat._byteRate;
}
}
public byte[] AudioDataBytes
{
get
{
if (_wavFormat == null)
{
_wavFormat = GetWavFormat();
}
return _audioData;
}
set
{
_audioData = value;
}
}
public void SetWavFormat(int bitsPerSample int channels int sampleRate)
{
_wavFormat = new WavFormat();
_wavFormat._bitsPerSample = bitsPerSample;
_wavFormat._channels = channels;
_wavFormat._sampleRate = sampleRate;
}
public void WriteWavFile(byte[] audioData)
{
WriteWavFile(_wavFormat audioData 0 audioData.Length);
}
public void WriteWavFile(WavFormat wavFormat byte[] audioData int startIndex int length)
{
FileStream fs = null;
BinaryWriter bw = null;
try
{
fs = new FileStream(_filePath FileMode.Create FileAccess.Write);
bw = new BinaryWriter(fs);
fs.Position = 0;
bw.Write(new char[4] { ‘R‘ ‘I‘ ‘F‘ ‘F‘ });
bw.Write((int)(length + 44 - 8));
bw.Write(new char[8] { ‘W‘ ‘A‘ ‘V‘ ‘E‘
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1450 2013-03-14 14:51 WavFileCut\WavFileCut\Properties\AssemblyInfo.cs
文件 6954 2013-03-14 14:56 WavFileCut\WavFileCut\WavCut.cs
文件 2623 2013-03-14 14:53 WavFileCut\WavFileCut\WavFileCut.csproj
文件 1428 2013-03-14 15:08 WavFileCut\WavFileCut.sln
文件 964 2013-03-14 15:08 WavFileCut\WavFileCut_Console\Program.cs
文件 1466 2013-03-14 14:56 WavFileCut\WavFileCut_Console\Properties\AssemblyInfo.cs
文件 2811 2013-03-14 15:12 WavFileCut\WavFileCut_Console\WavFileCut_Console.csproj
目录 0 2013-03-14 14:51 WavFileCut\WavFileCut\Properties
目录 0 2013-03-14 14:56 WavFileCut\WavFileCut_Console\Properties
目录 0 2013-03-14 15:13 WavFileCut\WavFileCut
目录 0 2013-03-14 15:13 WavFileCut\WavFileCut_Console
目录 0 2013-03-14 15:12 WavFileCut
----------- --------- ---------- ----- ----
17696 12
相关资源
- 基于OpenCV的数字识别468815
- 一个网络封包截取工具[不是WPE]
- C 源码 画出wav文件声音数据的波形曲
- 文本分割器(免费 无需安装)
- 声音文件播放程序.可以播放WAV文件并
- 经典wav音乐,特别收录
- stm32的DAC播放音乐文件
- 基于pytorch的UNet_demo实现及训练自己的
- 易语言简单树型框分割文本源码
- wav语音文件裁剪 截取工具
- New Analytical Solution of a Generalized Negat
- Analytical Studies of the (2+1)-Dimensiona
- Exact Conditions of Blow-up and Global Existen
- Wavelet characterization for multipliers on So
- Strichartz estimates for the wave equation wit
- Sinusoid envelope voltammetry - A novel voltam
- Schwarzian量子力学的Shockwave S矩阵
- 带式输送机托辊红外图像分割与定位
- Channel waveguides fabrication in bulk Lithium
- Sub-wavelength surface structuring of NiTi all
- Optimal control of the nonlinear one dimension
- 机载LiDAR支持下的铁路附属建(构)筑
- 基于libsvm的图像分割代码
- 截取封包工具
- Seismic Frequency-domain Full waveform 2-D inv
- 易语言封包截取源码易语言HOOKapi实现
- WPE封包截取工具和数据加密解密教程
- 14万 英文语音库
- 基于朴素贝叶斯分类法的图像分割
- M3U8视频PC机64位辅助工具2.0 —&md
评论
共有 条评论