public static AudioFileSearchCollection GetBestSearchCollection(AudioLibrary audioLibrary, AODLoadSheetRow lsr)
        {
            if (lsr.OriginalSearchStrategy != lsr.Tokens.SearchStrategy)
            {
                lsr.Tokens.SetOriginalSearchStrategy();
            }

            AudioFileSearchCollection collection_1      = GetSearchCollection(audioLibrary, lsr); //SearchStrategyType defined by loadsheet (Original Search Strategy)
            AudioFileOption           candidateOption_1 = collection_1.BestOption;

            if (collection_1.IsOptionQuickSearchElligible(candidateOption_1, SearchMethodType.Both, Globals.AccurateThreshold))  //[Prefered result]  Accurate scoring and not too many options in final pool (skip alternative strategy search for performance)
            {
                return(collection_1);
            }

            if (lsr.Tokens.SearchStrategy == SearchStrategyType.CD)
            {
                lsr.Tokens.ConfigureSearchStrategy_OTHER(true);
            }
            else if (lsr.Tokens.SearchStrategy == SearchStrategyType.OTHER)
            {
                lsr.Tokens.ConfigureSearchStrategy_CD(true);
            }

            AudioFileSearchCollection collection_2      = GetSearchCollection(audioLibrary, lsr); //Alternative SearchStrategyType if needed
            AudioFileOption           candidateOption_2 = collection_2.BestOption;

            SuggestedAudioFile suggestedOption_1 = new SuggestedAudioFile(collection_1);
            SuggestedAudioFile suggestedOption_2 = new SuggestedAudioFile(collection_2);

            if (suggestedOption_1.AccuracyType == AccuracyType.Accurate && suggestedOption_2.AccuracyType != AccuracyType.Accurate)
            {
                if (suggestedOption_1.AccuracyScore >= suggestedOption_2.AccuracyScore)
                {
                    lsr.Tokens.SetOriginalSearchStrategy();

                    return(collection_1);
                }
            }

            if (suggestedOption_1.AccuracyType != AccuracyType.Accurate && suggestedOption_2.AccuracyType == AccuracyType.Accurate)
            {
                if (suggestedOption_1.AccuracyScore <= suggestedOption_2.AccuracyScore)
                {
                    return(collection_2);
                }
            }

            //Suggested Files (1 and 2) are either both accurate, or both inaccurate
            if (suggestedOption_1.AccuracyScore >= (suggestedOption_2.AccuracyScore - Globals.SearchStrategySwitchThreshold))  //Preference is given to the original search strategy
            {
                lsr.Tokens.SetOriginalSearchStrategy();

                return(collection_1);
            }
            else
            {
                return(collection_2);
            }
        }
        public void PrepareManualOptionsList(AudioFileOption bestOption)
        {
            _AudioFileOptions = _AudioFileOptions.OrderByDescending(option => option.GetTotalPoints()).ToList();  //Order by total points

            if (_AudioFileOptions.Count > Globals.ManualOptionsListSize)
            {
                _AudioFileOptions = _AudioFileOptions.Take(Globals.ManualOptionsListSize).ToList();               //Cut list down to top 10 (total points)
            }

            if (!_AudioFileOptions.Contains(bestOption))
            {
                _AudioFileOptions.Insert(0, bestOption);      //add bestOption to front of list
            }
            else  //It does contain bestOption
            {
                if (_AudioFileOptions.First() != bestOption)  //if bestOption is not at the beginning of the list
                {
                    _AudioFileOptions.Remove(bestOption);     //remove best option from wherever in the list it currently is

                    _AudioFileOptions.Insert(0, bestOption);  //add bestOption to front of list
                }
            }

            if (_AudioFileOptions.Count > Globals.ManualOptionsListSize)
            {
                _AudioFileOptions = _AudioFileOptions.Take(Globals.ManualOptionsListSize).ToList();  //Confirm we only have 10 manual options
            }

            RefreshStatistics();
        }
        public void ShrinkOptionsListForPrinting(AudioFileOption bestOption)
        {
            ShrinkOptionsListForPrinting();

            if (!_AudioFileOptions.Any(option => option.LibraryFile.FullPath == bestOption.LibraryFile.FullPath))
            {
                _AudioFileOptions.Insert(0, bestOption);                 //add bestOption to front of list

                _AudioFileOptions.RemoveAt(_AudioFileOptions.Count - 1); //remove last option
            }
        }
        public void AddAudioFileOption(AudioFileOption newOption)
        {
            //If less than minimum search filter size, add to it and return
            if (_AudioFileOptions.Count < Globals.MinimumSearchFilterSize)
            {
                _AudioFileOptions.Add(newOption);

                _AudioFileOptions = _AudioFileOptions.OrderByDescending(option => option.GetTotalPoints()).ToList();

                UpdateStatistics(newOption);

                return;
            }

            int newOptionTotalPoints = newOption.GetTotalPoints();
            int lowestTotalPoints    = _AudioFileOptions.Last().GetTotalPoints();

            //The search filter is full, so only add if the option scores equal or better than the worst option
            if (newOptionTotalPoints >= lowestTotalPoints)
            {
                _AudioFileOptions.Add(newOption);             //add new option to end of list

                if (newOptionTotalPoints > lowestTotalPoints) //the list needs to be sorted again
                {
                    _AudioFileOptions = _AudioFileOptions.OrderByDescending(option => option.GetTotalPoints()).ToList();

                    int lowestPointsToKeep = _AudioFileOptions[Globals.MinimumSearchFilterSize - 1].GetTotalPoints();

                    if (lowestPointsToKeep > lowestTotalPoints)  //we need to trim out the worst options
                    {
                        _AudioFileOptions = _AudioFileOptions.Where(option => option.GetTotalPoints() >= lowestPointsToKeep).ToList();

                        RefreshStatistics();  //Full refresh of stats
                    }
                    else
                    {
                        UpdateStatistics(newOption);  //No options were removed, so just update the stats with the new option added
                    }
                }
                else
                {
                    UpdateStatistics(newOption);  //No options were removed, so just update the stats with the new option added
                }
            }
        }
        private static AudioFileOptions Track_Pass1(AudioLibrary audioLibrary, TokensCollection tokens)
        {
            //Backwards Search
            AudioFileOptions pass1 = new AudioFileOptions();

            foreach (AudioLibraryFile file in audioLibrary.GetAudioLibraryFiles)
            {
                AudioFileOption newOption = new AudioFileOption(file, tokens);

                newOption.ScoreTrackNumberTrackPoints(SearchMethodType.Backwards);

                pass1.AddAudioFileOption(newOption);
            }

            pass1.KeepBetterOptions();

            return(pass1);
        }
        private static AudioFileOptions ArtistAlbum_Pass1(AudioLibrary audioLibrary, TokensCollection tokens)
        {
            //Forwards Search
            AudioFileOptions pass1 = new AudioFileOptions();

            foreach (AudioLibraryFile file in audioLibrary.GetAudioLibraryFiles)
            {
                AudioFileOption newOption = new AudioFileOption(file, tokens);

                newOption.ScoreArtistAlbumPoints();

                pass1.AddAudioFileOption(newOption);
            }

            pass1.KeepBetterOptions();

            return(pass1);
        }
