Esempio n. 1
0
        public ISignal GetFiltered(ISignal signal, int c, int size)
        {
            var start = Math.Max(c - size / 2 - (size % 2), 0);

            size = Math.Min(size, signal.GetLength() - start);

            //return new FilteredSignal(signal, ind => (ind < start || ind >= start + window) ? 0 : 1);
            return(new WindowedSignal(signal, start, size));
        }
Esempio n. 2
0
        public override IEnumerable <double> GetValues()
        {
            var skipSignal = signal.GetValues().Skip(Start % signal.GetLength());

            for (var rest = Duration; rest > 0; rest--)
            {
                yield return(skipSignal.First());

                skipSignal = (skipSignal.Any()) ? skipSignal.Skip(1) : signal.GetValues();
            }
        }
Esempio n. 3
0
        public Complex CalcFreq(ISignal signal, double w)
        {
            var mc = Complex.Zero;
            var i  = 0;

            foreach (var val in signal.GetValues())
            {
                mc += Complex.FromPolarCoordinates(val, -i * w * 2 * Math.PI / signal.GetLength());
                i++;
                //Logger.DEFLOG.WriteLog(String.Format("val: {0};", val));
            }
            //Logger.DEFLOG.Flush();

            return(mc);
        }
Esempio n. 4
0
        public Spectrum Transform(WindowedTransformStuff stuff, ISignal signal, IWindowFilter filter)
        {
            var times = signal.GetLength() / stuff.WinStep - 1;
            var spec  = new Spectrum(stuff.CountFreq, times, signal.GetActualLength());

            //var log = new Logger("windowed_transform.log");
            //log.WriteLog(String.Format("Times: {0}", times));
            //log.Flush();

            var c = 128;

            for (var i = 0; i < times; i++)
            {
                var tr = Transform(stuff, filter.GetFiltered(signal, c, stuff.WinSize)).GetFreqsAtTime(0);
                spec.SetAtTime(i, tr);

                c += stuff.WinStep;
            }

            return(spec);
        }
Esempio n. 5
0
 public override int GetLength()
 {
     return(origin.GetLength());
 }