Skip to content

Commit

Permalink
Asserting how silence maps in the hash domain.
Browse files Browse the repository at this point in the history
  • Loading branch information
AddictedCS committed Jun 14, 2024
1 parent e9fe63c commit e6cc3e8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/SoundFingerprinting.Tests/Unit/Math/SimilarityUtilityTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ public void CalculateJaccardSimilarityCorrect()
Assert.AreEqual(5f / 6, result, 0.0001);
}

[Test]
public void SilenceShouldMapToNegativeOne()
{
byte[] minHashes = [255, 255, 255, 255];
int[] hashes = hashConverter.ToInts(minHashes, 1);

Assert.AreEqual(1, hashes.Length);
Assert.AreEqual(-1, hashes[0]);
}

private byte[] GenerateByteArray(int length)
{
var ran = new Random();
Expand Down
2 changes: 1 addition & 1 deletion src/SoundFingerprinting/Data/AVHashes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public AVHashes WithStreamId(string streamId)
}

/// <summary>
/// Add an additional property to the Audio/Video hashes object.
/// Add a property to the Audio/Video hashes object.
/// </summary>
/// <param name="key">Property key.</param>
/// <param name="value">Property value.</param>
Expand Down
2 changes: 1 addition & 1 deletion src/SoundFingerprinting/FingerprintService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ internal IEnumerable<Fingerprint> CreateOriginalFingerprintsFromFrames(IEnumerab
var images = normalized.ToList();
if (!images.Any())
{
return Enumerable.Empty<Fingerprint>();
return [];
}

var fingerprints = new ConcurrentBag<Fingerprint>();
Expand Down

0 comments on commit e6cc3e8

Please sign in to comment.