Exemple #7
0
        public void AssignBestOptionFromManualOptions(AudioFileOption bestOption)
        {
            _ForwardsPass1          = null;
            _ForwardsPass2          = null;
            _ForwardsFinalPass      = null;
            _ForwardsFinalPassCount = 0;

            _BackwardsPass1          = null;
            _BackwardsPass2          = null;
            _BackwardsFinalPass      = null;
            _BackwardsFinalPassCount = 0;

            _BestOption    = bestOption;
            _WinningMethod = SearchMethodType.Manual;

            _IsUsingManualOptions = true;

            _IsCollectionFinished = true;
        }
        public void AssignSuggestedAudioFileFromManualApproval(AudioFileOption bestOption)
        {
            if (_SearchCollection != null)
            {
                _SearchCollection.AssignBestOptionFromManualOptions(bestOption);

                AssignSuggestedAudioFile();

                _IsApproved = true;

                _SuggestedAudioFile.AccuracyNote = Globals.WasApprovedNote;
            }
            else
            {
                ConsolePrintHelpers.PrintRedText("\n\n  ERROR  Trying To Assign Suggested Audio File With Null Search Collection at LSR #:  ");
                ConsolePrintHelpers.PrintWhiteText((_LoadSheetRowNumber + 1).ToString());
                ConsolePrintHelpers.PressAnyKeyToExit();
            }
        }
        private void UpdateStatistics(AudioFileOption option)
        {
            if (option.AccuracyScore > _BestAccuracyScore)
            {
                _BestAccuracyScore = option.AccuracyScore;
            }

            if (option.GetTotalPoints() > _BestTotalPoints)
            {
                _BestTotalPoints = option.GetTotalPoints();
            }

            if (option.ArtistAlbumPoints > _BestArtistAlbumPoints)
            {
                _BestArtistAlbumPoints = option.ArtistAlbumPoints;
            }

            if (option.TrackPoints > _BestTrackPoints)
            {
                _BestTrackPoints = option.TrackPoints;
            }
        }
        private static AudioFileSearchCollection GetSearchCollection(AudioLibrary audioLibrary, AODLoadSheetRow lsr)
        {
            AudioFileSearchCollection searchCollection = new AudioFileSearchCollection(lsr);

            searchCollection = ForwardsSearch(searchCollection, audioLibrary, lsr.Tokens);
            AudioFileOption candidateOption_1 = searchCollection.ForwardsFinalPass.GetCandidateOption();

            searchCollection = BackwardsSearch(searchCollection, audioLibrary, lsr.Tokens);
            AudioFileOption candidateOption_2 = searchCollection.BackwardsFinalPass.GetCandidateOption();

            int bestCandidateOption = ChooseBestCandidateOption(candidateOption_1, candidateOption_2);

            if (bestCandidateOption == 1) //CandidateOption_1
            {
                searchCollection.FinishCollection(SearchMethodType.Forwards);
                return(searchCollection);
            }
            else //CandidateOption_2
            {
                searchCollection.FinishCollection(SearchMethodType.Backwards);
                return(searchCollection);
            }
        }
