如何比较c#中两个波形的相似性?



我试图根据波形的视觉方面而不是它们的声音来比较两个波形的相似性。
如何在 c# 中执行此操作?

如果波形数据的格式使得 time = 0 处的值可以索引为波形 [0],波的下一个"帧"可以索引为波形 [1],并且波的"帧"的最大值为 1,波的"帧"的最小值为 -1, (并且两个波的长度以"帧"为单位相同(,那么我认为这应该有效:(未经测试(

//WaveForm 1 is w1 and WaveForm 2 is w2.
Stack<float> temp = new Stack<float>();
for(int i = 0; i < w1.Length; i++)
{
//differenceFactor is the variable that decides what difference means.
//at a value of 1, then a two waves with indexes -0.5 and 0.5 will be "100%" 
//different. At a value of 0.5f then two waves with indexes -0.5 and 0.5 will be 
//"50%" different. According to what I see, if differenceFactor > 1f then wave 
//indexes greater than 1 unit apart are more than "100%" different, so probably don't 
//do that.
float difference = Math.Abs(w1[i] - w2[i]);
temp.Push(((difference < differenceFactor) ? difference : differenceFactor) * 0.5f);
}
return temp.Average();

相关内容

  • 没有找到相关文章

最新更新