File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ using NUnit . Framework ;
2
+ using System ;
3
+ using System . Collections . Generic ;
4
+ using System . Linq ;
5
+ using System . Text ;
6
+
7
+ namespace Spectrogram . Tests
8
+ {
9
+ class TestAGC
10
+ {
11
+ //[Test]
12
+ public void Test_QRSS_noAGC ( )
13
+ {
14
+ string wavFilePath = "../../../../../data/qrss-10min.wav" ;
15
+ ( int sampleRate , double [ ] L ) = WavFile . ReadMono ( wavFilePath ) ;
16
+
17
+
18
+ int fftSize = 8192 ;
19
+ var spec = new Spectrogram ( sampleRate , fftSize , stepSize : 2000 , maxFreq : 3000 ) ;
20
+ spec . Add ( L ) ;
21
+ spec . SaveImage ( "qrss-AGCoff.png" , intensity : 3 ) ;
22
+
23
+ var ffts = spec . GetFFTs ( ) ;
24
+ double normalIntensity = 2 ;
25
+ for ( int i = 0 ; i < ffts . Count ; i ++ )
26
+ {
27
+ double [ ] sorted = new double [ ffts [ i ] . Length ] ;
28
+ ffts [ i ] . CopyTo ( sorted , 0 ) ;
29
+ Array . Sort ( sorted ) ;
30
+
31
+ double percentile = 0.25 ;
32
+ int percentileIndex = ( int ) ( percentile * ffts [ 0 ] . Length ) ;
33
+ double floorValue = sorted [ percentileIndex ] ;
34
+
35
+ for ( int y = 0 ; y < ffts [ i ] . Length ; y ++ )
36
+ {
37
+ ffts [ i ] [ y ] = ffts [ i ] [ y ] / floorValue * normalIntensity ;
38
+ }
39
+
40
+ Console . WriteLine ( floorValue ) ;
41
+ }
42
+
43
+ spec . SaveImage ( "qrss-AGCon.png" , intensity : 3 ) ;
44
+ }
45
+ }
46
+ }
You can’t perform that action at this time.
0 commit comments