예제 #1
0
        private void ProcessStream1D(NodeSystemLib2.FormatData1D.InputPortData1D port)
        {
            var _buffer = port.Read();

            WriterObject   writer = null;
            Stream1DWriter stream = null;

            if (_recording)
            {
                writer = _writers[port];
                stream = (Stream1DWriter)writer.Writer;
            }

            foreach (var sample in _buffer.ZipWithValueInput(_portEn))
            {
                if (sample.Scalar >= 0.5 && !_recording)
                {
                    _firstWrittenSampleTime = sample.Stamp;
                    StartRecording();

                    writer = _writers[port];
                    stream = (Stream1DWriter)writer.Writer;
                }
                else if (sample.Scalar < 0.5 && _recording)
                {
                    EndRecording();
                }

                if (_recording)
                {
                    stream.WriteSample(sample.Sample);
                    writer.SetNewStamp(sample.Stamp);
                }
            }
        }
예제 #2
0
        public override void Process()
        {
            var buffer = _portIn.Read();
            var sum    = buffer.Data.Take(buffer.Available).Sum();

            TotalSum += sum;
        }
예제 #3
0
        public override void Process()
        {
            var fftsToRead       = Math.Min(_portInp.BufferCapacity / FFTSize, _portInp.Available / FFTSize);
            var outputFramesFree = _portOut.Free;

            if (outputFramesFree == 0)
            {
                return;
            }

            var inputBuffer  = _portInp.Read(Math.Min(outputFramesFree, fftsToRead) * FFTSize);
            var inputSamples = inputBuffer.Data;

            for (int i = 0; i < inputBuffer.Available; i++)
            {
                _frameBuffer[inputSampleCount++] = inputSamples[i];

                if (inputSampleCount == _fft.Size)
                {
                    _fft.UseData(_frameBuffer, 0, _fft.Size);
                    var result = _fft.Transform();
                    _portOut.WriteFrame(result, 0);
                    inputSampleCount = 0;
                }
            }
        }
예제 #4
0
        public override void Process()
        {
            var buffer = _portIn.Read();

            Session.AnalogWrite(Channel.Device, ChannelNumber, buffer.Data, 0, buffer.Available);
        }