Beispiel #1
0
 void SampleChannelPreVolumeMeter(object sender, StreamVolumeEventArgs e)
 {
     if (LevelChanged != null)
     {
         LevelChanged(this, new LevelChangedEventArgs(e.MaxSampleValues));
     }
 }
Beispiel #2
0
 void OnPreVolumeMeter(object sender, StreamVolumeEventArgs e)
 {
     if (PreVolumeMeter != null)
     {
         PreVolumeMeter(this, e);
     }
 }
Beispiel #3
0
 protected virtual void OnVolumeAnnounced(StreamVolumeEventArgs e)
 {
     if (VolumeAnnounced != null)
     {
         VolumeAnnounced(this, e);
     }
 }
Beispiel #4
0
 void MeteringProviderStreamVolume(object sender, StreamVolumeEventArgs e)
 {
     if (LevelChanged != null)
     {
         LevelChanged(this, new LevelChangedEventArgs(e.MaxSampleValues));
     }
 }
Beispiel #5
0
 private void _waveSourceMeter_StreamVolume(object sender, StreamVolumeEventArgs e)
 {
     if (OnMicVolumeChanged != null)
     {
         OnMicVolumeChanged(e.MaxSampleValues.Average());
     }
 }
Beispiel #6
0
 private void OnPreVolumeMeter(object sender, StreamVolumeEventArgs e)
 {
     // we know it is stereo
     //waveformPainter1.AddMax(e.MaxSampleValues[0]);
     //waveformPainter2.AddMax(e.MaxSampleValues[1]);
     float[] max = e.MaxSampleValues;
 }
Beispiel #7
0
        private void RunOutputMeter(Object sender, StreamVolumeEventArgs e, VerticalMeter meter)
        {
            OutputMeterSpan = DateTime.Now - lastOutputMeter;
            lastOutputMeter = DateTime.Now;
            // Return Time
            currentOutDbFS -= returnPrSec * (OutputMeterSpan.TotalMilliseconds / 1000d);

            double max = 0;

            if (e.MaxSampleValues[0] < 1)
            {
                max = 20 * Math.Log10(e.MaxSampleValues[0]);
            }
            else if (e.MaxSampleValues[0] >= 1)
            {
                max = 20;
            }

            if (currentOutDbFS < max)
            {
                currentOutDbFS = max;
            }

            if (!float.IsNaN(e.MaxSampleValues[0]))
            {
                Invoke(new Action(() =>
                {
                    meter.setValue2((int)currentOutDbFS + 18);
                }));
            }
            else
            {
                Invoke(new Action(() => { meter.setValue2(-40); }));
            }
        }
Beispiel #8
0
 private void meteringStream_StreamVolume(object sender, StreamVolumeEventArgs e)
 {
     if (e.MaxSampleValues.Length >= 2)
     {
         stereoVUMeter1.AmplitudeLeft  = e.MaxSampleValues[0];
         stereoVUMeter1.AmplitudeRight = e.MaxSampleValues[1];
     }
 }
 private void OnStreamVolume(object sender, StreamVolumeEventArgs e)
 {
     MaxVolume?.Invoke(sender, new VolumeEventArgs
     {
         Position  = (float)_waveProvider.CurrentTime.TotalSeconds,
         MaxVolume = e.MaxSampleValues
     });
 }
Beispiel #10
0
        void SampleChannelPreVolumeMeter(object sender, StreamVolumeEventArgs e)
        {
            var lc = LevelChanged;

            if (lc != null)
            {
                lc.Invoke(this, new LevelChangedEventArgs(e.MaxSampleValues));
            }
        }
Beispiel #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void SampleChannel_PreVolumeMeter(object?sender, StreamVolumeEventArgs e)
        {
            int prog = 100 * (int)Current.TotalMilliseconds / (int)Length.TotalMilliseconds;

            StatusEvent?.Invoke(this, new StatusEventArgs()
            {
                Progress = prog
            });
        }
Beispiel #12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void PostVolumeMeter_StreamVolume(object?sender, StreamVolumeEventArgs e)
        {
            levelL.AddValue(e.MaxSampleValues[0]);
            levelR.AddValue(e.MaxSampleValues.Length > 1 ? e.MaxSampleValues[1] : 0); // stereo?
            timeBar.Current = _audioFileReader !.CurrentTime;

            //waveViewerL.Marker1 = (int)(_audioFileReader.Position / _audioFileReader.BlockAlign);
            //waveViewerR.Marker2 = (int)(_audioFileReader.Position / _audioFileReader.BlockAlign);
        }
Beispiel #13
0
 private void Player_VolumeAnnounced_VolumeMeter(object sender, StreamVolumeEventArgs e)
 {
     Dispatcher.BeginInvoke((Action) delegate {
         if (e.MaxSampleValues.Length >= 2)
         {
             stereoVUMeter1.AmplitudeLeft  = e.MaxSampleValues[0];
             stereoVUMeter1.AmplitudeRight = e.MaxSampleValues[1];
         }
     });
 }