Exemple #11
0
        public bool IsOptionQuickSearchElligible(AudioFileOption candidateOption, SearchMethodType method, int accuracyThreshold)
        {
            if (!_IsCollectionFinished)
            {
                if (method == SearchMethodType.Forwards)
                {
                    _ChosenFinalPassCount = _ForwardsFinalPassCount;
                }

                if (method == SearchMethodType.Backwards)
                {
                    _ChosenFinalPassCount = _BackwardsFinalPassCount;
                }

                _BestOption = candidateOption;
            }

            if (candidateOption.AccuracyScore < accuracyThreshold)
            {
                return(false);
            }

            if (_ChosenFinalPassCount > 1)
            {
                return(false);
            }

            SuggestedAudioFile suggestedFile = new SuggestedAudioFile(this);

            if (suggestedFile.AccuracyType != AccuracyType.Accurate)  //SafetyNetChecks() in SuggestedAudioFile could mark it as 'Questionable'
            {
                return(false);
            }

            return(true);
        }
Exemple #12
0
 public void PrintManualOptionsConfirmation(AudioFileOption optionToConfirm, ManualSelectionType type, bool printSkipChoices)
 {
     _ManualOptions.PrintManualOptions(optionToConfirm, type, printSkipChoices);
 }
        public bool IsHistoricallyApproved(ApprovedLoadSheetRow approvedLSR)
        {
            //Same LSRHash Approval----------------------------------------------------------------
            if (_LoadSheetRowHash == approvedLSR.LoadSheetRowHash)
            {
                AudioFileOption manualOption = _SearchCollection.CheckManualOptions(approvedLSR);

                if (manualOption != null)
                {
                    AssignSuggestedAudioFileFromManualApproval(manualOption);

                    return(true);
                }
            }

            //Same Source File Approval------------------------------------------------------------
            if (_SuggestedAudioFile.FullPath != approvedLSR.SourceFilePath)
            {
                return(false);
            }

            if (_SuggestedAudioFile.FullPath.Length < Globals.MaxPathLenth)
            {
                if (_SuggestedAudioFile.ModifiedDate != approvedLSR.SourceFileModifiedDate)
                {
                    return(false);
                }

                if (_SuggestedAudioFile.FileSize != approvedLSR.SourceFileSize)
                {
                    return(false);
                }
            }

            if (_LoadSheetRowHash == approvedLSR.LoadSheetRowHash)
            {
                return(true);  //Matching identical hashes is a valid re-approval
            }

            if (_SuggestedAudioFile.AccuracyScore < approvedLSR.AccuracyScore)
            {
                return(false);
            }

            if (_SuggestedAudioFile.TotalPoints < approvedLSR.TotalPoints)
            {
                return(false);
            }

            if (_SuggestedAudioFile.IsPossiblyWrongCycle)
            {
                return(false);
            }

            if (_SuggestedAudioFile.AccuracyType == AccuracyType.HighRisk)
            {
                return(false);
            }

            if (approvedLSR.AccuracyType == AccuracyType.HighRisk)
            {
                return(false);
            }

            if (approvedLSR.LoadSheetRowHash.Contains(_TrackNumberTrackHash))
            {
                return(true);  //If LSR hashes are not identical, it can be re-approved with same or better accuracy scores and total points and the same _TrackNumberTrackHash, as long as it does not think it is from the wrong cycle or is a 'High Risk' Accuracy type
            }

            return(false);  //Matching source file, but no other qualities we are looking for match what we want
        }
        private static int ChooseBestCandidateOption(AudioFileOption candidateOption_1, AudioFileOption candidateOption_2)
        {
            if (candidateOption_1.AccuracyScore >= candidateOption_2.AccuracyScore && candidateOption_1.GetTotalPoints() >= candidateOption_2.GetTotalPoints())
            {
                if (candidateOption_1.ArtistAlbumPoints > 0 && candidateOption_1.TrackPoints > 0)
                {
                    return(1);
                }
            }

            if (candidateOption_2.AccuracyScore >= candidateOption_1.AccuracyScore && candidateOption_2.GetTotalPoints() >= candidateOption_1.GetTotalPoints())
            {
                if (candidateOption_2.ArtistAlbumPoints > 0 && candidateOption_2.TrackPoints > 0)
                {
                    return(2);
                }
            }

            if (candidateOption_1.AccuracyScore >= candidateOption_2.AccuracyScore && candidateOption_1.GetTotalPoints() >= candidateOption_2.GetTotalPoints())
            {
                return(1);
            }

            if (candidateOption_2.AccuracyScore >= candidateOption_1.AccuracyScore && candidateOption_2.GetTotalPoints() >= candidateOption_1.GetTotalPoints())
            {
                return(2);
            }

            //Candidate options have opposing accuracy scores and total points
            int accuracyScoreDiff = Math.Abs(candidateOption_1.AccuracyScore - candidateOption_2.AccuracyScore);

            int totalPointsDiff = Math.Abs(candidateOption_1.GetTotalPoints() - candidateOption_2.GetTotalPoints());

            if (accuracyScoreDiff >= totalPointsDiff) //Better to go with higher accuracy score
            {
                if (candidateOption_1.AccuracyScore >= candidateOption_2.AccuracyScore)
                {
                    if (candidateOption_1.ArtistAlbumPoints > 0 && candidateOption_1.TrackPoints > 0)
                    {
                        return(1);
                    }
                    else if (candidateOption_2.ArtistAlbumPoints > 0 && candidateOption_2.TrackPoints > 0)
                    {
                        return(2);
                    }
                    else
                    {
                        return(1);
                    }
                }
                else
                {
                    if (candidateOption_2.ArtistAlbumPoints > 0 && candidateOption_2.TrackPoints > 0)
                    {
                        return(2);
                    }
                    else if (candidateOption_1.ArtistAlbumPoints > 0 && candidateOption_1.TrackPoints > 0)
                    {
                        return(1);
                    }
                    else
                    {
                        return(2);
                    }
                }
            }
            else  //better to go with more total points
            {
                if (candidateOption_1.GetTotalPoints() >= candidateOption_2.GetTotalPoints())
                {
                    if (candidateOption_1.ArtistAlbumPoints > 0 && candidateOption_1.TrackPoints > 0)
                    {
                        return(1);
                    }
                    else if (candidateOption_2.ArtistAlbumPoints > 0 && candidateOption_2.TrackPoints > 0)
                    {
                        return(2);
                    }
                    else
                    {
                        return(1);
                    }
                }
                else
                {
                    if (candidateOption_2.ArtistAlbumPoints > 0 && candidateOption_2.TrackPoints > 0)
                    {
                        return(2);
                    }
                    else if (candidateOption_1.ArtistAlbumPoints > 0 && candidateOption_1.TrackPoints > 0)
                    {
                        return(1);
                    }
                    else
                    {
                        return(2);
                    }
                }
            }
        }