File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ """
2
+ sample rate: 44100
3
+ values: 166671
4
+ value 12345: 4435
5
+ """
6
+ from scipy .io import wavfile
7
+ import pathlib
8
+ PATH_HERE = pathlib .Path (__file__ ).parent
9
+ PATH_DATA = PATH_HERE .joinpath ("../../data" )
10
+
11
+ if __name__ == "__main__" :
12
+ wavFilePath = PATH_DATA .joinpath ("cant-do-that-44100.wav" )
13
+ samplerate , data = wavfile .read (wavFilePath )
14
+ print (f"sample rate: { samplerate } " )
15
+ print (f"values: { len (data )} " )
16
+ print (f"value 12345: { data [12345 ]} " )
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 . Text ;
5
+
6
+ namespace Spectrogram . Tests
7
+ {
8
+ class AudioFileTests
9
+ {
10
+ /// <summary>
11
+ /// Compare values read from the WAV reader against those read by Python's SciPy module (see script in /dev folder)
12
+ /// </summary>
13
+ [ Test ]
14
+ public void Test_AudioFile_KnownValues ( )
15
+ {
16
+ ( double [ ] audio , int sampleRate ) = AudioFile . ReadWAV ( "../../../../../data/cant-do-that-44100.wav" , multiplier : 32_000 ) ;
17
+
18
+ Assert . AreEqual ( 44100 , sampleRate ) ;
19
+ Assert . AreEqual ( 166671 , audio . Length ) ;
20
+ Assert . AreEqual ( 4435 , audio [ 12345 ] , 1000 ) ;
21
+ }
22
+ }
23
+ }
You can’t perform that action at this time.
0 commit comments