本文整理汇总了C#中Slice.SubsliceOfDuration方法的典型用法代码示例。如果您正苦于以下问题:C# Slice.SubsliceOfDuration方法的具体用法?C# Slice.SubsliceOfDuration怎么用?C# Slice.SubsliceOfDuration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Slice
的用法示例。
在下文中一共展示了Slice.SubsliceOfDuration方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestStream
public void TestStream()
{
BufferAllocator<float> bufferAllocator = new BufferAllocator<float>(FloatNumSlices * 2048, 1, sizeof(float));
DenseSampleFloatStream stream = new DenseSampleFloatStream(0, bufferAllocator, FloatSliverSize);
HoloDebug.Assert(stream.DiscreteDuration == 0);
var interval = new Interval<Sample>(0, 10);
Slice<Sample, float> firstSlice = stream.GetNextSliceAt(interval);
HoloDebug.Assert(firstSlice.IsEmpty());
// Now let's fill a float array...
float[] buffer = new float[FloatNumSlices * FloatSliverSize];
Duration<Sample> floatNumSlicesDuration = FloatNumSlices;
Slice<Sample, float> tempSlice = new Slice<Sample, float>(new Buf<float>(-1, buffer), FloatSliverSize);
PopulateFloatSlice(tempSlice);
// now append in chunks
stream.Append(tempSlice.SubsliceOfDuration(tempSlice.Duration / 2));
stream.Append(tempSlice.SubsliceStartingAt(tempSlice.Duration / 2));
HoloDebug.Assert(stream.InitialTime == 0);
HoloDebug.Assert(stream.DiscreteDuration == FloatNumSlices);
Slice<Sample, float> theSlice = stream.GetNextSliceAt(stream.DiscreteInterval);
VerifySlice(theSlice);
HoloDebug.Assert(theSlice.Duration == floatNumSlicesDuration);
}
示例2: TestSlice
public void TestSlice()
{
BufferAllocator<float> bufferAllocator = new BufferAllocator<float>(FloatNumSlices * 2048, 1, sizeof(float));
Buf<float> buffer = bufferAllocator.Allocate();
Slice<Sample, float> slice = new Slice<Sample, float>(buffer, 0, FloatNumSlices, FloatSliverSize);
HoloDebug.Assert(slice.Duration == FloatNumSlices);
HoloDebug.Assert(slice.IsEmpty() == false);
HoloDebug.Assert(slice.SliverSize == FloatSliverSize);
var halfDuration = (FloatNumSlices / 2);
Slice<Sample, float> prefixSlice = slice.Subslice(0, halfDuration);
Slice<Sample, float> prefixSlice2 = slice.SubsliceOfDuration(halfDuration);
Slice<Sample, float> suffixSlice = slice.Subslice(halfDuration, halfDuration);
Slice<Sample, float> suffixSlice2 = slice.SubsliceStartingAt(halfDuration);
HoloDebug.Assert(prefixSlice.Precedes(suffixSlice));
HoloDebug.Assert(prefixSlice.Precedes(suffixSlice2));
HoloDebug.Assert(prefixSlice2.Precedes(suffixSlice));
HoloDebug.Assert(prefixSlice2.Precedes(suffixSlice2));
PopulateFloatSlice(slice);
Buf<float> buffer2 = bufferAllocator.Allocate();
Slice<Sample, float> slice2 = new Slice<Sample, float>(buffer2, 0, FloatNumSlices, FloatSliverSize);
slice.CopyTo(slice2);
VerifySlice(slice2);
}