コード例 #1
0
        public MetricFFT(Graph graph) : base("FFT", graph)
        {
            _portOut = new NodeSystemLib2.FormatDataFFT.OutputPortDataFFT(this, "out");
            _portInp = new NodeSystemLib2.FormatData1D.InputPortData1D(this, "in");

            _portInp.SamplerateChanged += (s, e) => _portOut.Samplerate = _portInp.Samplerate;

            _attrFFTSize = new NodeSystemLib2.Generic.NodeAttributes.AttributeValueInt(this, "FFT Size", "Samples",
                                                                                       (x) => x < 2 ? 2 : (int)Math.Pow(2, Math.Round(Math.Log(x, 2)))
                                                                                       );
            _attrFFTSize.SetRuntimeReadonly();
            _attrFFTSize.Changed += (s, e) => _portOut.FFTSize = _attrFFTSize.TypedGet();
            _attrFFTSize.Set(512);
        }
コード例 #2
0
        public DeviceSimulatorPort(Graph g, int portId) : base("Simulator Port", g, UniquenessBy(portId))
        {
            Id = portId;

            _portOut = new OutputPortData1D(this, "Out");

            _attrFrequency  = new NodeSystemLib2.Generic.NodeAttributes.AttributeValueDouble(this, "Frequency", "Hz");
            _attrAmplitude  = new NodeSystemLib2.Generic.NodeAttributes.AttributeValueDouble(this, "Amplitude");
            _attrSamplerate = new NodeSystemLib2.Generic.NodeAttributes.AttributeValueInt(this, "Samplerate", "Hz");
            _attrSignalType = new NodeSystemLib2.Generic.NodeAttributes.AttributeValueEnum <SignalType>(this, "Type");
            _attrPeriod     = new NodeSystemLib2.Generic.NodeAttributes.AttributeValueInt(this, "Period", "ms");
            _attrPhase      = new NodeSystemLib2.Generic.NodeAttributes.AttributeValueDouble(this, "Phase", "°");

            _attrFrequency.Changed  += (s, e) => CalculatePhaseStep();
            _attrSamplerate.Changed += (s, e) => _portOut.Samplerate = _attrSamplerate.TypedGet();

            _attrSamplerate.SetRuntimeReadonly();
            _attrPeriod.SetRuntimeReadonly();

            _attrFrequency.Set(100000);
            _attrAmplitude.Set(1);
            _attrPeriod.Set(100);
            _attrSamplerate.Set(1000000);
        }