简体   繁体   English

使用C#测试音频文件

[英]Testing an Audio File Using C#

I would like to write a script that tests a specific .WAV file and determines whether it was recorded fine or not. 我想编写一个脚本来测试特定的.WAV文件,并确定是否录制得很好。 What I mean by this, is that I'm going to let several computers record the same input at the same time, save their audio files and at that point I need to see what computers did not manage to record it due to whatever reasons there might be. 我的意思是,我将让多台计算机同时记录相同的输入,保存其音频文件,这时我需要查看由于什么原因而没有计算机记录该输入的计算机可能。

I was thinking about checking the size of an audio file, but I'm not sure it is possible to say if a certain PC that had no actual recording in its output file did not pass the test, whilst another PC has passed it, basing only on the size of the output file. 我当时正在考虑检查音频文件的大小,但是我不确定是否可以说某台没有在其输出文件中进行实际录制的PC是否通过了测试,而另一台PC已经通过了测试,仅关于输出文件的大小。

I hope I'm clear enough about my question. 我希望我对我的问题足够清楚。 Best regards. 最好的祝福。

You can query the file attributes for sample rate , the higher the sample rate the better the quality. 您可以查询文件属性的采样率,采样率越高,质量越好。 Like so , taken from here : Whant to check all kind of audio & video quality in asp.net C# 像这样,从此处获取: 想要检查asp.net C#中的所有音频和视频质量

    using WMPLib; 

    WindowsMediaPlayerClass wmp = new WindowsMediaPlayerClass();
    IWMPMedia mediaInfo = wmp.newMedia("myfile.wmv"); 

    // duration
    Console.WriteLine("Duration = " + mediaInfo.duration);

    // write named attributes
    for (int i=0; i<mediaInfo.attributeCount; i++) 
    {
      Console.WriteLine(mediaInfo.getAttributeName(i) + " = " +  m    ediaInfo.getItemInfo(mediaInfo.getAttributeName(i)) );
    }

Or use a 3rd part tool/library to test sound quality 或使用第三部分工具/库来测试音质

NAudio was my solution. NAudio是我的解决方案。 I highly recommend using this library in similar cases. 我强烈建议在类似情况下使用此库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM