I want to make downsampling by halving the sample frequency. My signal is represented by an IObservable<Sample>
. Therefore I have to skip every second sample in the stream. I've tried like this. But there is an error with the second select command after Buffer(2).
The IntelliSense message (on the select command) is: "The type arguments for the method [...SkipEverySecond...] cannot be inferred from the usage. Try specifying the type arguments explicitly." This error could be eliminated by deleting the assignment "samples =>". I don't understand why...
/// <summary>
/// Called when a part's imports have been satisfied and it is safe to use
/// </summary>
public void OnImportsSatisfied()
{
signalFiltering.ConfigureFilters(filterParameter);
configManager.LoadAttributed(this, this);
//currentRdm.ForwardedDataSource is an imported Observable
//ToDo: Skip every second sample (downsampling)
this._forwardedDataSource = this.currentRdm.ForwardedDataSource.Select(
sample => signalFiltering.Filter(sample, filterParameter)).
Buffer(2).Select(samples => SkipEverySecond);
this._qrsComplexis = this._forwardedDataSource.Buffer(QRSWINDOWSIZE).Select(SamplePacketProcess);
}
private Sample SkipEverySecond(IEnumerable<Sample> samples )
{
return samples.First();
}
You don't need the lambda expression samples =>
. The Select is being applied to the output of Buffer which is IEnumerable<Sample>
if I understood correctly