summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/pcm2pdm.py6
-rw-r--r--tools/pdm2pcm.py21
2 files changed, 21 insertions, 6 deletions
diff --git a/tools/pcm2pdm.py b/tools/pcm2pdm.py
index 3a1fac6..4279eb2 100644
--- a/tools/pcm2pdm.py
+++ b/tools/pcm2pdm.py
@@ -56,7 +56,9 @@ def parse():
parser = argparse.ArgumentParser(description='Process an input file and write to an output file.')
parser.add_argument('-i', '--input', type=str, required=True, help='Path to the input file')
parser.add_argument('-o', '--output', type=str, required=True, help='Path to the output file')
-
+ #parser.add_argument('--samplerate', type=int, default=16000)
+ parser.add_argument('--oversample', type=int, default=64)
+
args = parser.parse_args()
return args
@@ -65,7 +67,7 @@ def main():
out_path = args.output
- pdm_data = convert_file(args.input, oversample=64)
+ pdm_data = convert_file(args.input, oversample=args.oversample)
with open(out_path, 'wb') as f:
save_pdm_bin(pdm_data, f)
diff --git a/tools/pdm2pcm.py b/tools/pdm2pcm.py
index b333a6f..f21803a 100644
--- a/tools/pdm2pcm.py
+++ b/tools/pdm2pcm.py
@@ -22,15 +22,28 @@ def pdm_to_pcm(pdm_signal, decimation_factor=64):
pcm_signal = filtered[::decimation_factor]
return pcm_signal
+def parse():
+ import argparse
+
+ parser = argparse.ArgumentParser(description='Process an input file and write to an output file.')
+ parser.add_argument('-i', '--input', type=str, required=True, help='Path to the input file')
+ parser.add_argument('-o', '--output', type=str, required=True, help='Path to the output file')
+ parser.add_argument('--samplerate', type=int, default=16000)
+ parser.add_argument('--oversample', type=int, default=64)
+
+ args = parser.parse_args()
+ return args
+
def main():
+ args = parse()
- pdm_path = 'test_tone.pdm'
- out_path = 'output.wav'
+ pdm_path = args.input
+ out_path = args.output
pdm_data = load_pdm_file(pdm_path)
# Convert to PCM
- oversample = 64
- samplerate = 16000
+ oversample = args.oversample
+ samplerate = args.samplerate
pcm_data = pdm_to_pcm(pdm_data, decimation_factor=oversample)
# Normalize and save to WAV