簡體   English   中英

如何比較c#中兩個波形的相似度?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM