Skip to content

Commit

Permalink
Merge pull request #40 from wantysal/txt_handling
Browse files Browse the repository at this point in the history
Thanks for this contribution
  • Loading branch information
Martin Glesser authored Feb 24, 2022
2 parents b19ba0f + a1535e2 commit 76122ce
Show file tree
Hide file tree
Showing 3 changed files with 355 additions and 3,044 deletions.
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
Loading

0 comments on commit 76122ce

Please sign in to comment.