Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  Version bump to v9.4.2
  Changing RealtimeQueryCommand similar to QueryCommand by asking only for IQueryService at the input instead of IModelService.
  • Loading branch information
AddictedCS committed Feb 27, 2024
2 parents a3879c1 + 09ca62b commit 88d82bf
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public async Task CreateFingerprintsFromFileAndFromAudioSamplesAndGetTheSameResu
.From(samples)
.Hash();

AssertHashDatasAreTheSame(h1, h2);
AssertHashDataIsTheSame(h1, h2);
}

[Test]
Expand Down Expand Up @@ -147,7 +147,7 @@ public async Task CreateFingerprintsWithTheSameFingerprintCommandTest()
var (h1, _) = await fingerprintCommand.Hash();
var (h2, _) = await fingerprintCommand.Hash();

AssertHashDatasAreTheSame(h1, h2);
AssertHashDataIsTheSame(h1, h2);
}

[Test]
Expand Down Expand Up @@ -289,9 +289,9 @@ public async Task ShouldCreateSameFingerprintsDuringDifferentParallelRuns()
.UsingServices(audioService)
.Hash();

AssertHashDatasAreTheSame(hashDatas1, hashDatas2);
AssertHashDatasAreTheSame(hashDatas2, hashDatas3);
AssertHashDatasAreTheSame(hashDatas3, hashDatas4);
AssertHashDataIsTheSame(hashDatas1, hashDatas2);
AssertHashDataIsTheSame(hashDatas2, hashDatas3);
AssertHashDataIsTheSame(hashDatas3, hashDatas4);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;

using Audio;
using Data;
using ProtoBuf;
Expand All @@ -13,11 +11,11 @@

public abstract class IntegrationWithSampleFilesTest : AbstractTest
{
protected readonly string pathToSamples = Path.Combine(TestContext.CurrentContext.TestDirectory, "chopinsamples.bin");
private readonly string pathToSamples = Path.Combine(TestContext.CurrentContext.TestDirectory, "chopinsamples.bin");

protected readonly string PathToWav = Path.Combine(TestContext.CurrentContext.TestDirectory, "chopin_short.wav");

protected void AssertHashDatasAreTheSame(Hashes h1, Hashes h2)
protected static void AssertHashDataIsTheSame(Hashes h1, Hashes h2)
{
var firstHashes = h1.ToList();
var secondHashes = h2.ToList();
Expand All @@ -36,7 +34,7 @@ protected void AssertHashDatasAreTheSame(Hashes h1, Hashes h2)
}
}

protected TagInfo GetTagInfo()
protected static TagInfo GetTagInfo()
{
return new TagInfo
{
Expand Down
4 changes: 2 additions & 2 deletions src/SoundFingerprinting.Tests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("4cac962e-ebc5-4006-a1e0-7ffb3e2483c2")]
[assembly: AssemblyVersion("9.4.0.101")]
[assembly: AssemblyInformationalVersion("9.4.0.101")]
[assembly: AssemblyVersion("9.4.2.100")]
[assembly: AssemblyInformationalVersion("9.4.2.100")]
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public async Task ShouldCreateExactlyTheSameFingerprints()
.From(audioSamples)
.Hash();

AssertHashDatasAreTheSame(h1, h2);
AssertHashDataIsTheSame(h1, h2);
}
}

Expand Down
20 changes: 10 additions & 10 deletions src/SoundFingerprinting/Command/IUsingRealtimeQueryServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,40 @@ public interface IUsingRealtimeQueryServices : IRealtimeQueryCommand
/// <summary>
/// Sets the model service that will be used as the data source during query.
/// </summary>
/// <param name="modelService">ModelService to query.</param>
/// <param name="queryService">ModelService to query.</param>
/// <returns>Realtime command.</returns>
IRealtimeQueryCommand UsingServices(IModelService modelService);
IRealtimeQueryCommand UsingServices(IQueryService queryService);

/// <summary>
/// Sets the model service that will query the datasource, as well as the audio service that will read content to fingerprint.
/// </summary>
/// <param name="modelService">ModelService to query.</param>
/// <param name="queryService">ModelService to query.</param>
/// <param name="audioService">AudioService to use for file processing.</param>
/// <returns>Realtime command.</returns>
IRealtimeQueryCommand UsingServices(IModelService modelService, IAudioService audioService);
IRealtimeQueryCommand UsingServices(IQueryService queryService, IAudioService audioService);

