diff options
| author | mikeos <mike.osipov@gmail.com> | 2013-09-28 16:38:17 +0400 |
|---|---|---|
| committer | mikeos <mike.osipov@gmail.com> | 2013-09-28 16:38:17 +0400 |
| commit | 07aa2154f13a2c90ac3f98b676cddd4e2b1a82b8 (patch) | |
| tree | 15e69b7874d1e95570a536bbfe69a5a78e85f058 /formats/__base__.py | |
| parent | 1bb90cf78b14c4cc228826e4d5443f4de047ed24 (diff) | |
support of different output encoding formats
Diffstat (limited to 'formats/__base__.py')
| -rw-r--r-- | formats/__base__.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/formats/__base__.py b/formats/__base__.py new file mode 100644 index 0000000..4bb6598 --- /dev/null +++ b/formats/__base__.py @@ -0,0 +1,25 @@ +class BaseHandler: + def __init__(self, logger = None): + self.logger = logger + self.buf = [] + + def log(self, fmt, *args): + if self.logger is not None: + self.logger(fmt, *args) + + def add(self, *args): + self.buf.extend(args) + + def build(self, join=True): + data = " ".join(self.buf) if join else self.buf + self.buf = [] + + return data + + def add_sox_args(self, opt, info): + if opt.sample_rate and opt.sample_rate != info.sample_rate: + self.add("-r %d" % opt.sample_rate) + if opt.bits_per_sample and opt.bits_per_sample != info.bits_per_sample: + self.add("-b %d" % opt.bits_per_sample) + if opt.channels and opt.channels != info.channels: + self.add("-c %d" % opt.channels) |
