public void NotifyUpdateForms(VuMeter ob_VuMeter, UpdateForms Update) { if (UpdateFormsEvent != null) { UpdateFormsEvent(ob_VuMeter, Update); } }
public void NotifyPeakOverload(VuMeter ob_VM, PeakOverload Overload) { if (PeakOverloadEvent != null) { PeakOverloadEvent(ob_VM, Overload); } }
public MainUnitViewModel(MainUnitModel mainUnit, MainViewModel main) { main.Communication.ConnectionModeChanged += Communication_ConnectionModeChanged; _mainUnit = mainUnit; _main = main; main.SystemChanged += UpdateName; VuMeter = new VuMeter(this); AlarmMessages = new AlarmMessagesViewModel(this); UpdateConnectionMode(); }
// catch the peak overload event triggered by VuMeter public void CatchPeakOverloadEvent(object sender, AudioLib.Events.VuMeter.PeakOverloadEventArgs ob_PeakOverload) { VuMeter ob_VuMeter = sender as VuMeter; if (ob_PeakOverload.Channel == 1) { } if (ob_PeakOverload.Channel == 2) { } m_OverloadLightEnabled = true; }
// 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()); }
private void btnPlay_Click(object sender, System.EventArgs e) { /* * OpenFileDialog ofd = new OpenFileDialog(); * ofd.Filter = "wave files(*.wav|*.wav"; * ofd.ShowDialog(); * textBox1.Text = ofd.FileName; * textBox2.Text = ofd.FileName; * * //AudioClip ob_Clip = new AudioClip (textBox1.Text) ; * * AudioMediaAsset am = new AudioMediaAsset (ob_Clip.Channels , ob_Clip.BitDepth , ob_Clip.SampleRate) ; * * * am.AddClip (ob_Clip) ; * * AudioClip ob_Clip1 = new AudioClip (textBox2.Text) ; * am.AddClip (ob_Clip1) ; * * AudioClip ob_Clip2 = new AudioClip ("F:\\My Documents\\Project\\0.wav" , 0, 5000) ; * am.AddClip (ob_Clip2) ; */ VuMeter ob_VuMeter = new VuMeter(); ob_VuMeter.ScaleFactor = 2; ob_VuMeter.SampleTimeLength = 2000; ob_VuMeter.LowerThreshold = 10; ob_VuMeter.UpperThreshold = 80; ob_VuMeter.ShowForm(); ap.VuMeterObject = ob_VuMeter; Microsoft.DirectX.DirectSound.Device dSound = new Microsoft.DirectX.DirectSound.Device(); dSound.SetCooperativeLevel(this, CooperativeLevel.Priority); ap.OutputDevice = dSound; ap.CompFactor = 1; ap.Play(am); //MessageBox.Show ("Done") ; }
// function to catch the update event from VuMeter class to update graph cordinates public void CatchUpdateForms(object sender, AudioLib.Events.VuMeter.UpdateFormsEventArgs Update) { VuMeter ob_VuMeterArg = sender as VuMeter; mVuMeter = ob_VuMeterArg; // Update erase left and erase right cordinates int ThresholdFactor = 12500 / (mVuMeter.UpperThreshold - mVuMeter.LowerThreshold); int DisplayAmpLeft = (mVuMeter.ChannelValueLeft * ThresholdFactor) / 100; int DisplayAmpRight = (mVuMeter.ChannelValueRight * ThresholdFactor) / 100; int Offset = 65 - ((mVuMeter.LowerThreshold * 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()); }
private void InitializeAudioStuff() { mCurrentAudioStreamProvider = () => { if (!String.IsNullOrEmpty(FilePath)) { if (m_FilePlayStream == null) { m_FilePlayStream = File.Open(FilePath, FileMode.Open); } return(m_FilePlayStream); } return(null); }; m_Player = new AudioPlayer(); m_Player.StateChanged += Player_StateChanged; m_Recorder = new AudioRecorder(); m_Recorder.StateChanged += Recorder_StateChanged; m_VuMeter = new VuMeter(m_Player, m_Recorder); /*m_GraphicalPeakMeter = new GraphicalPeakMeter * { * BarPaddingToWidthRatio = 0.075F, * Dock = System.Windows.Forms.DockStyle.Fill, * FontToHeightRatio = 0.03F, * FontToWidthRatio = 0.075F, * Location = new System.Drawing.Point(0, 0), * MinimumSize = new System.Drawing.Size(200, 300), * Name = "mGraphicalPeakMeter", * Size = new System.Drawing.Size(400, 500), * SourceVuMeter = m_VuMeter, * TabIndex = 0 * }; * * WinFormPeakMeter.Child = m_GraphicalPeakMeter; */ WinFormHost.Child = new System.Windows.Forms.Control("needed by DirectSound"); m_Player.SetDevice(WinFormHost.Child, @"auto"); m_PeakMeterBarDataCh1 = new PeakMeterBarData(() => peakMeterCanvasInvalidateVisual()); m_PeakMeterBarDataCh2 = new PeakMeterBarData(() => peakMeterCanvasInvalidateVisual()); m_PeakMeterBarDataCh1.ValueDb = Double.NegativeInfinity; m_PeakMeterBarDataCh2.ValueDb = Double.NegativeInfinity; m_PeakMeterValues = new double[2]; m_Player.EndOfAudioAsset += new EndOfAudioAssetHandler(OnEndOfAudioAsset); m_Player.StateChanged += new StateChangedHandler(OnAudioPlayerStateChanged); m_VuMeter.UpdatePeakMeter += new UpdatePeakMeterHandler(OnUpdateVuMeter); m_VuMeter.ResetEvent += new ResetHandler(OnResetVuMeter); m_VuMeter.PeakOverload += new PeakOverloadHandler(OnPeakOverload); /* * m_GraphicalVuMeter = new GraphicalVuMeter() * { * Dock = System.Windows.Forms.DockStyle.Fill, * //Location = new System.Drawing.Point(0, 0), * MinimumSize = new System.Drawing.Size(50, 50), * Name = "mVuMeter", * Size = new System.Drawing.Size(400, 500), * TabIndex = 0, * VuMeter = m_VuMeter * }; * WinFormVuMeter.Child = m_GraphicalVuMeter; */ }