From 48c9f10e01febf7dd9dc571575e35800d9604c9e Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Fri, 24 May 2013 14:51:11 +0200 Subject: [PATCH] doc: howto implement an analyzer --- doc/timeside_2013.html | 127 +++++++++++++++++++++++++++++++++++------ 1 file changed, 108 insertions(+), 19 deletions(-) diff --git a/doc/timeside_2013.html b/doc/timeside_2013.html index 867c41b..9b897d4 100644 --- a/doc/timeside_2013.html +++ b/doc/timeside_2013.html @@ -41,11 +41,11 @@

TimeSide

open and fast web audio components

- Created by Guillaume Pellerin / @yomguy at Parisson.com + created by Guillaume Pellerin / @yomguy at Parisson.com

- +

Goals

-

We just *need* a python library to:

+

We just need a python library to:


@@ -87,12 +87,15 @@

Quick processing example

Define some processors:


-import timeside
+from timeside.decoder import *
+from timeside.grapher import *
+from timeside.analyzer import *
+from timeside.encoder import *
 
-decoder = timeside.decoder.FileDecoder('source.wav')
+decoder = timeside.decoder.FileDecoder('sweep.wav')
 grapher = timeside.grapher.Waveform()
-analyzer = timeside.analyzer.MaxLevel()
-encoder = timeside.encoder.Mp3Encoder('output.mp3')
+analyzer = timeside.analyzer.Level()
+encoder = timeside.encoder.Mp3Encoder('sweep.mp3')
 					

then, the magic pipeline:


@@ -101,13 +104,15 @@ encoder = timeside.encoder.Mp3Encoder('output.mp3')
 					

get the results:


 grapher.render(output='image.png')
-print 'Level:', analyzer.result()
+print 'Level:', analyzer.results()
 					

Quick UI example

+

+

Documentation : UiGuide

@@ -335,7 +340,7 @@ class AnalyzerResultContainer(object): self.results += [analyzer_result] def to_xml(self, data_list = None): - if data_list == None: data_list = self.results + if data_list == None: data_lit = self.results import xml.dom.minidom doc = xml.dom.minidom.Document() root = doc.createElement('telemeta') @@ -410,16 +415,100 @@ class AnalyzerResultContainer(object):
+
+

Howto implement an analyzer plugin?

+

start from this template

+

+from timeside.core import Processor, implements, interfacedoc, FixedSizeInputAdapter
+from timeside.analyzer.core import *
+from timeside.api import IValueAnalyzer
+
+import numpy
+
+class NewAnalyzer(Processor):
+    implements(IValueAnalyzer)
+
+    @interfacedoc
+    def setup(self, channels=None, samplerate=None, blocksize=None, totalframes=None):
+        super(NewAnalyzer, self).setup(channels, samplerate, blocksize, totalframes)
+        # do setup things...
+
+    @staticmethod
+    @interfacedoc
+    def id():
+        return "new_analyzer"
+
+    @staticmethod
+    @interfacedoc
+    def name():
+        return "New analyzer"
+
+    def process(self, frames, eod=False):
+        # do process things...
+        # and maybe store some results :
+        # self.results = ...
+
+        return frames, eod
+
+    def results(self):
+        container = AnalyzerResultContainer()
+
+        result = AnalyzerResult(id = self.id(), name = self.name(), unit = "something")
+        result.value = self.results
+        container.add_result(result)
 
+        # add other results in the container if needed...
+
+        return container
+
+					
+
+ +
+

Howto implement an analyzer plugin?

+ +

+from level import *
+from dc import *
+from aubio_temporal import *
+from aubio_pitch import *
+from aubio_mfcc import *
+from aubio_melenergy import *
+from aubio_specdesc import *
+from new_analyzer import * # << here
+					
+
+ +
+

Howto implement an analyzer plugin?

+

then test it! +


+from timeside.decoder import *
+from timeside.analyzer import *
+
+decoder = timeside.decoder.FileDecoder('sweep.wav')
+analyzer = timeside.analyzer.NewAnalyzer()
+
+(decoder | analyzer).run()
+
+analyzer.results()
+					
+

Links

-- 2.39.5