예제 #1
0
        public override void PrepareProcessing()
        {
            if (_precTimer == null)
            {
                _precTimer                       = new PrecisionTimer();
                _precTimer.Elapsed              += precTimer_Elapsed;
                _precTimer.Milliseconds          = _attrPeriod.TypedGet();
                _precTimer.ToleranceMilliseconds = 10;
            }

            var sampleCount = _attrSamplerate.TypedGet() * _attrPeriod.TypedGet() / 1000;

            if (_buffer == null || _buffer.Length != sampleCount)
            {
                _buffer = new double[sampleCount];
            }

            _portOut.PrepareProcessing(
                DefaultParameters.DefaultQueueMilliseconds.ToSamples(_portOut.Samplerate),
                DefaultParameters.DefaultBufferMilliseconds.ToSamples(_portOut.Samplerate)
                );

            CalculatePhaseStep();
            _phaseAcc = 0;
        }
예제 #2
0
        public override void PrepareProcessing()
        {
            _portInp.PrepareProcessing();
            _portOut.PrepareProcessing();

            _outputBuffer = new TimeLocatedBuffer1D <double>(
                DefaultParameters.DefaultBufferMilliseconds.ToSamples(_portInp.Samplerate),
                _portInp.Samplerate
                );
        }
예제 #3
0
        public override void PrepareProcessing()
        {
            _input.PrepareProcessing();
            _output.PrepareProcessing();

            _bufOutput = new TimeLocatedBuffer1D <double>(
                DefaultParameters.DefaultBufferMilliseconds.ToSamples(_output.Samplerate) * 2, // TODO: * 2 pretty much magic
                _output.Samplerate
                );

            _resample = new LibResampler(_input.Samplerate, _output.Samplerate, _input.BufferCapacity, _bufOutput.Capacity);
        }
예제 #4
0
        public override void PrepareProcessing()
        {
            if (PortIn1.Samplerate != PortIn2.Samplerate)
            {
                throw new InvalidOperationException("Samplerates do not match");
            }

            PortIn1.PrepareProcessing();
            PortIn2.PrepareProcessing();
            PortOut.PrepareProcessing();

            OutputBuffer = new TimeLocatedBuffer1D <double>(PortOut.Buffer.Capacity, PortOut.Samplerate);
        }
예제 #5
0
        public override void PrepareProcessing()
        {
            if (_portIn.Samplerate == 0)
            {
                throw new InvalidOperationException("Input samplerate must be > 0");
            }

            if (_samplesPerRms <= 0)
            {
                throw new InvalidOperationException("Window length too short. Less than 1 sample.");
            }

            if (_portOut.Samplerate == 0)
            {
                throw new InvalidOperationException("Output samplerate is to small. Must be > 0. Chose a shorter window length");
            }

            _portIn.PrepareProcessing();
            _portOut.PrepareProcessing();

            _bufOut = new TimeLocatedBuffer1D <double>(DefaultParameters.DefaultBufferMilliseconds.ToSamples(_portOut.Samplerate), _portOut.Samplerate);
        }
예제 #6
0
        public override void PrepareProcessing()
        {
            _reader?.Dispose();
            try {
                _reader = new System.IO.BinaryReader(System.IO.File.OpenRead(_attrFilePath.TypedGet()));
            } catch (Exception ex) {
                Parent.Context.Notify(new GraphNotification(GraphNotification.NotificationType.Error, ex.ToString()));
                throw;
            }

            if (_reader != null)
            {
                _reader.BaseStream.Seek(0, System.IO.SeekOrigin.Begin);
                _portOut.PrepareProcessing();
                _portTrigger.PrepareProcessing();
                _buffer      = new TimeLocatedBuffer1D <double>(_portOut.Buffer.Capacity, _portOut.Samplerate);
                _endOfStream = false;

                if (_portTrigger.Connection == null)
                {
                    _startTime = new TimeStamp(0);
                }
            }
            else
            {
                throw new Exception("File node: did not specify input");
            }

            _lastStatePosition = 0;

            _sampleSize = _dataTypeSizes[_attrDataType.TypedGet()];

            _sampleGetterFunc = () => {
                throw new System.IO.EndOfStreamException();
            };

            switch (_attrDataType.TypedGet())
            {
            case DataType.Float32:
                _sampleGetterFunc = () => _reader.ReadSingle();
                break;

            case DataType.Float64:
                _sampleGetterFunc = () => _reader.ReadDouble();
                break;

            case DataType.Int16:
                _sampleGetterFunc = () => _reader.ReadInt16();
                break;

            case DataType.Int32:
                _sampleGetterFunc = () => _reader.ReadInt32();
                break;

            case DataType.Int64:
                _sampleGetterFunc = () => _reader.ReadInt64();
                break;

            default:
                throw new NotImplementedException();
            }
        }
예제 #7
0
        // ----------------------------------------------------------------------------------------------------
        // HELPERS

        private void InitBuffer()
        {
            _samplesToKeep = (int)(_portInp.Samplerate * _attrMillis.TypedGet() / 1000);
            _portInp.PrepareProcessing(2 * _samplesToKeep, 2 * _samplesToKeep);
            _portOut.PrepareProcessing(2 * _samplesToKeep, 2 * _samplesToKeep);
        }