Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SignalProcessingTools/__version__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__title__ = "SignalProcessingTools"
__version__ = "1.2.4"
__version__ = "1.2.5"
__author__ = "Bruno Zuada Coelho, Aron Noordam"
18 changes: 9 additions & 9 deletions SignalProcessingTools/time_signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,32 +500,32 @@ def v_eff_SBR(self, n: int = 4, tau: float = 0.125):
v0 = 1 / 1000 # Reference velocity [m/s]
f0 = 5.6 # Reference frequency [Hz]

# Handle even/odd signal length for FFT
# Handle even/odd signal length
if self.signal.shape[0] % 2 != 0:
nv1 = int(self.signal.shape[0] / 2 + 0.5)
nv2 = int(self.signal.shape[0] / 2 - 0.5)
sig = np.append(self.signal, 0.)
else:
nv1 = int(self.signal.shape[0] / 2)
nv2 = int(self.signal.shape[0] / 2)
sig = self.signal
nv1 = int(sig.shape[0] / 2)
nv2 = int(sig.shape[0] / 2)

# Calculate frequency resolution
df = 1 / (1 / self.Fs * self.signal.shape[0])
df = 1 / (1 / self.Fs * sig.shape[0])
freq = np.arange(df, (nv1 + 1) * df, df)

# Create high-pass weighting filter (human perception curve)
Hv = (1 / v0) * 1 / (np.sqrt(1 + (f0 / freq)**2))
Hv = np.append(0, Hv) # Add DC component

# Create low-pass filter with 50 Hz cutoff
cut_off_number = int(np.ceil(50 / df))
# Create low-pass filter with 80 Hz cutoff
cut_off_number = int(np.ceil(80 / df))
if cut_off_number < nv1:
Hv2 = np.zeros(Hv.shape[0])
Hv2[:cut_off_number + 1] = 1
else:
Hv2 = np.ones(Hv.shape[0])

# Applies the frequency weighting functions
Fv = np.fft.fft(self.signal)
Fv = np.fft.fft(sig)
Fhv = Hv2 * Hv * Fv[:nv1 + 1]
Fv = np.append(Fhv, np.flipud(np.conj(Fhv[1:nv2])))
v_eff = np.real(np.fft.ifft(Fv))
Expand Down
Loading
Loading