Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/common/Util
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@member.fsf.org>2008-12-19 03:32:22 (GMT)
committer Aleksey Lim <alsroot@member.fsf.org>2008-12-19 23:50:57 (GMT)
commit11ddb4cbf9b695fdd042105d7e341f20e347e018 (patch)
tree8a7fa92756418f5ea3919f63303f107a92a7b697 /common/Util
parentfbee8354739ecb45aa70345a7ee3a7b0584e6766 (diff)
move micrec code to OS.py
Diffstat (limited to 'common/Util')
-rw-r--r--common/Util/OS.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/common/Util/OS.py b/common/Util/OS.py
index 6bea80b..605fbf4 100644
--- a/common/Util/OS.py
+++ b/common/Util/OS.py
@@ -1,5 +1,8 @@
import commands
import logging
+import os
+
+import common.Config as Config
def system(*args):
cmd = ' '.join(args)
@@ -10,3 +13,24 @@ def system(*args):
return status
+def arecord(duration, crop_csd, dst):
+ tmp_file = os.path.join(Config.TMP_DIR, 'tempMic.wav')
+ out_file = os.path.join(Config.TMP_DIR, 'micTemp.wav')
+ crop_file = os.path.join(Config.FILES_DIR, crop_csd)
+ dst_file = os.path.join(Config.DATA_DIR, dst)
+
+ if system(Config.ARECORD, "-d", str(duration), tmp_file)[0] != 0:
+ logging.error('arecord failed')
+ return False
+
+ system("csound", "--strset999=" + Config.TMP_DIR, crop_file)
+
+ if os.path.isfile(dst):
+ os.remove(dst_file)
+
+ if os.path.isfile(out_file):
+ os.rename(out_file, dst_file)
+ os.remove(tmp_file)
+ else:
+ logging.debug('crop failed')
+ os.rename(tmp_file, dst_file)