public void SameNumberOfHashBinsIsInsertedInAllTablesWhenFingerprintingEntireSongTest() { const int StaticStride = 5115; TagInfo tagInfo = this.GetTagInfo(); int releaseYear = tagInfo.Year; TrackData track = new TrackData(tagInfo.ISRC, tagInfo.Artist, tagInfo.Title, tagInfo.Album, releaseYear, (int)tagInfo.Duration); var trackReference = TrackDao.InsertTrack(track); var hashedFingerprints = fingerprintCommandBuilder .BuildFingerprintCommand() .From(PathToMp3) .WithFingerprintConfig(config => { config.SpectrogramConfig.Stride = new IncrementalStaticStride(StaticStride, config.SamplesPerFingerprint); }) .UsingServices(audioService) .Hash() .Result; InsertHashedFingerprintsForTrack(hashedFingerprints, trackReference); var hashes = HashBinDao.ReadHashedFingerprintsByTrackReference(track.TrackReference); Assert.AreEqual(hashedFingerprints.Count, hashes.Count); foreach (var data in hashes) { Assert.AreEqual(25, data.HashBins.Length); } }
public TrackData Vector3ToTrackData(Vector3 vec, TrackData trackData) { trackData.x = FloatToInt(vec.x, true); trackData.y = FloatToInt(vec.z, true); trackData.z = FloatToInt(vec.y, true); return trackData; }
public bool DetectEyes(Image<Gray, byte> input, TrackData trackData) { if (input == null) return false; return DoEyesRegionExtraction(input, trackData); }
public void ShouldCreateFingerprintsFromAudioSamplesQueryAndGetTheRightResult() { const int SecondsToProcess = 10; const int StartAtSecond = 30; var audioSamples = GetAudioSamples(); var track = new TrackData(string.Empty, audioSamples.Origin, audioSamples.Origin, string.Empty, 1986, audioSamples.Duration); var trackReference = modelService.InsertTrack(track); var hashDatas = fingerprintCommandBuilder.BuildFingerprintCommand() .From(audioSamples) .UsingServices(audioService) .Hash() .Result; modelService.InsertHashDataForTrack(hashDatas, trackReference); var querySamples = GetQuerySamples(audioSamples, StartAtSecond, SecondsToProcess); var queryResult = queryCommandBuilder.BuildQueryCommand() .From(new AudioSamples(querySamples, string.Empty, audioSamples.SampleRate)) .UsingServices(modelService, audioService) .Query() .Result; Assert.IsTrue(queryResult.ContainsMatches); Assert.AreEqual(1, queryResult.ResultEntries.Count()); var bestMatch = queryResult.BestMatch; Assert.AreEqual(trackReference, bestMatch.Track.TrackReference); Assert.IsTrue(bestMatch.QueryMatchLength > SecondsToProcess - 3, string.Format("QueryMatchLength:{0}", bestMatch.QueryLength)); Assert.AreEqual(StartAtSecond, Math.Abs(bestMatch.TrackStartsAt), 0.1d); Assert.IsTrue(bestMatch.Confidence > 0.7, string.Format("Confidence:{0}", bestMatch.Confidence)); }
public static TrackData Vector3ToTrackData(Vector3 vec, TrackData trackData) { trackData.x = FloatToInt(vec.x); trackData.y = FloatToInt(vec.y); trackData.z = FloatToInt(vec.z); return trackData; }
public static void Init() { // Solo se crea la ventana si existen los datos del circuito managerData = GameObject.Find("MANAGER_TRACK").GetComponent<TrackData>(); if (managerData == null) { isActive = false; return; } if (isActive) { if (tClass != null) DestroyImmediate(tClass.gameObject); isActive = false; } else if (!isActive) { isActive = true; tClass = new GameObject("TRACK EDITOR").AddComponent<TrackDataEditorMono>(); tClass.hideFlags = HideFlags.HideInHierarchy; // Selecciona el editor GameObject[] gm = new GameObject[1]; gm[0] = tClass.gameObject; Selection.objects = gm; } }
public void Print(TrackData trackData) { const int numberOfTracks = 1; InitialiseGraphics(numberOfTracks); RenderTrackSwatch(trackData, numberOfTracks - 1); SaveSwatchToFile(); }
public void ShouldReadSubFingerprintsByHashBucketsHavingThreshold() { const int Threshold = 5; TrackData firstTrack = new TrackData("isrc1", "artist", "title", "album", 1986, 200); var firstTrackReference = modelService.InsertTrack(firstTrack); TrackData secondTrack = new TrackData("isrc2", "artist", "title", "album", 1986, 200); var secondTrackReference = modelService.InsertTrack(secondTrack); long[] firstTrackBuckets = new long[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 }; long[] secondTrackBuckets = new long[] { 2, 2, 4, 5, 6, 7, 7, 9, 10, 11, 12, 13, 14, 14, 16, 17, 18, 19, 20, 20, 22, 23, 24, 25, 26 }; var firstHashData = new HashedFingerprint(GenericSignature, firstTrackBuckets, 1, 0.928); var secondHashData = new HashedFingerprint(GenericSignature, secondTrackBuckets, 1, 0.928); modelService.InsertHashDataForTrack(new[] { firstHashData }, firstTrackReference); modelService.InsertHashDataForTrack(new[] { secondHashData }, secondTrackReference); // query buckets are similar with 5 elements from first track and 4 elements from second track long[] queryBuckets = new long[] { 3, 2, 5, 6, 7, 8, 7, 10, 11, 12, 13, 14, 15, 14, 17, 18, 19, 20, 21, 20, 23, 24, 25, 26, 25 }; var subFingerprints = modelService.ReadSubFingerprintDataByHashBucketsWithThreshold(queryBuckets, Threshold); Assert.IsTrue(subFingerprints.Count == 1); Assert.AreEqual(firstTrackReference, subFingerprints[0].TrackReference); }
public static GameEntityType GameEntityTypeFromTrackData(TrackData trackData) { GameEntityType entityType; switch (trackData.entityType) { case TrackData.EntityType.PLAYER: entityType = GameEntityType.Player; break; case TrackData.EntityType.NPC: entityType = GameEntityType.Npc; break; case TrackData.EntityType.SHIP: entityType = GameEntityType.Vehicle; break; case TrackData.EntityType.OTHER: entityType = GameEntityType.Other; break; default: entityType = GameEntityType.Other; break; } if (entityType == GameEntityType.Player && trackData.id != NetworkSettings.instance.username) { entityType = GameEntityType.OtherPlayer; } return entityType; }
public void TestSpectralImagesAreInsertedInDataSource() { TrackData track = new TrackData("isrc", "artist", "title", "album", 1986, 200); var trackReference = TrackDao.InsertTrack(track); var audioSamples = audioService.ReadMonoSamplesFromFile( PathToMp3, new DefaultFingerprintConfiguration().SampleRate); var spectralImages = spectrumService.CreateLogSpectrogram(audioSamples, SpectrogramConfig.Default); var concatenatedSpectralImages = new List<float[]>(); foreach (var spectralImage in spectralImages) { var concatenatedSpectralImage = ArrayUtils.ConcatenateDoubleDimensionalArray(spectralImage.Image); concatenatedSpectralImages.Add(concatenatedSpectralImage); } SpectralImageDao.InsertSpectralImages(concatenatedSpectralImages, trackReference); var readSpectralImages = SpectralImageDao.GetSpectralImagesByTrackId(trackReference); Assert.AreEqual(concatenatedSpectralImages.Count, readSpectralImages.Count); foreach (var readSpectralImage in readSpectralImages) { var expectedSpectralImage = concatenatedSpectralImages[readSpectralImage.OrderNumber]; for (int i = 0; i < expectedSpectralImage.Length; i++) { Assert.AreEqual( concatenatedSpectralImages[readSpectralImage.OrderNumber][i], expectedSpectralImage[i]); } } }
public IModelReference InsertTrack(TrackData track) { int id = PrepareStoredProcedure(SpInsertTrack) .WithParametersFromModel(track) .Execute() .AsScalar<int>(); return track.TrackReference = new ModelReference<int>(id); }
public void InsertTrackTest() { TrackData track = new TrackData("isrc", "artist", "title", "album", 1986, 200); var trackReference = ModelService.InsertTrack(track); AssertModelReferenceIsInitialized(trackReference); }
public TrackData QuaternionToTrackData(Quaternion q, TrackData trackData) { trackData.rx = FloatToInt(q.x, true); trackData.ry = FloatToInt(q.y, true); trackData.rz = FloatToInt(q.z, true); trackData.rw = FloatToInt(q.w, true); return trackData; }
/// <summary> /// /// </summary> /// <param name="track"></param> /// <param name="parent"></param> public TrayNotification(TrackData track, StoffiWindow parent) { ParentWindow = parent; InitializeComponent(); TrackArtist.Text = track.Artist; TrackTitle.Text = track.Title; AlbumArt.Source = Utilities.GetImageTag(track); }
public Quaternion TrackdataToQuaternion(TrackData trackData) { float x = (trackData.rx / 100f) - settings.worldOffset; float y = (trackData.ry / 100f) - settings.worldOffset; float z = (trackData.rz / 100f) - settings.worldOffset; float w = (trackData.rw / 100f) - settings.worldOffset; return new Quaternion(x, y, z,w); }
public void InsertTest() { TrackData track = new TrackData("isrc", "artist", "title", "album", 1986, 200); var trackReference = TrackDao.InsertTrack(track); var fingerprintReference = FingerprintDao.InsertFingerprint(new FingerprintData(GenericFingerprint, trackReference)); AssertModelReferenceIsInitialized(fingerprintReference); }
public void ReadTrackByTrackReferenceTest() { TrackData expectedTrack = new TrackData("isrc", "artist", "title", "album", 1986, 200); var trackReference = ModelService.InsertTrack(expectedTrack); var actualTrack = ModelService.ReadTrackByReference(trackReference); AssertTracksAreEqual(expectedTrack, actualTrack); }
public void InsertTest() { TrackData track = new TrackData("isrc", "artist", "title", "album", 1986, 200); var trackReference = TrackDao.InsertTrack(track); var subFingerprintReference = SubFingerprintDao.InsertSubFingerprint(GenericSignature, 123, 0.928, trackReference); AssertModelReferenceIsInitialized(subFingerprintReference); }
protected void AssertTracksAreEqual(TrackData expectedTrack, TrackData actualTrack) { Assert.AreEqual(expectedTrack.TrackReference, actualTrack.TrackReference); Assert.AreEqual(expectedTrack.Album, actualTrack.Album); Assert.AreEqual(expectedTrack.Artist, actualTrack.Artist); Assert.AreEqual(expectedTrack.Title, actualTrack.Title); Assert.AreEqual(expectedTrack.TrackLengthSec, actualTrack.TrackLengthSec); Assert.AreEqual(expectedTrack.ISRC, actualTrack.ISRC); Assert.AreEqual(expectedTrack.GroupId, actualTrack.GroupId); }
public void Print(TrackData data) { _consoleOut = new ConsoleOutput(data); _consoleOut.Divider(); _consoleOut.TrackHeader(); _consoleOut.MeanColour(); _consoleOut.ExaggeratedMeanColour(); _consoleOut.ModeColours(); _consoleOut.Divider(); }
public void InsertFingerprintTest() { var track = new TrackData("isrc", "artist", "title", "album", 1986, 200); var trackReference = modelService.InsertTrack(track); var fingerprint = new FingerprintData(GenericFingerprint(), trackReference); modelService.InsertFingerprint(fingerprint); AssertModelReferenceIsInitialized(fingerprint.FingerprintReference); }
public void ReadTest() { TrackData track = new TrackData("isrc", "artist", "title", "album", 1986, 200); var trackReference = TrackDao.InsertTrack(track); var subFingerprintReference = SubFingerprintDao.InsertSubFingerprint(GenericSignature, 123, 0.928, trackReference); SubFingerprintData actual = SubFingerprintDao.ReadSubFingerprint(subFingerprintReference); AsserSubFingerprintsAreEqual(new SubFingerprintData(GenericSignature, 123, 0.928, subFingerprintReference, trackReference), actual); }
public void ReadTrackByISRCTest() { const string ISRC = "isrc"; TrackData expectedTrack = new TrackData(ISRC, "artist", "title", "album", 1986, 200); ModelService.InsertTrack(expectedTrack); var actualTrack = ModelService.ReadTrackByISRC(ISRC); AssertTracksAreEqual(expectedTrack, actualTrack); }
public void MultipleFingerprintsInsertTest() { const int NumberOfFingerprints = 100; for (int i = 0; i < NumberOfFingerprints; i++) { var trackData = new TrackData("isrc" + i, "artist", "title", "album", 2012, 200); var trackReference = TrackDao.InsertTrack(trackData); var fingerprintReference = FingerprintDao.InsertFingerprint(new FingerprintData(GenericFingerprint, trackReference)); AssertModelReferenceIsInitialized(fingerprintReference); } }
public void ReadTrackByArtistAndTitleTest() { const string Artist = "artist"; const string Title = "title"; TrackData expectedTrack = new TrackData("isrc", Artist, Title, "album", 1986, 200); ModelService.InsertTrack(expectedTrack); var actualTracks = ModelService.ReadTrackByArtistAndTitleName(Artist, Title); Assert.IsTrue(actualTracks.Count == 1); AssertTracksAreEqual(expectedTrack, actualTracks[0]); }
public void InsertReadTest() { TrackData track = new TrackData("isrc", "artist", "title", "album", 1986, 200); var trackReference = TrackDao.InsertTrack(track); const int NumberOfHashBins = 100; var hashedFingerprints = Enumerable.Range(0, NumberOfHashBins).Select(i => new HashedFingerprint(GenericSignature, GenericHashBuckets, i, i * 0.928)); InsertHashedFingerprintsForTrack(hashedFingerprints, trackReference); var hashedFingerprintss = HashBinDao.ReadHashedFingerprintsByTrackReference(track.TrackReference); Assert.AreEqual(NumberOfHashBins, hashedFingerprintss.Count); }
public void ShouldInsertAllSubfingerprintsForTrack() { var hashedFingerprints = fcb.BuildFingerprintCommand() .From(PathToMp3) .UsingServices(this.audioService) .Hash() .Result; var track = new TrackData("isrc", "artist", "title", "album", 1986, 4d); var trackReference = modelService.InsertTrack(track); modelService.InsertHashDataForTrack(hashedFingerprints, trackReference); }
public void ReadByTrackGroupIdWorksAsExpectedTest() { TagInfo tagInfo = GetTagInfo(); TrackData firstTrack = new TrackData(tagInfo); TrackData secondTrack = new TrackData(tagInfo); var firstTrackReference = trackDao.InsertTrack(firstTrack); var secondTrackReference = trackDao.InsertTrack(secondTrack); var hashedFingerprintsForFirstTrack = fingerprintCommandBuilder .BuildFingerprintCommand() .From(GetAudioSamples()) .WithFingerprintConfig(config => { config.Clusters = new[] { "first-group-id" }; }).UsingServices(audioService) .Hash() .Result; InsertHashedFingerprintsForTrack(hashedFingerprintsForFirstTrack, firstTrackReference); var hashedFingerprintsForSecondTrack = fingerprintCommandBuilder .BuildFingerprintCommand() .From(GetAudioSamples()) .WithFingerprintConfig(config => { config.Clusters = new[] { "second-group-id" }; }).UsingServices(audioService) .Hash() .Result; InsertHashedFingerprintsForTrack(hashedFingerprintsForSecondTrack, secondTrackReference); const int ThresholdVotes = 25; foreach (var hashedFingerprint in hashedFingerprintsForFirstTrack) { var subFingerprintData = subFingerprintDao.ReadSubFingerprints( hashedFingerprint.HashBins, ThresholdVotes, new[] { "first-group-id" }).ToList(); Assert.AreEqual(1, subFingerprintData.Count); Assert.AreEqual(firstTrackReference, subFingerprintData[0].TrackReference); subFingerprintData = subFingerprintDao.ReadSubFingerprints( hashedFingerprint.HashBins, ThresholdVotes, new[] { "second-group-id" }).ToList(); Assert.AreEqual(1, subFingerprintData.Count); Assert.AreEqual(secondTrackReference, subFingerprintData[0].TrackReference); subFingerprintData = subFingerprintDao.ReadSubFingerprints(hashedFingerprint.HashBins, ThresholdVotes, Enumerable.Empty<string>()).ToList(); Assert.AreEqual(2, subFingerprintData.Count); } }
public void Intervaltimer_trackleftevent() { TrackData trackData1 = new TrackData("TEST1", 12000, 12000, 1000, "14322018", 10, 270, consoleOutput); string time = trackData1.TimeStamp; TrackLeftEvent TrackLeftEvent = new TrackLeftEvent(time, trackData1, true, consoleOutput, fileOutput); //Wait 6 seconds to check if isRaised flag has been set to False by the IntervalTimers Start and TimerElapsed function Thread.Sleep(6000); //Check if isRaised flag has been set to False Assert.That(() => TrackLeftEvent.isRaised.Equals(false)); }
/// <summary> /// Update the "Last Played" and "Play Count" information of a given track /// </summary> /// <param name="RefTrack">The track that was just played</param> public static void TrackWasPlayed(TrackData RefTrack) { if (RefTrack == null) { return; } uint pc = RefTrack.PlayCount + 1; foreach (TrackData track in SettingsManager.FileTracks) { if (track.Path == RefTrack.Path) { track.PlayCount = pc; track.LastPlayed = DateTime.Now; } } foreach (TrackData track in SettingsManager.QueueTracks) { if (track.Path == RefTrack.Path) { track.PlayCount = pc; track.LastPlayed = DateTime.Now; } } foreach (TrackData track in SettingsManager.HistoryTracks) { if (track.Path == RefTrack.Path) { track.PlayCount = pc; } } foreach (PlaylistData playlist in SettingsManager.Playlists) { if (playlist.Name == CurrentPlaylist) { foreach (TrackData track in playlist.Tracks) { if (track.Path == RefTrack.Path) { track.PlayCount = pc; track.LastPlayed = DateTime.Now; } } } } }
internal void Update(TrackData trackUpdate) { foreach (var camSetUpdate in trackUpdate.CameraSets) { //if (camSetUpdate.Key.Equals("set1") || camSetUpdate.Key.Equals("set2") || camSetUpdate.Key.Equals("setVR") || camSetUpdate.Key.Equals("pitlane")) //{ // continue; //} if (camSetUpdate.Key.Equals("setVR")) { continue; } var camSetVM = CameraSets.SingleOrDefault(x => x.CameraSetName == camSetUpdate.Key); if (camSetVM == null) { camSetVM = new CameraSetViewModel(camSetUpdate.Key); CameraSets.Add(camSetVM); } camSetVM.Update(camSetUpdate.Value); } // Now we check if we have to remove one of our cam sets var toRemove = new List <CameraSetViewModel>(); foreach (var camSetVM in CameraSets) { if (!trackUpdate.CameraSets.ContainsKey(camSetVM.CameraSetName)) { toRemove.Add(camSetVM); } } foreach (var item in toRemove) { CameraSets.Remove(item); } // The same (but 1d) for the HUD pages foreach (var hudPageCaption in trackUpdate.HUDPages) { var hudPageVM = HudPages.SingleOrDefault(x => x.Caption == hudPageCaption); if (hudPageVM == null) { hudPageVM = new HudPageViewModel(hudPageCaption); HudPages.Add(hudPageVM); } } }
public void DeleteHashBinsAndSubfingerprintsOnTrackDelete() { const int StaticStride = 5115; const int SecondsToProcess = 20; const int StartAtSecond = 30; TagInfo tagInfo = tagService.GetTagInfo(PathToMp3); int releaseYear = tagInfo.Year; TrackData track = new TrackData(tagInfo.ISRC, tagInfo.Artist, tagInfo.Title, tagInfo.Album, releaseYear, (int)tagInfo.Duration); int trackId = TrackDao.Insert(track); var hashData = fingerprintCommandBuilder .BuildFingerprintCommand() .From(PathToMp3, SecondsToProcess, StartAtSecond) .WithFingerprintConfig(config => { config.Stride = new IncrementalStaticStride(StaticStride, config.SamplesPerFingerprint); }) .Hash() .Result; List <long> subFingerprintIds = new List <long>(); foreach (var hash in hashData) { long subFingerprintId = SubFingerprintDao.Insert(hash.SubFingerprint, trackId); HashBinDao.Insert(hash.HashBins, subFingerprintId); subFingerprintIds.Add(subFingerprintId); } var actualTrack = TrackDao.ReadTrackByISRC(tagInfo.ISRC); Assert.IsNotNull(actualTrack); AssertTracksAreEqual(track, actualTrack); // Act int modifiedRows = TrackDao.DeleteTrack(trackId); Assert.IsNull(TrackDao.ReadTrackByISRC(tagInfo.ISRC)); foreach (var id in subFingerprintIds) { Assert.IsTrue(id != 0); Assert.IsNull(SubFingerprintDao.ReadById(id)); } for (int i = 1; i <= 25; i++) { Assert.IsTrue(HashBinDao.ReadHashBinsByHashTable(i).Count == 0); } Assert.AreEqual(1 + hashData.Count + (25 * hashData.Count), modifiedRows); }
/// <summary> /// Parses a JSON array into a list of tracks. /// </summary> /// <param name="json">The JSON data</param> /// <returns>A list of tracks</returns> private static ObservableCollection <TrackData> ParseTracks(JArray json) { ObservableCollection <TrackData> tracks = new ObservableCollection <TrackData>(); foreach (JObject o in json) { TrackData t = ParseTrack(o); if (t != null) { tracks.Add(t); } } return(tracks); }
public void HandleNewTrackData_TrackMoved1Zin1Sec_SpeedIsUpdatedTo0() { uut = new ATMclass(consoleOutput, fileOutput, airspace, transponderReceiver); string timestampOld = "20181109103800000"; string timestampNew = "20181109103801000"; //Timestamp 1 second later TrackData testTrack1 = new TrackData("ABC", 10000, 10000, 1000, timestampOld, 0, 0, consoleOutput); TrackData testTrack2 = new TrackData("ABC", 10000, 10000, 1001, timestampNew, 0, 0, consoleOutput); uut.HandleNewTrackData(testTrack1); uut.HandleNewTrackData(testTrack2); Assert.That(uut.CurrentTracks[0].CurrentHorzVel.Equals(0)); }
public void ReadFingerprintsByTrackReferenceTest() { TrackData track = new TrackData("isrc", "artist", "title", "album", 1986, 200); var trackReference = modelService.InsertTrack(track); FingerprintData fingerprint = new FingerprintData(GenericFingerprint(), trackReference); modelService.InsertFingerprint(fingerprint); var fingerprints = modelService.ReadFingerprintsByTrackReference(trackReference); Assert.AreEqual(1, fingerprints.Count); Assert.AreEqual(fingerprint.FingerprintReference, fingerprints[0].FingerprintReference); Assert.AreEqual(trackReference, fingerprints[0].TrackReference); CollectionAssert.AreEqual(GenericFingerprint(), fingerprints[0].Signature); }
public ResultEntry(TrackData track, double score, DateTime matchedAt, Coverage coverage) { Coverage = coverage; Track = track; QueryMatchStartsAt = Coverage.QueryMatchStartsAt; TrackCoverageWithPermittedGapsLength = Coverage.TrackCoverageWithPermittedGapsLength; DiscreteTrackCoverageLength = Coverage.TrackDiscreteCoverageLength; TrackMatchStartsAt = Coverage.TrackMatchStartsAt; Confidence = Coverage.Confidence; Score = score; TrackStartsAt = Coverage.TrackStartsAt; QueryLength = Coverage.QueryLength; MatchedAt = matchedAt; }
public LinkedDataModels AssignModelReferences(TrackInfo trackInfo, Hashes hashes) { var trackRef = trackReferenceProvider.Next(); var trackData = new TrackData(trackInfo.Id, trackInfo.Artist, trackInfo.Title, hashes.DurationInSeconds, trackRef, trackInfo.MetaFields, trackInfo.MediaType); var subFingerprints = hashes.Select(hash => { var subFingerprintReference = subFingerprintsReferenceProvider.Next(); return(new SubFingerprintData(hash.HashBins, hash.SequenceNumber, hash.StartsAt, subFingerprintReference, trackRef, hash.OriginalPoint)); }) .ToList(); return(new LinkedDataModels(trackData, subFingerprints)); }
public void CalculateSpeed_TrackMoved1X1Yin1Sec_Returns1p414() { //sqrt(3^2+3^2)=3 string timestampOld = "20181109103800000"; string timestampNew = "20181109103801000"; //Timestamp 1 second later TrackData testTrack1 = new TrackData("ABC", 10000, 10000, 1000, timestampOld, 0, 0, consoleOutput); TrackData testTrack2 = new TrackData("ABC", 10001, 10001, 1000, timestampNew, 0, 0, consoleOutput); double result = Math.Sqrt(Math.Pow(1, 2) + Math.Pow(1, 2)); Assert.That(uut.CalculateTrackSpeed(testTrack2, testTrack1).Equals(result)); }
public void ReadAllTracksTest() { TrackData firstTrack = new TrackData("first isrc", "artist", "title", "album", 2012, 200); TrackData secondTrack = new TrackData("second isrc", "artist", "title", "album", 2012, 200); TrackDao.Insert(firstTrack); TrackDao.Insert(secondTrack); IList <TrackData> tracks = TrackDao.ReadAll(); Assert.IsTrue(tracks.Count == 2); Assert.IsTrue(tracks.Any(track => track.ISRC == "first isrc")); Assert.IsTrue(tracks.Any(track => track.ISRC == "second isrc")); }
public void logging_logActiveSeparationEvent_Tag2IsSame() { TrackData trackData1 = new TrackData("ABC", 10000, 20000, 3000, timestamp, 100, 10); TrackData trackData2 = new TrackData("DEF", 10000, 20000, 3000, timestamp, 100, 10); List <TrackData> trackDatas = new List <TrackData> { trackData1, trackData2 }; SeperationEvent seperationEvent = new SeperationEvent(timestamp, trackDatas, true); uut.CheckForSeperationEvent(trackData1, trackData2); Assert.That(logger.ParametersList[0]._InvolvedTracks[1]._Tag.Equals(seperationEvent._InvolvedTracks[1]._Tag)); }
/// <summary> /// Duplicate the track data. /// </summary> /// <returns>Copy of the track data.</returns> public TrackData Duplicate() { TrackData t = new TrackData(); foreach (var c in Channels) { t.Channels.Add(c); } foreach (var p in Properties) { t.Properties.Add(p.Key, new TrackProperty(p.Value.Type, p.Value.Data)); } return(t); }
public TrackData GetProperties() { var data = new TrackData { Title = GetTitle(), AlbumTitle = GetAlbumTitle(), Artists = GetArtists(), Comment = GetComment(), Genre = GetGenre(), Picture = GetPicture(), Year = GetYear() }; return data; }
/// <summary> /// Select all event in a track /// </summary> /// <param name="trackData"></param> public void SelectTrack(TrackData trackData) { if (trackData == null) { return; } m_selectedObjects.Clear(); foreach (EventData eventData in trackData.Events) { m_selectedObjects.Add(eventData); } }
public ResultEntry(TrackData track, double confidence, double score, DateTime matchedAt, Coverage coverage) : this(track, confidence, score, matchedAt, coverage.QueryLength, coverage.QueryMatchStartsAt, coverage.CoverageWithPermittedGapsLength, coverage.DiscreteCoverageLength, coverage.TrackMatchStartsAt, coverage.TrackStartsAt) { Coverage = coverage; }
public override GTPoint GetGazeCoordinates(TrackData trackData, EyeEnum eye) { var row = new Matrix <double>(6, 1); var screenCoordinates = new Matrix <double>(2, 1); var gazedPoint = new GTPoint(); double X = 0; double Y = 0; try { switch (eye) { case EyeEnum.Left: X = trackData.PupilDataLeft.Center.X - trackData.GlintDataLeft.Glints.AverageCenter.X; Y = trackData.PupilDataLeft.Center.Y - trackData.GlintDataLeft.Glints.AverageCenter.Y; break; default: X = trackData.PupilDataRight.Center.X - trackData.GlintDataRight.Glints.AverageCenter.X; Y = trackData.PupilDataRight.Center.Y - trackData.GlintDataRight.Glints.AverageCenter.Y; break; } row[0, 0] = 1; row[1, 0] = X; row[2, 0] = Y; row[3, 0] = X * Y; row[4, 0] = X * X; row[5, 0] = Y * Y; if (eye == EyeEnum.Left) { gazedPoint.X = CvInvoke.cvDotProduct(row.Ptr, CalibrationDataLeft.CoeffsX.Ptr); gazedPoint.Y = CvInvoke.cvDotProduct(row.Ptr, CalibrationDataLeft.CoeffsY.Ptr); } else { gazedPoint.X = CvInvoke.cvDotProduct(row.Ptr, CalibrationDataRight.CoeffsX.Ptr); gazedPoint.Y = CvInvoke.cvDotProduct(row.Ptr, CalibrationDataRight.CoeffsY.Ptr); } } catch (Exception ex) { Console.Out.WriteLine("Calibration.cs, exception in GetGazeCoordinates(), message: " + ex.Message); } return(gazedPoint); }
public void ATMclass_HandleNewTrackDataNewTrackDataComesOutOfRange_CurrentTracksCountIs0() { //We need uut with a REAL airspace, not a FAKE for this test. uut = new ATMclass(logger, renderer, airspace); //Track data with coordinates inside airspace. TrackData trackData1 = new TrackData("ABC", xMin + 1, yMin + 1, zMin + 1, "180320180954", 200, 200); //Track data with same tag, butf coordinates outside airspace. TrackData trackData2 = new TrackData("ABC", xMin - 1, yMin - 1, zMin - 1, "180320180954", 200, 200); uut.HandleNewTrackData(trackData1); uut.HandleNewTrackData(trackData2); Assert.That(uut._currentTracks.Count.Equals(0)); }
public void UpdateFromNetwork(TrackData trackData, bool hasDelta) { this.trackData = trackData; if (trackData.broadcast != 1) { if (hasDelta) { position = GmUtil.TrackdataDeltaToVector3(trackData, position); } else { position = GmUtil.TrackdataToVector3(trackData); } } }
public void CollisionDetectorCollision() { TrackData dummyTrackData1 = new TrackData("X1", 10000, 10000, 5000, new DateTime()); TrackData dummyTrackData2 = new TrackData("X2", 11000, 11000, 5200, new DateTime()); List <TrackData> trackList = new List <TrackData> { dummyTrackData1, dummyTrackData2 }; List <String> tagList = new List <String> { dummyTrackData1.Tag, dummyTrackData2.Tag }; Tuple <List <string>, List <string> > uutTuple = uut.SeperationCheck(trackList); List <string> uutList = uutTuple.Item1; Assert.AreEqual(tagList, uutList); }
public void ATMclass_HandleNewTrackDataNewTrackDataComesOutOfRange_CurrentTracksCountIs0() { //We need uut with a REAL airspace, not a FAKE for this test. uut = new ATMclass(consoleOutput, fileOutput, airspace, transponderReceiver); //Track data with coordinates inside airspace. TrackData trackData1 = new TrackData("ABC", xMin + 1, yMin + 1, zMin + 1, "20181108102045200", 200, 200, consoleOutput); //Track data with same tag, butf coordinates outside airspace. TrackData trackData2 = new TrackData("ABC", xMin - 1, yMin - 1, zMin - 1, "20181108102045200", 200, 200, consoleOutput); uut.HandleNewTrackData(trackData1); uut.HandleNewTrackData(trackData2); Assert.That(uut.CurrentTracks.Count.Equals(0)); }
private List <TrackData> GetSampleTracks(int numberOfTracks) { var tracks = new List <TrackData>(); for (int i = 0; i < numberOfTracks; i++) { var track = new TrackData("isrc", "artist", "title", "album", 0, 0) { TrackReference = new ModelReference <int>(i) }; tracks.Add(track); } return(tracks); }
public void CheckForSeperationEvent_SeperationConditionsMetAndNoExistingEvent_EventIsCreated() { TrackData track1 = new TrackData("ABC", 30000, 30000, 1000, timestamp, 150, 50, consoleOutput); TrackData track2 = new TrackData("DEF", 30001, 30001, 1001, timestamp, 150, 50, consoleOutput); uut.AddTrack(track1); //track2 and this track will meet conditions for the seperation event //List of events is empty before checking Assert.That(uut.CurrentEvents.events.Count.Equals(0)); uut.CheckForSeperationEvents(track2); //Seperation event has been added Assert.That(uut.CurrentEvents.events.Count.Equals(1)); }
private void timerUpdate_Tick(object sender, EventArgs e) { if (ControlViews.Track.currentControl == ControlViews.TrackView) { if (track != null) { track = ControlViews.Main.trackHandler.Get(track.Key); setTrackInfo(track); } else { setTrackInfo(null); } } }
public void CalVelocity(TrackData track1, TrackData track2) { //Coordinates x1 = track1.X; x2 = track2.X; y1 = track1.Y; y2 = track2.Y; //Distance between the 2 tracks double distance = Math.Sqrt(Math.Pow(x1 - x2, 2) + Math.Pow(y1 - y2, 2)); double time = track2.Timestamp.Subtract(track1.Timestamp).TotalSeconds; track2.Velocity = distance / time; }
public void UpdateSeperationEventStatus_NewEventCreated_isRaisedIsTrue() { TrackData track1 = new TrackData("ABC", 30000, 30000, 1000, timestamp, 150, 50, consoleOutput); TrackData track2 = new TrackData("DEF", 50000, 50000, 5000, timestamp, 150, 50, consoleOutput); //Add tracks in order to have some data to update from uut.AddTrack(track1); uut.AddTrack(track2); //Add seperation event involving the 2 tracks already uut.CurrentEvents.AddSeperationEventFor(track1, track2, fileOutput); //Check that status is true before update Assert.That(uut.CurrentEvents.events[0].isRaised.Equals(true)); }
public void SameNumberOfHashBinsIsInsertedInAllTablesWhenFingerprintingEntireSongTest() { var track = new TrackData(string.Empty, "artist", "title", "album", 1986, 197d); var trackReference = trackDao.InsertTrack(track); var hashedFingerprints = HashFingerprintsForTrack(trackReference); var hashes = subFingerprintDao.ReadHashedFingerprintsByTrackReference(track.TrackReference); Assert.AreEqual(hashedFingerprints.Count, hashes.Count); foreach (var data in hashes) { Assert.AreEqual(25, data.HashBins.Length); } }
public TrackDTO LoadWorld(string name) { var trackPath = directoryHelper.GetTrackPath(name); XmlSerializer serializer = new XmlSerializer(typeof(TrackDTO)); TrackFileCompressor trackCompressor = new TrackFileCompressor(); TrackData decompressedTrackStreams = trackCompressor.DecompressPackage(trackPath); TrackDTO mapObject = (TrackDTO)serializer.Deserialize(new MemoryStream(decompressedTrackStreams.ObjectsData)); track.Terrain.terrainData.SetHeights(0, 0, terrainSerializer.DeserializeHeightMap(decompressedTrackStreams.HeightMapData, track.HeightMapSize)); track.Terrain.terrainData.SetAlphamaps(0, 0, terrainSerializer.DeserializeTextureMap(decompressedTrackStreams.TextureMapData, track.TextureMapSize)); return(mapObject); }
public void InsertHashDataTest() { TrackData expectedTrack = new TrackData("isrc", "artist", "title", "album", 1986, 200); var trackReference = modelService.InsertTrack(expectedTrack); var hashedFingerprints = new HashedFingerprint(GenericHashBuckets(), 1, 0.928f, Enumerable.Empty <string>()); modelService.InsertHashDataForTrack(new[] { hashedFingerprints }, trackReference); var subFingerprints = modelService.ReadSubFingerprints(GenericHashBuckets(), new DefaultQueryConfiguration()); Assert.AreEqual(1, subFingerprints.Count); Assert.AreEqual(trackReference, subFingerprints[0].TrackReference); Assert.AreNotEqual(0, subFingerprints[0].SubFingerprintReference.GetHashCode()); CollectionAssert.AreEqual(GenericHashBuckets(), subFingerprints[0].Hashes); }
/// <summary> /// Parses a JSON object into a track. /// </summary> /// <param name="json">The JSON data</param> /// <returns>A track</returns> private static TrackData ParseTrack(JObject json) { if (json == null) { return(null); } try { JObject user = (JObject)json["user"]; TrackData track = new TrackData(); track.Icon = "pack://application:,,,/Platform/Windows 7/GUI/Images/Icons/SoundCloud.ico"; track.Path = String.Format("{0}{1}", pathPrefix, json["id"]); track.Length = Convert.ToDouble((int)json["duration"]) / 1000.0; track.Genre = (string)json["genre"]; track.ArtURL = (string)json["artwork_url"]; track.URL = (string)json["permalink_url"]; track.IsActive = SettingsManager.CurrentTrack != null && SettingsManager.CurrentTrack.Path == track.Path; JToken token = json["release_year"]; if (token != null && token.Type != JTokenType.Null) { track.Year = (uint)token; } token = json["playback_count"]; if (token != null && token.Type != JTokenType.Null) { track.Views = (int)token; } string[] str = U.ParseTitle((string)json["title"]); track.Artist = str[0]; track.Title = str[1]; if (String.IsNullOrWhiteSpace(track.Artist) && user != null) { track.Artist = (string)user["username"]; } return(track); } catch (Exception e) { U.L(LogLevel.Warning, "SOUNDCLOUD", "Could not parse track JSON data: " + e.Message); return(null); } }
public void DeleteHashBinsAndSubfingerprintsOnTrackDelete() { const int StaticStride = 5115; const int SecondsToProcess = 20; const int StartAtSecond = 30; var tagInfo = GetTagInfo(); int releaseYear = tagInfo.Year; TrackData track = new TrackData(tagInfo.ISRC, tagInfo.Artist, tagInfo.Title, tagInfo.Album, releaseYear, (int)tagInfo.Duration); var trackReference = trackDao.InsertTrack(track); var hashData = fingerprintCommandBuilder .BuildFingerprintCommand() .From(PathToMp3, SecondsToProcess, StartAtSecond) .WithFingerprintConfig(config => { config.SpectrogramConfig.Stride = new IncrementalStaticStride(StaticStride, config.SamplesPerFingerprint); }) .UsingServices(audioService) .Hash() .Result; var subFingerprintReferences = new List <IModelReference>(); foreach (var hash in hashData) { var subFingerprintReference = subFingerprintDao.InsertSubFingerprint(hash.SubFingerprint, hash.SequenceNumber, hash.Timestamp, trackReference); hashBinDao.InsertHashBins(hash.HashBins, subFingerprintReference, trackReference); subFingerprintReferences.Add(subFingerprintReference); } var actualTrack = trackDao.ReadTrackByISRC(tagInfo.ISRC); Assert.IsNotNull(actualTrack); AssertTracksAreEqual(track, actualTrack); // Act int modifiedRows = trackDao.DeleteTrack(trackReference); Assert.IsNull(trackDao.ReadTrackByISRC(tagInfo.ISRC)); foreach (var id in subFingerprintReferences) { Assert.IsTrue(id.GetHashCode() != 0); Assert.IsNull(subFingerprintDao.ReadSubFingerprint(id)); } Assert.IsTrue(hashBinDao.ReadHashedFingerprintsByTrackReference(actualTrack.TrackReference).Count == 0); // Assert.AreEqual(1 + hashData.Count + (FingerprintConfiguration.Default.HashingConfig.NumberOfLSHTables * hashData.Count), modifiedRows); }