[英]How to compare the similarity of two waveforms in c#?
我试图根据波形的视觉方面而不是它们的声音来比较两个波形的相似性。
我怎么能在 c# 中做到这一点?
如果波形数据的格式使得时间 = 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();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.