I have a .wav file and I am plotting waveform using ZedGraph. I am calculating the energies of .wav file of each second and if energy is less then 4 I want to draw the sample in different color. I have created two PointPairLlist
and LineItem
to do this but there is a problem while merging these two list. Here is my code and how my graph appears.
LineItem myCurveAudio;
LineItem myCurveAudio2;
PointPairList list1 = new PointPairList();
PointPairList list2 = new PointPairList();
while(true)
{
for (int i = 0; i < fmainBuffer.Length; i++)
{
float segmentSquare = fmainBuffer[i] * fmainBuffer[i];
listOfSquaredSegment.Add(segmentSquare);
}
float energy = (float)Math.Sqrt(listOfSquaredSegment.Sum());
if (energy < 4)
{
for (int i = 0; i < read; i += (int)window)
{
list1.Add((float)(count / ((float)read / (float)window)), fmainBuffer[i]);
count++;
}
}
else
{
for (int i = 0; i < read; i += (int)window)
{
list4.Add((float)(count / ((float)read / (float)window)), fmainBuffer[i]);
count++;
}
}
}
zgc.MasterPane.PaneList[1].XAxis.Scale.MaxAuto = true;
zgc.MasterPane.PaneList[1].XAxis.Scale.MinAuto = true;
zgc.MasterPane.PaneList[1].XAxis.Type = AxisType.Linear;
zgc.MasterPane.PaneList[1].XAxis.Scale.Format = "";
zgc.MasterPane.PaneList[1].XAxis.Scale.Min = 0;
myCurveAudio = zgc.MasterPane.PaneList[1].AddCurve(null, list1, Color.Lime, SymbolType.None);
myCurveAudio2 = zgc.MasterPane.PaneList[1].AddCurve(null, list4, Color.Red, SymbolType.None);
The lines of myCurveAudio and myCurveAudio2 intersect like in the picture.
How can I merge these two list preventing those intersections?
I have also tried to add `double.NaN to end of the lists but it did not work.