/// <summary>
/// Sets the model service that will query the datasource, as well as the media service that will read content to fingerprint.
/// </summary>
/// <param name="modelService">ModelService to query.</param>
/// <param name="queryService">ModelService to query.</param>
/// <param name="mediaService">MediaService to use for file processing.</param>
/// <returns>Realtime command.</returns>
IRealtimeQueryCommand UsingServices(IModelService modelService, IMediaService mediaService);
IRealtimeQueryCommand UsingServices(IQueryService queryService, IMediaService mediaService);

/// <summary>
/// Sets the model service that will query the datasource, as well as the video service that will read content to fingerprint.
/// </summary>
/// <param name="modelService">ModelService to query.</param>
/// <param name="queryService">ModelService to query.</param>
/// <param name="videoService">VideoService to use for file processing.</param>
/// <returns>Realtime command.</returns>
IRealtimeQueryCommand UsingServices(IModelService modelService, IVideoService videoService);
IRealtimeQueryCommand UsingServices(IQueryService queryService, IVideoService videoService);

/// <summary>
/// Sets the model service that will query the datasource, as well as the realtime media service used to create fingerprints directly from a given URL.
/// </summary>
/// <param name="modelService">ModelService to query.</param>
/// <param name="queryService">ModelService to query.</param>
/// <param name="realtimeMediaService">Realtime media service to use.</param>
/// <returns>Realtime command.</returns>
IRealtimeQueryCommand UsingServices(IModelService modelService, IRealtimeMediaService realtimeMediaService);
IRealtimeQueryCommand UsingServices(IQueryService queryService, IRealtimeMediaService realtimeMediaService);
}
}
38 changes: 19 additions & 19 deletions src/SoundFingerprinting/Command/RealtimeQueryCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public sealed class RealtimeQueryCommand : IRealtimeSource, IWithRealtimeQueryCo
private Func<CancellationToken, IAsyncEnumerable<AVHashes>> realtimeCollection;
private RealtimeQueryConfiguration configuration;
private IRealtimeMediaService? realtimeMediaService;
private IModelService? modelService;
private IQueryService? queryService;
private IMediaService? mediaService;
private IVideoService? videoService;
private IAudioService audioService;
Expand Down Expand Up @@ -135,41 +135,41 @@ public async Task<double> Query(CancellationToken cancellationToken)
}
}

/// <inheritdoc cref="IUsingRealtimeQueryServices.UsingServices(IModelService)"/>
public IRealtimeQueryCommand UsingServices(IModelService service)
/// <inheritdoc cref="IUsingRealtimeQueryServices.UsingServices(IQueryService)"/>
public IRealtimeQueryCommand UsingServices(IQueryService service)
{
modelService = service;
queryService = service;
return this;
}

/// <inheritdoc cref="IUsingRealtimeQueryServices.UsingServices(IModelService,IAudioService)"/>
public IRealtimeQueryCommand UsingServices(IModelService modelService, IAudioService audioService)
/// <inheritdoc cref="IUsingRealtimeQueryServices.UsingServices(IQueryService,IAudioService)"/>
public IRealtimeQueryCommand UsingServices(IQueryService modelService, IAudioService audioService)
{
this.modelService = modelService;
this.queryService = modelService;
this.audioService = audioService;
return this;
}

/// <inheritdoc cref="IUsingRealtimeQueryServices.UsingServices(IModelService,IMediaService)"/>
public IRealtimeQueryCommand UsingServices(IModelService modelService, IMediaService mediaService)
/// <inheritdoc cref="IUsingRealtimeQueryServices.UsingServices(IQueryService,IMediaService)"/>
public IRealtimeQueryCommand UsingServices(IQueryService modelService, IMediaService mediaService)
{
this.modelService = modelService;
this.queryService = modelService;
this.mediaService = mediaService;
return this;
}

