-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9ba6978
commit 8d27643
Showing
13 changed files
with
164 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import multiprocessing as mp | ||
from pathlib import Path | ||
|
||
|
||
def get_default_nprocs(): | ||
return max(1, int(0.8*mp.cpu_count())) | ||
|
||
|
||
def clear_dat_folder(dat_folder_str=None): | ||
# clear dat folder | ||
dat_path = Path(dat_folder_str) | ||
if not dat_path.exists(): | ||
dat_path.mkdir(parents=True) | ||
else: | ||
assert dat_path.is_dir() | ||
|
||
assert dat_path.exists() | ||
assert dat_path.is_dir() | ||
for f in dat_path.glob('*'): | ||
try: | ||
f.unlink() | ||
except OSError as e: | ||
print("Error: %s : %s" % (f, e.strerror)) | ||
|
||
|
||
def yes_or_no(question): | ||
while "the answer is invalid": | ||
reply = str(input(question+' (y/n): ')).lower().strip() | ||
if reply[:1] == 'y': | ||
return True | ||
if reply[:1] == 'n': | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import numpy as np | ||
import scipy.io.wavfile | ||
|
||
|
||
def wavread(fname): | ||
fs, data = scipy.io.wavfile.read(fname) # reads in (Nsamples,Nchannels) | ||
if data.dtype == np.int16: | ||
data = data/32768.0 | ||
fs = np.float64(fs) | ||
return fs, np.float64(data.T) | ||
|
||
|
||
def wavwrite(fname, fs, data): | ||
# expects (Nchannels,Nsamples), this will also assert that | ||
data = np.atleast_2d(data) | ||
# reads in (Nsamples,Nchannels) | ||
scipy.io.wavfile.write(fname, int(fs), np.float32(data.T)) | ||
print(f'wrote {fname} at fs={fs/1000:.2f} kHz') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.