33Multichannel processing validation tests.
44"""
55
6- import os
7- import sys
8-
96import numpy as np
10-
11- # Ensure local package is used
12- sys .path .insert (0 , os .path .abspath (os .path .join (os .path .dirname (__file__ ), "../src" )))
13-
147from pyoctaveband import octavefilter
158
169
@@ -29,36 +22,21 @@ def test_multichannel() -> None:
2922
3023 x = np .vstack ((ch1 , ch2 ))
3124
32- print (f"Testing stereo input with shape: { x .shape } " )
3325 spl , freq = octavefilter (x , fs , fraction = 3 )
3426
35- print (f"Resulting SPL shape: { spl .shape } " )
3627 assert spl .shape == (2 , len (freq )), "Output SPL should maintain channel count"
3728
3829 # Verify Channel 1 (Tone) peaks near 500Hz
3930 target_idx = np .argmin (np .abs (np .array (freq ) - 500 ))
4031 max_idx = np .argmax (spl [0 ])
41- print (f"Ch 1 Peak: { freq [max_idx ]:.1f} Hz (Target: { freq [target_idx ]:.1f} Hz)" )
4232 assert abs (max_idx - target_idx ) <= 1 , "Tone peak not detected in correct band"
4333
4434 # Verify Channel 2 (Noise) has lower variance than Tone
4535 std_tone = np .std (spl [0 ])
4636 std_noise = np .std (spl [1 ])
47- print (f"SPL Std Dev - Tone: { std_tone :.2f} , Noise: { std_noise :.2f} " )
4837 assert std_tone > std_noise , "Tone should have higher spectral variance than noise"
4938
50- print ("Multichannel SPL test: OK" )
51-
5239 # Verify time-domain band splitting
53- print ("Testing 'sigbands' mode..." )
5440 _ , _ , xb = octavefilter (x , fs , fraction = 3 , sigbands = True )
55- if xb is None :
56- raise ValueError ("xb should not be None when sigbands=True" )
57-
58- print (f"Extracted { len (xb )} bands." )
41+ assert xb is not None , "xb should not be None when sigbands=True"
5942 assert xb [0 ].shape == (2 , len (t )), "Bands should maintain stereo shape and length"
60- print ("Multichannel sigbands test: OK" )
61-
62-
63- if __name__ == "__main__" :
64- test_multichannel ()
0 commit comments