@@ -2933,9 +2933,15 @@ def wrsamp(
2933
2933
raise Exception (
2934
2934
"When using d_signal or e_d_signal, must also specify 'fmt', 'gain', and 'baseline' fields"
2935
2935
)
2936
+ if (e_p_signal is not None or e_d_signal is not None ) and samps_per_frame is None :
2937
+ raise Exception (
2938
+ "When passing e_p_signal or e_d_signal, you also need to specify samples per frame for each channel"
2939
+ )
2936
2940
2937
- # If samps_per_frame is a list, check that it aligns as expected with the channels in the signal
2938
- if isinstance (samps_per_frame , list ):
2941
+ # If samps_per_frame is provided, check that it aligns as expected with the channels in the signal
2942
+ if samps_per_frame :
2943
+ # Get the number of elements being passed in samps_per_frame
2944
+ samps_per_frame_length = len (samps_per_frame ) if isinstance (samps_per_frame , list ) else 1
2939
2945
# Get properties of the signal being passed
2940
2946
first_valid_signal = next (
2941
2947
signal for signal in signal_list if signal is not None
@@ -2952,13 +2958,11 @@ def wrsamp(
2952
2958
raise TypeError (
2953
2959
"Unsupported signal format. Must be ndarray or list of lists."
2954
2960
)
2955
-
2956
2961
# Check that the number of channels matches the number of samps_per_frame entries
2957
- if num_sig_channels != len ( samps_per_frame ) :
2962
+ if num_sig_channels != samps_per_frame_length :
2958
2963
raise Exception (
2959
- "When passing samps_per_frame as a list , it must have the same number of entries as the signal has channels"
2964
+ "When passing samps_per_frame, it must have the same number of entries as the signal has channels"
2960
2965
)
2961
-
2962
2966
# Check that the number of frames is the same across all channels
2963
2967
frames = [a / b for a , b in zip (channel_samples , samps_per_frame )]
2964
2968
if len (set (frames )) > 1 :
0 commit comments