@@ -10,16 +10,28 @@ namespace NAudio.Extras
1010 /// </summary>
1111 public class SampleAggregator : ISampleProvider
1212 {
13- // volume
13+ /// <summary>
14+ /// Raised to indicate the maximum volume level in this period
15+ /// </summary>
1416 public event EventHandler < MaxSampleEventArgs > MaximumCalculated ;
1517 private float maxValue ;
1618 private float minValue ;
19+ /// <summary>
20+ /// Notification count, number of samples between MaximumCalculated events
21+ /// </summary>
1722 public int NotificationCount { get ; set ; }
1823 int count ;
1924
20- // FFT
25+ /// <summary>
26+ /// Raised to indicate that a block of samples has had an FFT performed on it
27+ /// </summary>
2128 public event EventHandler < FftEventArgs > FftCalculated ;
29+
30+ /// <summary>
31+ /// If true, performs an FFT on each block of samples
32+ /// </summary>
2233 public bool PerformFFT { get ; set ; }
34+
2335 private readonly Complex [ ] fftBuffer ;
2436 private readonly FftEventArgs fftArgs ;
2537 private int fftPos ;
@@ -29,6 +41,11 @@ public class SampleAggregator : ISampleProvider
2941
3042 private readonly int channels ;
3143
44+ /// <summary>
45+ /// Creates a new SampleAggregator
46+ /// </summary>
47+ /// <param name="source">source sample provider</param>
48+ /// <param name="fftLength">FFT length, must be a power of 2</param>
3249 public SampleAggregator ( ISampleProvider source , int fftLength = 1024 )
3350 {
3451 channels = source . WaveFormat . Channels ;
@@ -48,7 +65,9 @@ static bool IsPowerOfTwo(int x)
4865 return ( x & ( x - 1 ) ) == 0 ;
4966 }
5067
51-
68+ /// <summary>
69+ /// Reset the volume calculation
70+ /// </summary>
5271 public void Reset ( )
5372 {
5473 count = 0 ;
@@ -81,8 +100,14 @@ private void Add(float value)
81100 }
82101 }
83102
103+ /// <summary>
104+ /// Gets the WaveFormat of this Sample Provider
105+ /// </summary>
84106 public WaveFormat WaveFormat => source . WaveFormat ;
85107
108+ /// <summary>
109+ /// Reads samples from this sample provider
110+ /// </summary>
86111 public int Read ( float [ ] buffer , int offset , int count )
87112 {
88113 var samplesRead = source . Read ( buffer , offset , count ) ;
@@ -95,25 +120,46 @@ public int Read(float[] buffer, int offset, int count)
95120 }
96121 }
97122
123+ /// <summary>
124+ /// Max sample event args
125+ /// </summary>
98126 public class MaxSampleEventArgs : EventArgs
99127 {
128+ /// <summary>
129+ /// Creates a new MaxSampleEventArgs
130+ /// </summary>
100131 [ DebuggerStepThrough ]
101132 public MaxSampleEventArgs ( float minValue , float maxValue )
102133 {
103134 MaxSample = maxValue ;
104135 MinSample = minValue ;
105136 }
137+ /// <summary>
138+ /// Maximum sample value in this period
139+ /// </summary>
106140 public float MaxSample { get ; private set ; }
141+ /// <summary>
142+ /// Minimum sample value in this period
143+ /// </summary>
107144 public float MinSample { get ; private set ; }
108145 }
109146
147+ /// <summary>
148+ /// FFT Event Args
149+ /// </summary>
110150 public class FftEventArgs : EventArgs
111151 {
152+ /// <summary>
153+ /// Creates a new FFTEventArgs
154+ /// </summary>
112155 [ DebuggerStepThrough ]
113156 public FftEventArgs ( Complex [ ] result )
114157 {
115158 Result = result ;
116159 }
160+ /// <summary>
161+ /// Result of FFT
162+ /// </summary>
117163 public Complex [ ] Result { get ; private set ; }
118164 }
119165}
0 commit comments