当前位置: 首页 > news >正文

一些音频文件转Wav

常见的 音频文件就不用多说了,今天就说一下比较冷门的音频文件。

DSS、DS2文件转换的代码:

  AudioFunctions ds2 = new AudioFunctions();
  ds2.DSSToWav(income_fn, wav_fn); 

需要的环境:

DPMControl.msi

OlyAudCom.dll

PIA.DpmCtrlLib.dll

代码:

下面是AudioFileSourceType2.OLYMPUS、 AudioFileSourceType2.PHILIPS的处理

 public void DSSToWav(string dssFile, string outputFile, bool processUnknown = true){if (File.Exists(outputFile)){File.Delete(outputFile);}OlympusConverter converter = new OlympusConverter();AudioFileDetails2 fileDetails = converter.GetAudioFileDetails(dssFile);if (fileDetails == null){throw new Exception("Unable to determine file source type.");}else if (fileDetails.AudioFileSourceType == AudioFileSourceType2.OLYMPUS){Console.WriteLine("\tConverting with Olympus Converter");converter.Convert(dssFile, outputFile);converter = null;fileDetails = null;GC.Collect(2, GCCollectionMode.Forced);}else if (fileDetails.AudioFileSourceType == AudioFileSourceType2.PHILIPS){Console.WriteLine("\tConverting with Philips DPMCtrl Converter");PhilipsConverter DPMCtrl = new PhilipsConverter();DPMCtrl.convert(dssFile, outputFile, 0, false);DPMCtrl = null;converter = null;fileDetails = null;GC.Collect(2, GCCollectionMode.Forced);}else if (fileDetails.AudioFileSourceType == AudioFileSourceType2.UNKNOWN && processUnknown == true){Console.WriteLine("\tTrying DSS as DS2");string ds2File = dssFile + ".ds2";WavFileUtils.ChangeDSS2DS2(dssFile, ds2File);DSSToWav(ds2File, outputFile, false);File.Delete(ds2File);}}
 public static void ChangeDSS2DS2(string inPath, string outPath){using (BinaryReader br = new BinaryReader(new FileStream(inPath, FileMode.Open))){using (BinaryWriter wr = new BinaryWriter(new FileStream(outPath, FileMode.Create))){int index = 0;int count = 1024;byte[] buffer = new byte[count];int bufferSize = 0;while ((bufferSize = br.Read(buffer, 0, count)) > 0){if (index == 0){for (int i = 0; i < 10; i++){if (buffer[i] == 'd' && buffer[i + 1] == 's' && buffer[i + 2] == 's'){buffer[i] = (byte)'d';buffer[i + 1] = (byte)'s';buffer[i + 2] = (byte)'2';break;}}}wr.Write(buffer, 0, bufferSize);index += bufferSize;}}}}

对于  AudioFileSourceType2.PHILIPS使用下面的代码进行处理:

   public class PhilipsConverter{public void convert(string sourceFile, string destFile, int AudioFormat, bool delayed){try{IDPMControl iDPM = new DPMControl();iDPM.Initialize(false);//After initializing the DPMControl it is possible to extract job information from a file. //var fileInfo = iDPM.get_FileInfo(sourceFile);//The last arguement is the files password, as we do not support password protected DS2 it is always blank string. //If we get a password protected file then the task will fail. iDPM.Decrypt(sourceFile, destFile, (dpmAudioFormat)AudioFormat, delayed, "");iDPM.Deinitialize();}catch (COMException e){//From my testing, when passing a file with a password the Error message is DPMCtrlFileNotFound. var err = e.ErrorCode;dpmCtrlError dpmErr = (dpmCtrlError)err;Console.WriteLine(string.Format("****\nErrCode: {0}\nError: {1}\n****", err, dpmErr));throw new Exception("Failed to convert DS2 to Wav with error message " + dpmErr, innerException: e);}}}


http://www.mrgr.cn/news/33074.html

相关文章:

  • 使用OpenCV(C++)通过鼠标点击操作获取图像的像素坐标和像素值
  • 大数据新视界 -- 大数据大厂之 Impala 存储格式转换:从原理到实践,开启大数据性能优化星际之旅(下)(20/30)
  • 【TensorRT】使用C++将yolov8 onnx转化为tensorrt格式
  • I.MX6U 裸机开发9.BEEP蜂鸣器实验
  • 【LeetCode】【算法】11. 盛最多水的容器
  • Docker 篇-Docker 详细安装、了解和使用 Docker 核心功能(数据卷、自定义镜像 Dockerfile、网络)
  • BUUCTF逆向wp [WUSTCTF2020]Cr0ssfun
  • 【笔记】第三节 组织与性能
  • 计算机毕业设计 数字化农家乐管理平台的设计与实现 Java实战项目 附源码+文档+视频讲解
  • C++入门(03)萌新问题多(二)
  • ftrace - 几种tracer的打印例子
  • OpenGL 原生库5 变换
  • 吉首大学--23级题目讲解
  • 山东潍坊戴尔存储服务器维修 md3800f raid恢复
  • OpenGL使用Glfw框架创建第一个窗体
  • 【巧用ddddocr破解算术运算验证码的经典示范】
  • 【OS】AUTOSAR OsStack监控原理
  • CMake中的PUBLIC、PRIVATE 和 INTERFACE用法
  • 楼宇自动巡检小车设计
  • 借10万块,年化利息明明是3.8%,为啥就变成了2.07%?
  • 【软考】传输层协议TCP与UDP
  • C++智能指针入门教程(C++11)
  • OpenGL渲染管线(Rendering Pipeline)介绍
  • proteus仿真学习(1)
  • 【笔记】1.3 塑性变形
  • PAT甲级-1086 Tree Traversals Again