Beispiel #14
0
        void OnPostVolumeMeter(object sender, StreamVolumeEventArgs e)
        {
            TimeSpan currentTime = (waveOut.PlaybackState == PlaybackState.Stopped) ? TimeSpan.Zero : fileWaveStream.CurrentTime;
            string   time        = String.Format("{0:00}:{1:00}:{2:00}", (int)currentTime.TotalMinutes, currentTime.Seconds, currentTime.Milliseconds);

            // we know it is stereo
            volumeMeter1.Amplitude = e.MaxSampleValues[0];
            MainLogClass.Log       = string.Format("[0] v {0} t {1} \n", volumeMeter1.Amplitude, time);
            volumeMeter2.Amplitude = e.MaxSampleValues[1];
            MainLogClass.Log       = string.Format("[0] v {0} t {1} \n", volumeMeter1.Amplitude, time);
        }
Beispiel #15
0
        void postVolumeMeter_StreamVolume(object sender, StreamVolumeEventArgs e)
        {
            //Draw bitmap
            if (mGraphics != null && mGraphics1 != null)
            {
                float volume;
                float volume1;

                if (e.MaxSampleValues.Length > 1)
                {
                    if (mVolumnNum == 2)
                    {
                        volume  = e.MaxSampleValues[0] * (float)(mPngHeight / 2.0);
                        volume1 = e.MaxSampleValues[1] * (float)(mPngHeight / 2.0);
                    }
                    else
                    {
                        volume  = Math.Max(e.MaxSampleValues[0], e.MaxSampleValues[1]) * (float)(mPngHeight / 2.0);
                        volume1 = 0;
                    }
                }
                else
                {
                    if (mVolumnNum == 2)
                    {
                        volume  = e.MaxSampleValues[0] * (float)(mPngHeight / 2.0);
                        volume1 = volume;
                    }
                    else
                    {
                        volume  = e.MaxSampleValues[0] * (float)(mPngHeight / 2.0);
                        volume1 = 0;
                    }
                }

                PointF volume11  = new PointF(mPos, (float)(mPngHeight / 2.0) - mVolume);
                PointF volume111 = new PointF(mPos, (float)(mPngHeight / 2.0) - mVolume1);
                PointF volume12  = new PointF(mPos, (float)(mPngHeight / 2.0) + mVolume);
                PointF volume112 = new PointF(mPos, (float)(mPngHeight / 2.0) + mVolume1);
                mPos += 1;
                PointF   volume21  = new PointF(mPos, (float)(mPngHeight / 2.0) - volume);
                PointF   volume121 = new PointF(mPos, (float)(mPngHeight / 2.0) - volume1);
                PointF   volume22  = new PointF(mPos, (float)(mPngHeight / 2.0) + volume);
                PointF   volume122 = new PointF(mPos, (float)(mPngHeight / 2.0) + volume1);
                PointF[] points    = { volume11, volume21, volume22, volume12 };
                PointF[] points1   = { volume111, volume121, volume122, volume112 };
                mGraphics.FillPolygon(mDrawBrush, points);
                mGraphics1.FillPolygon(mDrawBrush, points1);
                //mGraphics.FillPolygon(Brushes.Blue, points);
                mVolume  = volume;
                mVolume1 = volume1;
            }
        }
Beispiel #16
0
 private void Meter_StreamVolume(Object sender, StreamVolumeEventArgs e)
 {
     try
     {
         LevelLeftValue  = Math.Truncate(e.MaxSampleValues[0] * 150);
         LevelRightValue = Math.Truncate(e.MaxSampleValues[1] * 150);
     }
     catch
     {
         LevelLeftValue  = 0;
         LevelRightValue = 0;
     }
 }
        private void OnPostVolumeMeter(object sender, StreamVolumeEventArgs e)
        {
            // we know it is stereo
            System.Threading.Tasks.Task.Factory.StartNew(new Action(() =>
            {
                Dispatcher.Invoke(delegate
                {
                    // Update meter async
                    volumeMeter1.Amplitude = e.MaxSampleValues[0];
                });
            }));

            //volumeMeter2.Amplitude = e.MaxSampleValues[1];
        }
Beispiel #18
0
        /// <summary>
        /// 믹서 채널용 생성자
        /// </summary>
        /// <param name="source">Source Sample Provider</param>
        public VolumePanningSampleProvider(ISampleProvider source, int samplesPerNotification)
        {
            this.source = source;
            Volume      = 1.0f;
            Panning     = 0.0f;
            Mute        = false;

            _channels              = source.WaveFormat.Channels;
            _maxSamples            = new float[_channels];
            SamplesPerNotification = samplesPerNotification;
            _eventArgs             = new StreamVolumeEventArgs()
            {
                MaxSampleValues = _maxSamples
            };
        }
Beispiel #19
0
        void OnPostVolumeMeter(object sender, StreamVolumeEventArgs e)
        {
            ///left
            ///-
            ///-60 to 0 dB volume
            /// 0 dB to 5 dB volume
            volumeMeter1.Amplitude = e.MaxSampleValues[0];
            volumeMeter3.Amplitude = e.MaxSampleValues[0];

            ///right
            ///-
            ///-60 to 0 dB volume
            /// 0 dB to 5 dB volume
            volumeMeter2.Amplitude = e.MaxSampleValues[1];
            volumeMeter4.Amplitude = e.MaxSampleValues[0];
        }
