Beispiel #1
0
 public static uint PeakPairToHash(PeakPair pp)
 {
     // Put frequency bins and the distance each in one byte. The actual quantization
     // is configured through the parameters, e.g. the FFT window size determines the
     // number of frequency bins, and the size of the target zone determines the max
     // distance. Their max size can be anywhere in the range of a byte. if it should be
     // higher, a quantization step must be introduced (which will basically be a division).
     return((uint)((byte)pp.Peak1.Index << 16 | (byte)pp.Peak2.Index << 8 | (byte)pp.Distance));
 }
Beispiel #2
0
        private void ConvertPairsToSubFingerprints(List <PeakPair> peakPairs, List <SubFingerprint> subFingerprints)
        {
            // This sorting step is needed for the Zipper intersection algorithm in the fingerprint
            // store to find matching hashes, which expects them sorted by frame index. Sorting works
            // because the index is coded in the most significant bits of the hashes.
            var hashes = peakPairs.ConvertAll(pp => new SubFingerprintHash(PeakPair.PeakPairToHash(pp)));

            hashes.Sort();
            subFingerprints.AddRange(hashes.ConvertAll(h => new SubFingerprint(peakPairs[0].Index, h, false)));
        }