Skip to content
Snippets Groups Projects
Commit 0675b44d authored by ale's avatar ale
Browse files

a couple of minor fixes for timbre analysis

parent c9acf2f5
Branches
No related tags found
No related merge requests found
...@@ -14,12 +14,21 @@ from djrandom.mood import mood ...@@ -14,12 +14,21 @@ from djrandom.mood import mood
log = logging.getLogger(__name__) 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): class FeatureExtractor(processor.Processor):
def process(self, mp3): def process(self, mp3):
log.info('extracting features from %s' % mp3.sha1) log.info('extracting features from %s' % mp3.sha1)
try: try:
timbre_vector = mood.vector_from_file(mp3.path) timbre_vector = vector_from_file(mp3.path)
except Exception, e: except Exception, e:
log.error('error processing %s: %s' % (mp3.sha1, e)) log.error('error processing %s: %s' % (mp3.sha1, e))
return return
......
...@@ -104,8 +104,8 @@ string vector_from_file(const string& filename) ...@@ -104,8 +104,8 @@ string vector_from_file(const string& filename)
// Shift the start over so that the duration is in the middle // Shift the start over so that the duration is in the middle
mrs_natural start = (slength - numsamps)/2; mrs_natural start = (slength - numsamps)/2;
fnet->updctrl("SoundFileSource/src/mrs_natural/start", start); fnet->updctrl("SoundFileSource/src/mrs_natural/pos", start);
fnet->updctrl("SoundFileSource/src/mrs_natural/duration", numsamps); fnet->updctrl("SoundFileSource/src/mrs_natural/onSamples", numsamps);
// ----------------- Accumulator --------------------------------- // ----------------- Accumulator ---------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment