Open artpelling opened 7 months ago
I think we once discussed that it should be possible to have float sampling rates to be most flexible, but it definately should not be an array. We could cast it to int, if abs(int(sampling_rate) - sampling_rate) < tolerance
. Would that be a good compromise?
Would that be a good compromise?
I was thinking more somehing like:
if hasattr(sampling_rate, '__iter__'):
assert len(sampling_rate) == 1
sampling_rate = sampling_rate[0]
?
Ah, yes - that would be needed but would not cast to integer. But it works woth float as desired:
signal = pf.Signal([0, 1, 0, 0], 22.5)
gd = pf.dsp.group_delay(signal)
Regarding casting to integer: I noticed that a float
fails when writing to file, i.e.
pyfar.io.write_audio(pyfar.Signal(array, sampling_rate=44100.0))
will fail. I think writing to file should round to the nearest integer, cast the type and throw a warning on nonzero roundoff. What do you think?
Can you check your pyfar version. It works for me in 0.6.3 and only thros an error if acutally having a non integer sampling rate. We fixed it a while ago following the idea you also have :)
The
sampling_rate
kwarg in theSignal
constructor is not thoroughly typechecked or parsed which leads to errors down the line that are hard to backtrace. IMOsampling_rate
should be cast as an integer. Of course havingsampling_rate
as a 2d-array is not a great design choice but happens sometimes, e.g. when reading data from.mat
filesMWE: