本文整理汇总了C#中WaveFormat.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# WaveFormat.Equals方法的具体用法?C# WaveFormat.Equals怎么用?C# WaveFormat.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WaveFormat
的用法示例。
在下文中一共展示了WaveFormat.Equals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValidateWaveAlignment
/// <summary>
/// Check waveform files consistence between waveform and
/// Referrence waveform files with the filemap.
/// </summary>
/// <param name="fileMap">File list map listed the sentences to validate.</param>
/// <param name="waveDir">Base directory of waveform file.</param>
/// <param name="refWaveDir">Directory of referrence waveform file.</param>
/// <param name="refName">The name of the referrence waveform directory.</param>
/// <returns>Data error set found.</returns>
public static DataErrorSet ValidateWaveAlignment(FileListMap fileMap, string waveDir,
string refWaveDir, string refName)
{
if (fileMap == null)
{
throw new ArgumentNullException("fileMap");
}
if (fileMap.Map == null)
{
throw new ArgumentException("fileMap.Map is null");
}
if (fileMap.Map.Keys == null)
{
throw new ArgumentException("fileMap.Map.Keys is null");
}
if (string.IsNullOrEmpty(refName))
{
throw new ArgumentNullException("refName");
}
if (string.IsNullOrEmpty(refWaveDir))
{
throw new ArgumentNullException("refWaveDir");
}
DataErrorSet errorSet = new DataErrorSet();
foreach (string sid in fileMap.Map.Keys)
{
try
{
string refFile = Path.Combine(refWaveDir, fileMap.Map[sid] + ".wav");
string waveFile = Path.Combine(waveDir, fileMap.Map[sid] + ".wav");
int waveSampleCount = 0;
int refSampleCount = 0;
WaveFormat waveFormat = new WaveFormat();
WaveFormat refWaveFormat = new WaveFormat();
StringBuilder sb = new StringBuilder();
// validate referrence file existance
if (!File.Exists(refFile))
{
sb.AppendFormat(CultureInfo.InvariantCulture,
"{0} file [{0}] does not exist.", refName, refFile);
}
else
{
refSampleCount = WaveFile.ReadSampleCount(refFile);
refWaveFormat = WaveFile.ReadFormat(refFile);
}
// validate waveform file existance
if (!File.Exists(waveFile))
{
sb.AppendFormat(CultureInfo.InvariantCulture,
"Wave file [{0}] does not exist.", waveFile);
}
else
{
waveSampleCount = WaveFile.ReadSampleCount(waveFile);
waveFormat = WaveFile.ReadFormat(waveFile);
}
// validate content consistence
if (waveSampleCount != 0 && refSampleCount != 0
&& waveSampleCount != refSampleCount)
{
sb.AppendFormat(CultureInfo.InvariantCulture,
"The sample count is not the same between waveform file [{0}] and {1} file [{2}].",
waveFile, refName, refFile);
}
if (!waveFormat.Equals(refWaveFormat))
{
sb.AppendFormat(CultureInfo.InvariantCulture,
"The waveform format is not the same between waveform file [{0}] and {1} file [{2}].",
waveFile, refName, refFile);
}
if (sb.Length > 0)
{
errorSet.Errors.Add(new DataError(string.Empty, sb.ToString(), sid));
}
}
catch (InvalidDataException ide)
{
//.........这里部分代码省略.........