コード例 #1
0
 public void NotifyPeakOverload(object sender, PeakOverload Overload)
 {
     if (PeakOverloadEvent != null)
     {
         PeakOverloadEvent(sender, Overload);
     }
 }
コード例 #2
0
ファイル: VuMeterForm.cs プロジェクト: daisy/obi
        // catch the peak overload event triggered by VuMeter
        public void CatchPeakOverloadEvent(object sender, events.VuMeterEvents.PeakOverload ob_PeakOverload)
        {
            VuMeter ob_VuMeter = sender as VuMeter;

            if (ob_PeakOverload.Channel == 1)
            {
                //txtOverloadLeft.Text	 = ob_VuMeter.m_MeanValueLeft.ToString () ;
                SetTextBoxText(txtOverloadLeft, ob_VuMeter.m_MeanValueLeft.ToString());                  // JQ -- avoid race condition
            }

            if (ob_PeakOverload.Channel == 2)
            {
                //txtOverloadRight.Text = ob_VuMeter.m_MeanValueRight.ToString ()  ;
                SetTextBoxText(txtOverloadRight, ob_VuMeter.m_MeanValueRight.ToString());
            }

            //BeepEnabled =true  ;
            BeepEnabled = false;              // don't beep (JQ)
        }
コード例 #3
0
        void AnimationComputation()
        {
            //Thread.Sleep (25) ;
            // finds the origin i.e upper left corner of graph display rectangle
            //origin is computed from centre position of graph
            int OriginX = m_GraphPositionX - Convert.ToInt32((m_ScaleFactor * 60));
            int OriginY = m_GraphPositionY - Convert.ToInt32(125 * m_ScaleFactor);

            // create an local array and fill the amplitude value of both channels from function
            int [] AmpArray = new int [2];
            Array.Copy(AmplitudeValue(), AmpArray, 2);

            // feed the amplitude in sampple array for computing mean value

            SampleArrayLeft [m_SampleArrayPosition]  = AmpArray [0];
            SampleArrayRight [m_SampleArrayPosition] = AmpArray [1];


            m_SampleArrayPosition++;
            if (m_SampleArrayPosition >= m_SampleCount)
            {
                m_SampleArrayPosition = 0;
            }

            // Find Mean Values of Left and Right Channels
            m_MeanValueLeft = m_MeanValueRight = 0;
            for (int i = 0; i < m_SampleCount; i++)
            {
                m_MeanValueLeft  = m_MeanValueLeft + SampleArrayLeft [i];
                m_MeanValueRight = m_MeanValueRight + SampleArrayRight [i];
            }
            m_MeanValueLeft  = m_MeanValueLeft / m_SampleCount;
            m_MeanValueRight = m_MeanValueRight / m_SampleCount;

            // update peak values if it is greater than previous value
            if (m_PeakValueLeft < m_MeanValueLeft)
            {
                arPeakOverloadValue[0] = m_PeakValueLeft = m_MeanValueLeft;
            }

            if (m_PeakValueRight < m_MeanValueRight)
            {
                arPeakOverloadValue[1] = m_PeakValueRight = m_MeanValueRight;
            }


            // Check for Peak Overload  and fire event if overloaded
            if (m_MeanValueLeft > m_UpperThreshold)
            {
                arPeakOverloadFlag [0] = true;
                events.VuMeterEvents.PeakOverload e;
                if (boolPlayer)
                {
                    e = new events.VuMeterEvents.PeakOverload(1,
                                                              ob_AudioPlayer.GetCurrentBytePosition(), ob_AudioPlayer.GetCurrentTimePosition());
                }
                else
                {
                    e = new events.VuMeterEvents.PeakOverload(1, 0, 0);
                }
                PeakOverload(this, e);
            }
            else
            {
                arPeakOverloadFlag[0] = false;
            }

            if (m_MeanValueRight > m_UpperThreshold)
            {
                m_bOverload = true;

                arPeakOverloadFlag [1] = true;
                events.VuMeterEvents.PeakOverload e;
                if (boolPlayer)
                {
                    e = new events.VuMeterEvents.PeakOverload(2,
                                                              ob_AudioPlayer.GetCurrentBytePosition(), ob_AudioPlayer.GetCurrentTimePosition());
                }
                else
                {
                    e = new events.VuMeterEvents.PeakOverload(2, 0, 0);
                }
                PeakOverload(this, e);
            }
            else
            {
                arPeakOverloadFlag[1] = false;
            }

            // compute the cordinates of graph and animation
            DisplayGraph();

            int ThresholdFactor = 12500 / (m_UpperThreshold - m_LowerThreshold);
            int DisplayAmpLeft  = (m_MeanValueLeft * ThresholdFactor) / 100;
            int DisplayAmpRight = (m_MeanValueRight * ThresholdFactor) / 100;
            int Offset          = 65 - ((m_LowerThreshold * ThresholdFactor) / 100);

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

            Graph.EraserLeft  = OriginY + Convert.ToInt32(m_ScaleFactor * (254 - DisplayAmpLeft));
            Graph.EraserRight = OriginY + Convert.ToInt32(m_ScaleFactor * (254 - DisplayAmpRight));

            //Thread.Sleep (25) ;
            // Update ccurrent graph cordinates to VuMeter display
            UpdateForms(this, new events.VuMeterEvents.UpdateForms());
        }