/// <summary>
 /// Initialises a new instance of MeteringSampleProvider 
 /// </summary>
 /// <param name="source">source sampler provider</param>
 /// <param name="samplesPerNotification">Number of samples between notifications</param>
 public MeteringSampleProvider(ISampleProvider source, int samplesPerNotification)
 {
     this.source = source;
     this.channels = source.WaveFormat.Channels;
     this.maxSamples = new float[channels];
     this.SamplesPerNotification = samplesPerNotification;
     this.args = new StreamVolumeEventArgs() { MaxSampleValues = this.maxSamples }; // create objects up front giving GC little to do
 }
 /// <summary>
 /// Initialises a new instance of MeteringSampleProvider
 /// </summary>
 /// <param name="source">source sampler provider</param>
 /// <param name="samplesPerNotification">Number of samples between notifications</param>
 public MeteringSampleProvider(ISampleProvider source, int samplesPerNotification)
 {
     this.source                 = source;
     this.channels               = source.WaveFormat.Channels;
     this.maxSamples             = new float[channels];
     this.SamplesPerNotification = samplesPerNotification;
     this.args = new StreamVolumeEventArgs()
     {
         MaxSampleValues = this.maxSamples
     };                                                                             // create objects up front giving GC little to do
 }
Esempio n. 3
0
 void SampleChannelPreVolumeMeter(object sender, StreamVolumeEventArgs e)
 {
     LevelChanged?.Invoke(this, new LevelChangedEventArgs(e.MaxSampleValues));
 }
Esempio n. 4
0
 void MeteringProviderStreamVolume(object sender, StreamVolumeEventArgs e)
 {
     if (LevelChanged != null)
         LevelChanged(this, new LevelChangedEventArgs(e.MaxSampleValues));
 }
Esempio n. 5
0
 void SampleChannelPreVolumeMeter(object sender, StreamVolumeEventArgs e)
 {
     if (LevelChanged != null)
         LevelChanged(this, new LevelChangedEventArgs(e.MaxSampleValues));
 }
 void OnPreVolumeMeter(object sender, StreamVolumeEventArgs e)
 {
     // we know it is stereo
     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];
 }
Esempio n. 8
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;
		}
Esempio n. 9
0
 void _meteringProvider_StreamVolume(object sender, StreamVolumeEventArgs e)
 {
     UpdateLevel(e.MaxSampleValues[0]);
 }
Esempio n. 10
0
 void OnPreVolumeMeter(object sender, NAudio.Wave.SampleProviders.StreamVolumeEventArgs e)
 {
     // we know it is stereo
     //w aveformPainter1.AddMax(e.MaxSampleValues[0]);
     //waveformPainter2.AddMax(e.MaxSampleValues[1]);
 }
        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);
        }
Esempio n. 12
0
 void SampleChannelPreVolumeMeter(object sender, StreamVolumeEventArgs e)
 {
     var lc = LevelChanged;
     if (lc != null)
     {
         lc.Invoke(this, new LevelChangedEventArgs(e.MaxSampleValues));
     }
 }
Esempio n. 13
0
 void onPreVolumeMeter(object sender, StreamVolumeEventArgs e)
 {
     waveformPainterL.AddMax(e.MaxSampleValues[0]);
     waveformPainterR.AddMax(e.MaxSampleValues[1]);
 }
Esempio n. 14
0
 void onPostVolumeMeter(object sender, StreamVolumeEventArgs e)
 {
     volumeMeterL.Amplitude = e.MaxSampleValues[0];
     volumeMeterR.Amplitude = e.MaxSampleValues[1];
 }
Esempio n. 15
0
 /// <summary>
 /// Event handler to update volume meter
 /// </summary>
 /// <param name="sender">Sending object</param>
 /// <param name="e">Event arguments</param>
 void sampleProvider_StreamVolume(object sender, StreamVolumeEventArgs e)
 {
     float peak;
     // If stereo, set peak to value of the highest channel
     if (e.MaxSampleValues.Count() > 1)
     {
         peak = (e.MaxSampleValues[0] > e.MaxSampleValues[1]) ? e.MaxSampleValues[0] : e.MaxSampleValues[1];
     }
     // Else if mono use only channel peak value
     else
     {
         peak = e.MaxSampleValues[0];
     }
     // Convert signal level to decibels and update level with result
     meterLevel = (float)(20 * Math.Log10(e.MaxSampleValues[0]));
     // Fire event indicating the level has changed
     if (MeterLevelChanged != null)
     {
         MeterLevelChanged(this, new EventArgs());
     }
 }