Exemple #1
0
        public void SetResults(IEnumerable <Biofeedback.Sample> value, IReverseLookup lookup)
        {
            resultsList.Items.Clear();

            results = value.
                      Where(s => s.response >= Threshold).
                      OrderByDescending(s => s.response).
                      Take(MaxCount).ToArray();

            foreach (var r in results)
            {
                var threshold = 0.0125;

                var results = lookup.Search(r.frequency * (1.0 - threshold), r.frequency * (1.0 + threshold), 0, 0);

                var e = results.GetEnumerator();
                if (e.MoveNext())
                {
                    var item = new ListViewItem(new string[] { r.frequency.ToString(), $"{r.response:0.00}", e.Current });
                    resultsList.Items.Add(item);
                    while (e.MoveNext())
                    {
                        item = new ListViewItem(new string[] { "", "", e.Current });
                        resultsList.Items.Add(item);
                    }
                }
                else
                {
                    var item = new ListViewItem(new string[] { r.frequency.ToString(), r.response.ToString(), "" });
                    resultsList.Items.Add(item);
                }
            }
        }
Exemple #2
0
 public static IEnumerable <string> Search(this IReverseLookup lookup, double min, double max, int minOctave, int maxOctave)
 {
     return(Enumerable.
            Range(minOctave, maxOctave - minOctave + 1).
            Select(octave => Math.Pow(2.0, octave)).
            SelectMany(m => lookup.Search(m * min, m * max)).
            OrderBy(s => s));
 }