Exemple #1
0
        public void CatchPeakMeterUpdateEvent(object sender, AudioLib.VuMeter.PeakMeterUpdateEventArgs e)
        {
            //double channelValueLeft = 0;
            //double channelValueRight = 0;

            //if (e.PeakDb != null && e.PeakDb.Length > 0)
            //{
            //    channelValueLeft = e.PeakDb[0];

            //    if (e.PeakDb.Length > 1)
            //    {
            //        channelValueRight = e.PeakDb[1];
            //    }
            //    else
            //    {
            //        channelValueRight = channelValueLeft;
            //    }

            //    if (channelValueLeft == Double.PositiveInfinity
            //        && e.PeakDb.Length > 1
            //        && channelValueRight == Double.PositiveInfinity)
            //    {
            //        VuMeter_ResetEvent();
            //        return;
            //    }
            //}
        }
        // function to catch the update event from VuMeter class to update graph cordinates
        public void CatchPeakMeterUpdateEvent(object sender, AudioLib.VuMeter.PeakMeterUpdateEventArgs e)
        {
            VuMeter ob_VuMeterArg = sender as VuMeter;

            mVuMeter = ob_VuMeterArg;

            double channelValueLeft  = 0;
            double channelValueRight = 0;

            if (e.PeakDb != null && e.PeakDb.Length > 0)
            {
                channelValueLeft = e.PeakDb[0];

                if (e.PeakDb.Length > 1)
                {
                    channelValueRight = e.PeakDb[1];
                }
                else
                {
                    channelValueRight = channelValueLeft;
                }

                //if (channelValueLeft == Double.PositiveInfinity
                //    && e.PeakDb.Length > 1
                //    && channelValueRight == Double.PositiveInfinity)
                //{
                //    CatchResetEvent();
                //    return;
                //}
            }

            // Update erase left and erase right cordinates
            int ThresholdFactor = 12500 / (210 - 15);
            int DisplayAmpLeft  = (int)((channelValueLeft * ThresholdFactor) / 100.0);
            int DisplayAmpRight = (int)((channelValueRight * ThresholdFactor) / 100.0);
            int Offset          = 65 - ((15 * ThresholdFactor) / 100);


            DisplayAmpLeft  = DisplayAmpLeft + Offset;
            DisplayAmpRight = DisplayAmpRight + Offset;

            EraserLeft  = Convert.ToInt32(LowBottom - (ScaleFactor * DisplayAmpLeft));
            EraserRight = Convert.ToInt32(LowBottom - (ScaleFactor * DisplayAmpRight));
            //EraserLeft = 100+  mVuMeter.m_MeanValueLeft;

            tmRefresh.Start();
            //MessageBox.Show(EraserLeft.ToString());
        }
        public void CatchPeakMeterUpdateEvent(object sender, AudioLib.VuMeter.PeakMeterUpdateEventArgs e)
        //void SourceVuMeter_UpdatePeakMeter ( object sender, Obi.Events.Audio.VuMeter.UpdatePeakMeter e )
        {
            //double channelValueLeft = 0;
            //double channelValueRight = 0;

            //if (e.PeakDb != null && e.PeakDb.Length > 0)
            //{
            //    channelValueLeft = e.PeakDb[0];

            //    if (e.PeakDb.Length > 1)
            //    {
            //        channelValueRight = e.PeakDb[1];
            //    }
            //    else
            //    {
            //        channelValueRight = channelValueLeft;
            //    }

            //    if ((channelValueLeft == Double.PositiveInfinity && e.PeakDb.Length > 0)
            //    || (channelValueLeft == Double.PositiveInfinity && e.PeakDb.Length > 1 && channelValueRight == Double.PositiveInfinity))
            //    {
            //        CatchResetEvent();
            //        return;
            //    }
            //}

            if (e.PeakDb == null)
            {
                mSourcePeaksIsNull = true;
            }
            else
            {
                mSourcePeaksIsNull = false;
            }

            if (mSourceVuMeter != null && e.PeakDb != null && e.PeakDb.Length > 0)
            {
                mPeakArrayLength = e.PeakDb.Length;
                for (int i = 0; i < e.PeakDb.Length; i++)
                {
                    // AudioLib VuMeter is set to positive infinity by default so it is important to take care of it.
                    //mPeakValues[i] = e.PeakDb[i] == double.PositiveInfinity? double.NegativeInfinity: e.PeakDb[i];
                    mPeakValues[i] = e.PeakDb[i];
                }
            }
        }