This commit is contained in:
2026-04-17 14:55:32 -04:00
commit bc3ac1d4c9
18017 changed files with 4371742 additions and 0 deletions

View File

@@ -0,0 +1,82 @@
using DTS.Common.Enums.Hardware;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace DTS.Common.Classes.DSP
{
public class StreamingFilterProfile : IStreamingFilterProfile
{
public double Ratio { get; set; }
public string DisplayString { get; set; }
public string DescriptionString { get; set; }
public int EnumValue { get; set; }
private readonly List<DASRestriction> _restrictions = new List<DASRestriction>();
public DASRestriction[] Restrictions { get => _restrictions.ToArray(); set { _restrictions.Clear(); _restrictions.AddRange(value); } }
public StreamingFilterProfile() { }
public StreamingFilterProfile(StreamingFilterProfileCollection.DefaultProfiles profile, DASRestriction[] restrictions)
{
GetProfileValues(profile, out var displayName, out var description, out var enumValue, out var ratio);
Initialize(displayName, description, enumValue, ratio, restrictions);
}
public StreamingFilterProfile(string display, string description, int enumValue, double ratio, DASRestriction[] restrictions)
{
Initialize(display, description, enumValue, ratio, restrictions);
}
private void Initialize(string display, string description, int enumValue, double ratio, DASRestriction[] restrictions)
{
DisplayString = display;
DescriptionString = description;
EnumValue = enumValue;
Restrictions = restrictions;
Ratio = ratio;
}
public override string ToString()
{
return DisplayString;
}
public static void GetProfileValues(StreamingFilterProfileCollection.DefaultProfiles profile, out string displayName, out string description, out int enumValue,
out double ratio)
{
displayName = string.Empty;
description = string.Empty;
enumValue = -1;
ratio = -1;
var enumType = typeof(StreamingFilterProfileCollection.DefaultProfiles);
var memberInfos = enumType.GetMember(profile.ToString());
var enumValueMemberInfo = Array.Find(memberInfos, m => m.DeclaringType == enumType);
var valueAttributes = enumValueMemberInfo.GetCustomAttributes(typeof(DisplayAttribute), false);
enumValue = (int)profile;
description = ((DisplayAttribute)valueAttributes[0]).GetDescription();
displayName = ((DisplayAttribute)valueAttributes[0]).GetName();
valueAttributes = enumValueMemberInfo.GetCustomAttributes(typeof(ScalerAttribute), false);
ratio = ((ScalerAttribute)valueAttributes[0]).Scaler;
}
public double GetDSPFilterRate(double sps, string hwType)
{
//if we have legacy then we need the sample rate, if it's >8k s6abr then Fc
if (hwType == HardwareTypes.SLICE6_AIR.ToString() && sps >= DSPFilterType.S6A_CAP) { return double.NaN; }
if (!Array.Exists(Restrictions, x => x.DASType == hwType || string.IsNullOrEmpty(x.DASType))) { return double.NaN; }
if (EnumValue == StreamingFilterProfileCollection.DEFAULT_VALUE)
{
return DSPFilterType.GetLegacytDSPFilterRate(sps, hwType);
}
else if (double.IsNaN(Ratio)) { return double.NaN; }
var array = DSPFilterType.Get6PButterWorthLegacyTable();
Array.Sort(array, (x, y) => { return y.Item1.CompareTo(x.Item1); });
foreach (var entry in array)
{
if (sps >= entry.Item1) { return sps / Ratio; }
}
return double.NaN;
}
}
}