protected override void DataAvailable(DataInputPort port) { _inp.Queue.Dequeue(_buffer); var samples = _buffer.GetSamples(); for (int j = 0; j < _buffer.WrittenSamples; j++) { samples[j] += factor++; } _out.SendData(_buffer); }
protected override void DataAvailable(DataInputPort port) { System.Diagnostics.Debug.WriteLine($"{Name}: DataAvailable mit {_input.Queue.Length} Samples im InputBuffer"); var timesReadable = Math.Max(1, _input.Queue.Length / _buffer.Length); for (int j = 0; j < timesReadable; j++) { _input.Queue.Dequeue(_buffer); _output.SendData(_buffer); } }
public void SendData(int sampleCount) { System.Diagnostics.Debug.WriteLine($"{Name}: SendData mit {sampleCount}"); CheckBufferSize(ref _buffer, sampleCount, Samplerate); var samples = _buffer.GetSamples(); for (int i = 0; i < sampleCount; i++) { samples[i] = 1; } _buffer.SetWritten(sampleCount); _output.SendData(_buffer); }
private void Process() { _portInp.Queue.Dequeue(_bufIn); var samples = _bufIn.GetSamples(); var output = _bufOut.GetSamples(); // 1: Get Stamp for current sample // 2: Get Multiplier Value from Input // 3: Multiply // 4: Remove unnecessary values from Value List var currentSampleTime = new TimeLocatedValue(0, new TimeStamp(0)); TimeLocatedValue fLast = new TimeLocatedValue(1, new TimeStamp(0)); var stamp = _bufIn.FrontTime; var sr = _bufIn.Samplerate; for (int i = 0; i < _bufIn.Length; i++) { stamp.AddInplace(1, sr); currentSampleTime.SetStamp(stamp); // TODO: Values should cache current and next value TimeLocatedValue multiplier; if (_inputValue.Values.SafeTryWeakPredecessor(currentSampleTime, out multiplier)) { output[i] = samples[i] * multiplier.Value; if (multiplier != fLast) { fLast = multiplier; _inputValue.Values.SafeRemoveRangeTo(multiplier); } } else { output[i] = samples[i] * fLast.Value; } } _bufOut.SetWritten(_bufIn.Length); _portOut.SendData(_bufOut); }
private void ProcessBuffers(int samples) { var bufA = _portInA.Read(samples); var bufB = _portInB.Read(samples); System.Diagnostics.Debug.Assert(bufA.WrittenSamples == bufB.WrittenSamples); var samplesA = bufA.GetSamples(); var samplesB = bufB.GetSamples(); var samplesC = _outputBuffer.GetSamples(); for (var i = 0; i < bufA.WrittenSamples; i++) { samplesC[i] = samplesA[i] + samplesB[i]; } _outputBuffer.SetWritten(_portInA.Buffer.WrittenSamples); _portOut.SendData(_outputBuffer); }