public void AddLR(WavData wd, int sampleNum, double start, double end) { double startTime = wd.RatioToTime(start); double endTime = wd.RatioToTime(end); double dt = (endTime - startTime) / sampleNum; short[] left = wd.GetLeft(sampleNum, start, end); short[] right = wd.GetRight(sampleNum, start, end); chart.Series.Clear(); chart.Series.Add("L"); chart.Series["L"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; for (int i = 0; i < left.Length; i++) { double x = startTime + dt * i; chart.Series["L"].Points.AddXY(x, left[i]); } chart.Series.Add("R"); chart.Series["R"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; for (int i = 0; i < right.Length; i++) { double x = startTime + dt * i; chart.Series["R"].Points.AddXY(x, right[i]); } setXlim(startTime, endTime); setYlim(Int16.MinValue + 1, Int16.MaxValue - 1); }
short[] ComputeMean(int idx) { int left = 0; int right = 0; ArrayList listUnmuted = GetUnmutedItems(); int num = listUnmuted.Count; double factorL = 0; double factorR = 0; for (int i = 0; i < num; i++) { try { WavData item = ((ItemSet)listUnmuted[i]).GetData(); left += item.GetLeft(idx); right += item.GetRight(idx); factorL += Math.Abs(item.GetFactor(idx, WavData.LEFT)); factorR += Math.Abs(item.GetFactor(idx, WavData.RIGHT)); } catch (ArgumentOutOfRangeException) { // sometimes thrown when item removed while playing // can be ignored } catch (NullReferenceException) { continue; } } if (factorL == 0 && factorR == 0 && avoidAllMute) { WavData item = GetLastItem().GetData(); item.IsDefault = true; left = item.GetLeft(idx); right = item.GetRight(idx); item.IsDefault = false; factorL = 1; factorR = 1; } short newLeft, newRight; if (factorL > 1 || normalize) { newLeft = ToShortDevidedBy(left, factorL); } else { newLeft = Convert.ToInt16(left); } if (factorR > 1 || normalize) { newRight = ToShortDevidedBy(right, factorR);; } else { newRight = Convert.ToInt16(right); } return(new short[] { newLeft, newRight }); }