Beispiel #20
0
        private void OnAudioRecordingMeterStreamVolume(object sender, StreamVolumeEventArgs e)
        {
            AudioEngineRecordingVolumeChanged handler = this.OnMicVolumeChanged;

            if (handler != null && this.enabled)
            {
                try
                {
                    handler(e.MaxSampleValues.Average());
                }
                catch (Exception ex)
                {
                    Logger.Log(LogLevel.Error, ex.Message);
                }
            }
        }
Beispiel #21
0
        private void OnPreVolumeMeter(object sender, StreamVolumeEventArgs e)
        {
            var sampleValues = e.MaxSampleValues;
            var channels     = sampleValues.Length;

            Debug.Assert(channels == waveformPainters.Count, "channels == waveformPainters.Count");

            if (channels == waveformPainters.Count)
            {
                for (int ch = 0; ch < channels; ch++)
                {
                    var painter   = waveformPainters[ch];
                    var sampleVal = e.MaxSampleValues[ch];
                    painter.AddMax(sampleVal);
                }
            }
        }
Beispiel #22
0
        private void PostVolumeMeter_StreamVolume(object sender, StreamVolumeEventArgs e)
        {
            var maxSample0 = e.MaxSampleValues[0];

            //if (e.MaxSampleValues.Count() > 1)
            //{

            //    var maxSample1 = e.MaxSampleValues[1];
            //    logger.Debug("MaxSampleValues" + maxSample0 + " " + maxSample1);
            //}
            //else
            //{
            //    logger.Debug("MaxSampleValues" + maxSample0);
            //}

            waveformPainter?.AddMax(maxSample0);
        }
Beispiel #23
0
        /// ------------------------------------------------------------------------------------
        protected void HandlePlaybackMetering(object sender, StreamVolumeEventArgs e)
        {
            if (PlaybackUpdate != null)
            {
                PlaybackUpdate(this, _playbackStream.CurrentTime, _playbackStream.TotalTime);
            }

            var newTime = _playbackStream.CurrentTime.Add(-TimeSpan.FromMilliseconds(_waveOut.DesiredLatency / 2.0));

            if (newTime >= (_playbackRange.End > TimeSpan.Zero ? _playbackRange.End : WaveStream.TotalTime))
            {
                SetCursor(_playbackRange.End);
            }
            else
            {
                SetCursor(newTime);
            }
        }
Beispiel #24
0
        private void MeterSampleProvider_StreamVolume(object sender, StreamVolumeEventArgs e)
        {
            PeakValueLeft = Normalize(e.MaxSampleValues[0]);

            if (e.MaxSampleValues.Length > 1)
            {
                PeakValueRight = Normalize(e.MaxSampleValues[1]);
            }
            else
            {
                PeakValueRight = PeakValueLeft;
            }

            OnPeak?.Invoke(new PeakEventArgs {
                Left  = PeakValueLeft,
                Right = PeakValueRight
            });
        }
Beispiel #25
0
        void OnPreVolumeMeter(object sender, StreamVolumeEventArgs e)
        {
            // we know it is stereo
            float max1 = e.MaxSampleValues[0];
            float max2 = e.MaxSampleValues[1];

            Console.WriteLine(string.Format("max1:{0} max2:{1}", max1, max2));
            currentValue = max1;
            if (currentChannel == "L")
            {
                L_valueLable.Text = "value:" + max1.ToString();
            }
            else
            {
                R_valueLable.Text = "value:" + max1.ToString();
            }

            // waveformPainter1.AddMax(e.MaxSampleValues[0]);
            //waveformPainter2.AddMax(e.MaxSampleValues[1]);
        }
 void onPostVolumeMeter(object sender, StreamVolumeEventArgs e)
 {
     // we know it is stereo
     volumeMeter1.Amplitude = e.MaxSampleValues[0];
     volumeMeter2.Amplitude = e.MaxSampleValues[1];
 }
Beispiel #27
0
 void SampleChannelPreVolumeMeter(object sender, StreamVolumeEventArgs e)
 {
     LevelChanged?.Invoke(this, new LevelChangedEventArgs(e.MaxSampleValues));
 }
Beispiel #28
0
 void _meteringProvider_StreamVolume(object sender, StreamVolumeEventArgs e)
 {
     UpdateLevel(e.MaxSampleValues[0]);
     //UpdateLevel(0);
 }
Beispiel #29
0
 void OnPreVolumeMeter(object sender, StreamVolumeEventArgs e)
 {
     // we know it is stereo
     waveformPainter1.AddMax(e.MaxSampleValues[0]);
     waveformPainter2.AddMax(e.MaxSampleValues[1]);
 }
Beispiel #30
0
 private void Notifier_StreamVolume(object sender, StreamVolumeEventArgs e)
 {
     volumeMeter.Amplitude = e.MaxSampleValues[0];
 }