#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
-# Copyright (c) 2007-2013 Parisson SARL
+# Copyright (c) 2007-2014 Parisson SARL
# This file is part of TimeSide.
import sys, os.path
-usage = "usage: %s [options] -c file.conf file1.wav [file2.wav ...]" % sys.argv[0]
+usage = "usage: %s [options] -C file.conf file1.wav [file2.wav ...]" % sys.argv[0]
usage += "\n help: %s -h" % sys.argv[0]
def parse_config(path):
if __name__ == '__main__':
options, args = parse_args()
# load timeside after parse_args, to avoid gstreamer hijacking
- import timeside
+ import timeside.core
if len(args) == 0:
print usage
graphers = options.graphers
encoders = options.encoders
- all_decoders = timeside.core.processors(timeside.api.IDecoder)
- all_analyzers = timeside.core.processors(timeside.api.IAnalyzer)
- all_graphers = timeside.core.processors(timeside.api.IGrapher)
- all_encoders = timeside.core.processors(timeside.api.IEncoder)
+ all_decoders = timeside.core.processor.processors(timeside.core.api.IDecoder)
+ all_analyzers = timeside.core.processor.processors(timeside.core.api.IAnalyzer)
+ all_graphers = timeside.core.processor.processors(timeside.core.api.IGrapher)
+ all_encoders = timeside.core.processor.processors(timeside.core.api.IEncoder)
def match_id_or_class(id_or_class, processors):
matches = filter(lambda x: x.__name__ == id_or_class, processors)
encoders = map(match_encoder, encoders)
def process_file(path):
- import uuid
- from timeside.decoder.utils import get_uri
- file_uuid = str(uuid.uuid5(uuid.NAMESPACE_URL, get_uri(path) ))
+ #import uuid
+ #from timeside.plugins.decoder.utils import get_uri
+ from timeside.core import get_processor
+
+ decoder = get_processor('file_decoder')(path)
+
+ #file_uuid = str(uuid.uuid5(uuid.NAMESPACE_URL, get_uri(path) ))
+ file_uuid = decoder.sha1
+
+ result_dir = os.path.join(outputdir, file_uuid)
+ if not os.path.isdir(result_dir):
+ os.makedirs(result_dir)
+
- decoder = timeside.decoder.FileDecoder(path, start = 1)
#pipe.setup(channels = channels, samplerate = samplerate, blocksize = blocksize)
pipe = decoder
_analyzers = [a() for a in analyzers]
_graphers = [g() for g in graphers]
- _encoders = [e(os.path.join(outputdir, file_uuid + '.' + e.file_extension())) for e in encoders]
+ _encoders = [e(os.path.join(result_dir, file_uuid + '.' + e.file_extension())) for e in encoders]
for a in _analyzers:
pipe = pipe | a
pipe.run(channels = channels, samplerate = samplerate, blocksize = blocksize)
if len(_analyzers):
- results = pipe.results
- for f in r_formats:
- result_path = os.path.join(outputdir, file_uuid + '.' + f)
- getattr(results,'to_'+f)(result_path)
- if verbose : print 'saved', result_path
+ for res_uuid, result in pipe.results.items():
+
+ for f in r_formats:
+ result_path = os.path.join(result_dir, res_uuid + '.' + f)
+ getattr(result,'to_'+f)(result_path)
+ if verbose : print 'saved', result_path
if len(_graphers):
for g in _graphers:
for f in i_formats:
- graph_path = os.path.join(outputdir, file_uuid, g.id() + '.' + f)
- if not os.path.isdir(os.path.dirname(graph_path)):
- os.makedirs(os.path.dirname(graph_path))
+ graph_path = os.path.join(result_dir, g.uuid() + '.' + f)
g.render(graph_path)
if verbose : print 'saved', graph_path
if len(_encoders):
import os
import sys
-import timeside
+import timeside.core
class GrapherScheme:
return path_dict
def process(self):
- waveform = timeside.grapher.Waveform(width=self.width, height=self.height,
+
+ waveform = timeside.core.get_processor('waveform_simple')(width=self.width, height=self.height,
bg_color=self.bg_color, color_scheme=self.color_scheme)
for source, image in self.path_dict.iteritems():
if not os.path.exists(image) or self.force:
print 'Processing ', source
audio = os.path.join(os.path.dirname(__file__), source)
- decoder = timeside.decoder.FileDecoder(audio)
+ decoder = timeside.core.get_processor('file_decoder')(audio)
(decoder | waveform).run()
img_name = os.path.split(image)[1]
- image = os.path.split(image)[0]+os.sep+os.path.splitext(img_name)[0] + '_' +\
+ filename = os.path.split(image)[0]+os.sep+os.path.splitext(img_name)[0] + '_' +\
'_'.join([str(self.width), str(self.height)])+os.path.splitext(img_name)[1]
- waveform.graph.filename = image
- print 'Rendering ', waveform.graph.filename
+ #waveform.graph.filename = image
+ print 'Rendering %s '% filename
#print 'frames per pixel = ', waveform.graph.samples_per_pixel
waveform.render(output=image)
timeside-waveforms : TimeSide simple batch waveform generator
usage : timeside-waveforms /path/to/media_dir /path/to/img_dir
- infos : https://github.com/yomguy/TimeSide/
+ infos : https://github.com/Parisson/TimeSide/
version : %s
""" % version
else:
--- /dev/null
+#!/bin/bash
+
+export TEMPDIR=$(mktemp -d)
+export WAVFILE=$(python -c"from timeside.core.tools.test_samples import samples; print samples['C4_scale.wav']")
+export WAVDIR=$(python -c"from timeside.core.tools.test_samples import samples; import os;print os.path.dirname(samples['C4_scale.wav'])")
+
+echo '-----------------------------------------------------'
+echo ' timeside-launch '
+echo '-----------------------------------------------------'
+
+timeside-launch -h
+timeside-launch -C examples/presets/draw_waveform_contour_white.ts $WAVFILE -o $TEMPDIR -R 'json','yaml','xml','hdf5' -v
+timeside-launch -C examples/presets/transcode_media.ts $WAVFILE -o $TEMPDIR -R 'json','yaml','xml','hdf5' -v
+timeside-launch -C examples/presets/extract_aubio_bpm.ts $WAVFILE -o $TEMPDIR -R 'json','yaml','xml','hdf5' -v
+
+echo '-----------------------------------------------------'
+echo ' timeside-waveforms '
+echo '-----------------------------------------------------'
+
+timeside-waveforms $WAVDIR $TEMPDIR
+ls $TEMPDIR
\ No newline at end of file