示例#1
0
        protected override Task <double> Frequency(double t, int n, int channel)
        {
            var isThisFeature = featureChooser.IsFeature(n, nameof(FeatureProbabilityModel.Frequency));

            if (!isThisFeature)
            {
                return(Task.FromResult(pulseFrequency.Quiescent));
            }
            var section = sectionsProvider.Section(n);

            var topFrequency = topFrequencyCache.GetOrAdd(section, CreateTopFrequency);
            var frequency    = featureProvider.FeatureValue(t, n, pulseFrequency.Quiescent, topFrequency);

            return(Task.FromResult(frequency));
        }
        // get a feature-dependent amplitude based on the time through the track
        public double FeatureValue(double t, int n, double min, double max)
        {
            if (sectionModel == null)
            {
                return(min);
            }

            double sectionLengthSeconds = sectionModel.TotalLength.TotalSeconds;
            int    section = sectionsProvider.Section(n);
            double ts      = t - (section * sectionModel.TotalLength.TotalSeconds); //time through the current section
            var    p       = GetTabletopParamsBySection(section, nameof(FeatureProbabilityModel.Wetness));
            var    a       = TabletopAlgorithm.GetY(ts, sectionLengthSeconds, min, max, p);

            return(a);
        }
示例#3
0
        private double Wetness(double t, int n)
        {
            if (wetness == null)
            {
                return(0);
            }

            if (sections == null)
            {
                return(wetness.Maximum);
            }

            // rise in a sin^2 fashion from MinWetness to MaxWetness
            var section = sectionsProvider.Section(n);

            var maxForSection = maxWetnessForSectionCache.GetOrAdd(section, s =>
            {
                var numSections = sectionsProvider.NumSections();
                var progression = (double)s / Math.Max(1, numSections - 1); // <= 1
                var max         = randomizer.ProportionAlong(wetness.Variation, progression,
                                                             wetness.Minimum, wetness.Maximum);
                return(max);
            });

            double value;

            if (wetness.LinkToFeature)
            {
                var isThisFeature = featureChooser.IsFeature(n, nameof(FeatureProbabilityModel.Wetness));
                value = isThisFeature ?
                        featureProvider.FeatureValue(t, n, wetness.Minimum, maxForSection)
                    : wetness.Minimum;
            }
            else
            {
                value = maxForSection;
            }

            return(value);
        }