c# - Merging multiple pointpairlist -
i have .wav file , plotting waveform using zedgraph. calculating energies of .wav file of each second , if energy less 4 want draw sample in different color. have created 2 pointpairllist
, lineitem
there problem while merging these 2 list. here code , how graph appears.
lineitem mycurveaudio; lineitem mycurveaudio2; pointpairlist list1 = new pointpairlist(); pointpairlist list2 = new pointpairlist(); while(true) { (int = 0; < fmainbuffer.length; i++) { float segmentsquare = fmainbuffer[i] * fmainbuffer[i]; listofsquaredsegment.add(segmentsquare); } float energy = (float)math.sqrt(listofsquaredsegment.sum()); if (energy < 4) { (int = 0; < read; += (int)window) { list1.add((float)(count / ((float)read / (float)window)), fmainbuffer[i]); count++; } } else { (int = 0; < read; += (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);
lines of mycurveaudio , mycurveaudio2 intersect in picture.
how can merge these 2 list preventing intersections?
i have tried add `double.nan end of lists did not work.
try code below, modified code based on "this thread"
lineitem mycurveaudio; lineitem mycurveaudio2; pointpairlist list1 = new pointpairlist(); pointpairlist list2 = new pointpairlist(); double lastaddedhighenergy = double.nan; double lastaddedlowenergy = double.nan; while (true) { (int = 0; < fmainbuffer.length; i++) { float segmentsquare = fmainbuffer[i] * fmainbuffer[i]; listofsquaredsegment.add(segmentsquare); } float energy = (float)math.sqrt(listofsquaredsegment.sum()); if (energy < 4) { (int = 0; < read; += (int)window) { lastaddedlowenergy = (double)(count / ((double)read / (double)window)); if (lastaddedhighenergy != double.nan) { list1.add(lastaddedhighenergy + ((lastaddedlowenergy - lastaddedhighenergy) / 2.0), double.nan); lastaddedhighenergy = double.nan; } list1.add(lastaddedlowenergy, fmainbuffer[i]); count++; } } else { (int = 0; < read; += (int)window) { lastaddedhighenergy = (double)(count / ((double)read / (double)window)); if (lastaddedlowenergy != double.nan) { list2.add(lastaddedlowenergy + ((lastaddedhighenergy - lastaddedlowenergy) / 2.0), double.nan); lastaddedlowenergy = double.nan; } list2.add(lastaddedhighenergy, 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, list2, color.red, symboltype.none);
if above code not worked, follow steps given in this thread
Comments
Post a Comment