summaryrefslogtreecommitdiff
path: root/examples/wire.py
diff options
context:
space:
mode:
authorMatthias Geier <Matthias.Geier@gmail.com>2016-08-05 09:40:51 +0200
committerMatthias Geier <Matthias.Geier@gmail.com>2016-08-05 09:40:51 +0200
commit5408733e7f7b3ed1f350bbae8d74e758a00f0be7 (patch)
treebdac9db11b3e428a521342666ede37c087f2fc38 /examples/wire.py
parent104d912af4bd54bc34521c43ab53332e933425a0 (diff)
Accept device substrings in all examples
Diffstat (limited to 'examples/wire.py')
-rwxr-xr-xexamples/wire.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/examples/wire.py b/examples/wire.py
index ce9cfe7..a980d7f 100755
--- a/examples/wire.py
+++ b/examples/wire.py
@@ -7,9 +7,19 @@ See https://www.assembla.com/spaces/portaudio/subversion/source/HEAD/portaudio/t
import argparse
import logging
+
+def int_or_str(text):
+ """Helper function for argument parsing."""
+ try:
+ return int(text)
+ except ValueError:
+ return text
+
parser = argparse.ArgumentParser(description=__doc__)
-parser.add_argument("-i", "--input-device", type=int, help="input device ID")
-parser.add_argument("-o", "--output-device", type=int, help="output device ID")
+parser.add_argument("-i", "--input-device", type=int_or_str,
+ help="input device ID or substring")
+parser.add_argument("-o", "--output-device", type=int_or_str,
+ help="output device ID or substring")
parser.add_argument("-c", "--channels", type=int, default=2,
help="number of channels")
parser.add_argument("-t", "--dtype", help="audio data type")