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 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); }