/// <inheritdoc cref="IUsingRealtimeQueryServices.UsingServices(IModelService,IVideoService)"/>
public IRealtimeQueryCommand UsingServices(IModelService modelService, IVideoService videoService)
/// <inheritdoc cref="IUsingRealtimeQueryServices.UsingServices(IQueryService,IVideoService)"/>
public IRealtimeQueryCommand UsingServices(IQueryService modelService, IVideoService videoService)
{
this.modelService = modelService;
this.queryService = modelService;
this.videoService = videoService;
return this;
}

/// <inheritdoc cref="IUsingRealtimeQueryServices.UsingServices(IModelService,IRealtimeMediaService)"/>
public IRealtimeQueryCommand UsingServices(IModelService modelService, IRealtimeMediaService realtimeMediaService)
/// <inheritdoc cref="IUsingRealtimeQueryServices.UsingServices(IQueryService,IRealtimeMediaService)"/>
public IRealtimeQueryCommand UsingServices(IQueryService modelService, IRealtimeMediaService realtimeMediaService)
{
this.modelService = modelService;
this.queryService = modelService;
this.realtimeMediaService = realtimeMediaService;
return this;
}
Expand Down Expand Up @@ -354,7 +354,7 @@ private void HandleQueryFailure(AVHashes? hashes, Exception e)
}

/// <summary>
/// Queries local or remote <see cref="IModelService"/> with <see cref="AVHashes"/> gathered from offline storage.
/// Queries local or remote <see cref="IQueryService"/> with <see cref="AVHashes"/> gathered from offline storage.
/// </summary>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>Async enumerable with <see cref="AVQueryResult"/>.</returns>
Expand All @@ -373,7 +373,7 @@ private async IAsyncEnumerable<AVQueryResult> QueryFromOfflineStorage([Enumerato
}

/// <summary>
/// Tries querying associated <see cref="IModelService"/>.
/// Tries querying associated <see cref="IQueryService"/>.
/// </summary>
/// <param name="hashes">An instance of <see cref="AVHashes"/>.</param>
/// <param name="realtimeAggregator">Realtime aggregator.</param>
Expand Down Expand Up @@ -491,7 +491,7 @@ private async Task<AVQueryResult> GetAvQueryResult(AVHashes hashes)
.BuildQueryCommand()
.From(hashes)
.WithQueryConfig(configuration.QueryConfiguration)
.UsingServices(modelService)
.UsingServices(queryService)
.Query();
var avQueryResult = queryResultInterceptor(queryResult);
queryLength += (hashes.Audio?.DurationInSeconds + hashes.Audio?.TimeOffset ?? hashes.Video?.DurationInSeconds) ?? 0;
Expand Down
4 changes: 2 additions & 2 deletions src/SoundFingerprinting/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
[assembly: InternalsVisibleTo("SoundFingerprinting.FFT.FFTW")]
[assembly: InternalsVisibleTo("SoundFingerprinting.FFT.FFTW.Tests")]

[assembly: AssemblyVersion("9.4.0.101")]
[assembly: AssemblyInformationalVersion("9.4.0.101")]
[assembly: AssemblyVersion("9.4.2.100")]
[assembly: AssemblyInformationalVersion("9.4.2.100")]
4 changes: 2 additions & 2 deletions src/SoundFingerprinting/SoundFingerprinting.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Nullable>enable</Nullable>
<PackageVersion>9.4.0</PackageVersion>
<PackageVersion>9.4.2</PackageVersion>
<Authors>Sergiu Ciumac</Authors>
<PackageDescription>SoundFingerprinting is a C# framework that implements an efficient algorithm of audio fingerprinting and identification. Designed for developers, enthusiasts, researchers in the fields of audio processing, data mining, digital signal processing.</PackageDescription>
<PackageProjectUrl>https://github.com/addictedcs/soundfingerprinting</PackageProjectUrl>
<RepositoryUrl>https://github.com/AddictedCS/soundfingerprinting</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageReleaseNotes>
Version 9.4.0
Version 9.4.2
- Contains an important improvement to QueryCommand, allowing a much faster lookup for the use-cases when the track and the query are very long and almost identical.
- The improvement is rooted in the idea of returning Candidates from the IModelService instead of list of SubFingerprints. This provided knowledge on which hashed fingerprint matched with the query.
- To further improve the API design, methods related to the correct functioning of the QueryCommand were extracted into IQueryService interface (from which IModelService derives).
Expand Down

0 comments on commit 88d82bf

Please sign in to comment.