I am using an AnalogWaveform<double> to store a waveform of recorded samples.
I want to run my waveform through an FIR filter to clean it up a little. Here is the function I wrote:
public static AnalogWaveform<double> FIRFilter(AnalogWaveform<double> Waveform, double [] Coefficients)
{
AnalogWaveform<double> Result;
NationalInstruments.Analysis.Dsp.Filters.FirDirectFilter MyFilter = new FirDirectFilter(Coefficients);
double[] InputData = Waveform.GetRawData();
double[] OutputData = MyFilter.FilterData(InputData);
Result = new AnalogWaveform<double>(0, Waveform.Capacity);
Result.Append(OutputData);
Result.Timing = Waveform.Timing; // I get an exception here, telling me that "The number of irregular time stamps is not equal to the number of samples in the waveform."
return Result;
}
I was expecting that I would have something like:
Waveform.Samples = { { 0, 7/16/13 9:22:22.01}, { 0.002, 7/16/13 9:22:22.01}, ..... { 0.3223, 7/16/13 9:22:28.93} }
After the filtering and append I was expecting:
Result.Samples = { { Filtered0}, { Filtered 0.002}, ..... { Filtered 0.3223} }
and after the timing:
Result.Samples = { { Filtered 0, 7/16/13 9:22:22.01}, { Filtered 0.002, 7/16/13 9:22:22.01}, ..... { Filtered 0.3223, 7/16/13 9:22:28.93} }
Can you tell me why I am getting this exception and the "right way" to get what I want?
2) This is my construction of that waveform:
_RawSampleWaveform = new AnalogWaveform<double>(0, 0);
_RawSampleWaveform.Append(new double[] { 0 });
_RawSampleWaveform.Timing = WaveformTiming.CreateWithIrregularInterval(new DateTime[] { DateTime.Now });
Is there a better way than having a 'fake' 0 sample. If I try to change the timing without that 'fake' sample I get the same exception-- that my number of samples does not match my number of timestamps.
Suggestions on the "right" way to do this appreciated.
Thanks,
Roger