From 0675b44db1927bb6c4fa00f48a0acf0a8be84e67 Mon Sep 17 00:00:00 2001 From: ale <ale@incal.net> Date: Sun, 27 Nov 2011 10:00:05 +0000 Subject: [PATCH] a couple of minor fixes for timbre analysis --- server/djrandom/mood/extract_features.py | 11 ++++++++++- server/djrandom/mood/mood.cc | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/server/djrandom/mood/extract_features.py b/server/djrandom/mood/extract_features.py index 5b3a4a3..bf9f6e1 100644 --- a/server/djrandom/mood/extract_features.py +++ b/server/djrandom/mood/extract_features.py @@ -14,12 +14,21 @@ from djrandom.mood import mood log = logging.getLogger(__name__) +def vector_from_file(path): + ln = os.path.join('/tmp', '__analysis_%s.mp3' % os.path.basename(path)) + os.symlink(path, ln) + try: + return mood.vector_from_file(ln) + finally: + os.unlink(ln) + + class FeatureExtractor(processor.Processor): def process(self, mp3): log.info('extracting features from %s' % mp3.sha1) try: - timbre_vector = mood.vector_from_file(mp3.path) + timbre_vector = vector_from_file(mp3.path) except Exception, e: log.error('error processing %s: %s' % (mp3.sha1, e)) return diff --git a/server/djrandom/mood/mood.cc b/server/djrandom/mood/mood.cc index c3aa4e2..df18fb1 100644 --- a/server/djrandom/mood/mood.cc +++ b/server/djrandom/mood/mood.cc @@ -104,8 +104,8 @@ string vector_from_file(const string& filename) // Shift the start over so that the duration is in the middle mrs_natural start = (slength - numsamps)/2; - fnet->updctrl("SoundFileSource/src/mrs_natural/start", start); - fnet->updctrl("SoundFileSource/src/mrs_natural/duration", numsamps); + fnet->updctrl("SoundFileSource/src/mrs_natural/pos", start); + fnet->updctrl("SoundFileSource/src/mrs_natural/onSamples", numsamps); // ----------------- Accumulator --------------------------------- -- GitLab