Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.txt files handling #40

Merged
merged 6 commits into from
Feb 24, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
15 changes: 14 additions & 1 deletion mosqito/functions/shared/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,21 @@ def load(file, calib=1, mat_signal="", mat_fs=""):
fs = matfile[mat_fs]
fs = fs[:, 0]

# load the .txt file content
elif file[-3:] == "txt":
# extract the values
data = np.loadtxt(file)
signal = data[:,1]
time = data[:,0]

# calibration for for the signal to be in Pa
signal = signal * calib

# calculate sampling frequency
fs = 1/(time[1]-time[0])

else:
raise ValueError("""ERROR: only .wav .mat or .uff files are supported""")
raise ValueError("""ERROR: only .wav .mat .uff or .txt files are supported""")

# resample to 48kHz to allow calculation
if fs != 48000:
Expand Down
Binary file not shown.
Binary file not shown.
Loading