コード例 #1
0
 public static unsafe void GetReflectionData <TAudioKernel, TParameters, TProviders>(
     out void *jobReflectionData, out ParameterDescriptionData parameterDescriptionData)
     where TAudioKernel : struct, IAudioKernel <TParameters, TProviders>
     where TParameters  : unmanaged, Enum
     where TProviders   : unmanaged, Enum
 {
     AudioKernelJobStructProduce <TAudioKernel, TParameters, TProviders> .Initialize(
         out jobReflectionData, out parameterDescriptionData, out SampleProviderDescriptionData ignored);
 }
コード例 #2
0
            static ParameterDescriptionData CreateParameterDescription()
            {
                var pType = typeof(TParameters);

                if (!pType.IsEnum)
                {
                    throw new ArgumentException("CreateDSPNode<Parameters, Providers, T> must have Parameters as an enum.");
                }

                var pValues = Enum.GetValues(pType);

                for (var i = 0; i < pValues.Length; i++)
                {
                    if ((int)pValues.GetValue(i) != i)
                    {
                        throw new ArgumentException("CreateDSPNode<Parameters, Providers, T> enum values must start at 0 and be consecutive");
                    }
                }

                var paramsDescriptions = Utility.AllocateUnsafe <DSPParameterDescription>(pValues.Length, Allocator.Persistent, true);

                for (var i = 0; i < pValues.Length; i++)
                {
                    paramsDescriptions[i].Min          = float.MinValue;
                    paramsDescriptions[i].Max          = float.MaxValue;
                    paramsDescriptions[i].DefaultValue = 0.0f;
                    var field = pType.GetField(Enum.GetName(pType, pValues.GetValue(i)));

                    var rangeAttr = (ParameterRangeAttribute)Attribute.GetCustomAttribute(field, typeof(ParameterRangeAttribute));
                    if (rangeAttr != null)
                    {
                        paramsDescriptions[i].Min = rangeAttr.Min;
                        paramsDescriptions[i].Max = rangeAttr.Max;
                    }

                    var defValAttr = (ParameterDefaultAttribute)Attribute.GetCustomAttribute(field, typeof(ParameterDefaultAttribute));
                    if (defValAttr != null)
                    {
                        paramsDescriptions[i].DefaultValue = defValAttr.DefaultValue;
                    }
                }

                var data = new ParameterDescriptionData
                {
                    Descriptions   = paramsDescriptions,
                    ParameterCount = pValues.Length
                };

                return(data);
            }
コード例 #3
0
            public static void Initialize(
                out void *jobReflectionData, out ParameterDescriptionData parameterDescriptionData,
                out SampleProviderDescriptionData sampleProviderDescriptionData)
            {
                if (s_JobReflectionData == null)
                {
                    s_JobReflectionData = (void *)JobsUtility.CreateJobReflectionData(typeof(TAudioKernel), JobType.Single, (ExecuteKernelFunction)Execute);
                }

                if (s_ParameterDescriptionData.Descriptions == null)
                {
                    s_ParameterDescriptionData = CreateParameterDescription();
                }

                if (s_SampleProviderDescriptionData.Descriptions == null)
                {
                    s_SampleProviderDescriptionData = CreateSampleProviderDescription();
                }

                jobReflectionData             = s_JobReflectionData;
                parameterDescriptionData      = s_ParameterDescriptionData;
                sampleProviderDescriptionData = s_SampleProviderDescriptionData;
            }