]> git.parisson.com Git - timeside.git/commitdiff
- fix waveform peaks and centroid
authoryomguy <yomguy@parisson.com>
Wed, 3 Mar 2010 12:29:10 +0000 (12:29 +0000)
committeryomguy <yomguy@parisson.com>
Wed, 3 Mar 2010 12:29:10 +0000 (12:29 +0000)
- remove unnecessary adapters
- tested WAV, FLAC, OGG and MP3, mono and stereo. decoder OK
- TODO : breaks spectrogram linearity

tests/api/examples.py
tests/api/test_pipe_spectrogram.py
tests/api/test_pipe_waveform.py

index 3a9f582d5d19043472fbb70e78a5639d9a35095c..475c65096ec492a54eafe30c02d174bd5173ad25 100644 (file)
@@ -210,7 +210,7 @@ class WavEncoder(Processor):
 class Waveform(Processor):
     implements(IGrapher)
 
-    BUFFER_SIZE = 1024
+    FFT_SIZE = 0x400
 
     @interfacedoc
     def __init__(self, width=None, height=None, output=None, bg_color=None, color_scheme=None):
@@ -247,14 +247,12 @@ class Waveform(Processor):
         super(Waveform, self).setup(channels, samplerate, nframes)
         if self.graph:
             self.graph = None
-        self.adapter = FixedSizeInputAdapter(self.BUFFER_SIZE, channels, pad=True)
-        self.graph = WaveformImage(self.width, self.height, self.nframes(), self.samplerate(), self.BUFFER_SIZE,
+        self.graph = WaveformImage(self.width, self.height, self.nframes(), self.samplerate(), self.FFT_SIZE,
                                     bg_color=self.bg_color, color_scheme=self.color_scheme, filename=self.filename)
 
     @interfacedoc
     def process(self, frames, eod=False):
-        for buffer, end in self.adapter.process(frames, eod):
-            self.graph.process(buffer, end)
+        self.graph.process(frames, eod)
         return frames, eod
 
     @interfacedoc
@@ -267,7 +265,7 @@ class Waveform(Processor):
 class Spectrogram(Processor):
     implements(IGrapher)
 
-    BUFFER_SIZE = 512
+    FFT_SIZE = 0x1000
 
     @interfacedoc
     def __init__(self, width=None, height=None, output=None, bg_color=None, color_scheme=None):
@@ -304,14 +302,12 @@ class Spectrogram(Processor):
         super(Spectrogram, self).setup(channels, samplerate, nframes)
         if self.graph:
             self.graph = None
-        self.adapter = FixedSizeInputAdapter(self.BUFFER_SIZE, channels, pad=True)
-        self.graph = SpectrogramImage(self.width, self.height, self.nframes(), self.samplerate(), self.BUFFER_SIZE,
+        self.graph = SpectrogramImage(self.width, self.height, self.nframes(), self.samplerate(), self.FFT_SIZE,
                                     bg_color=self.bg_color, color_scheme=self.color_scheme, filename=self.filename)
 
     @interfacedoc
     def process(self, frames, eod=False):
-        for buffer, end in self.adapter.process(frames, eod):
-            self.graph.process(buffer, end)
+        self.graph.process(frames, eod)
         return frames, eod
 
     @interfacedoc
index 742e4c1e10422e013e4f1fada5738cea1362ea28..ec06865eb2f695831790d6f33a0f53181d992b33 100644 (file)
@@ -11,7 +11,17 @@ else:
     from timeside.tests.api.examples import FileDecoder, WavEncoder
 
 image_file = './spectrogram.png'
-source = os.path.join(os.path.dirname(__file__), "../samples/sweep_source.mp3")
+
+# mono
+#source = os.path.join(os.path.dirname(__file__), "../samples/sweep_source.wav")
+#source = os.path.join(os.path.dirname(__file__), "../samples/guitar.wav")
+#source = os.path.join(os.path.dirname(__file__), "../samples/sweep_source.mp3")
+
+# stereo
+source = os.path.join(os.path.dirname(__file__), "../samples/sweep.wav")
+#source = os.path.join(os.path.dirname(__file__), "../samples/guitar_stereo.wav")
+#source = os.path.join(os.path.dirname(__file__), "/home/momo/music/flac/Isabelle Aboulker/Mon imagier des instruments/16 - Isabelle Aboulker - 16 instru.flac")
+#source = os.path.join(os.path.dirname(__file__), "/home/momo/music/ogg/Emilie_Jolie/01 - Henri Salvador - Prologue.ogg")
 
 decoder  = FileDecoder(source)
 spectrogram = examples.Spectrogram(width=1024, height=256, output=image_file, bg_color=(0,0,0), color_scheme='default')
index 24b5242db209c51a59f8e5d4361193f9befd44c7..82ba4a9f8a3ee1d6af527a30d52a92d86db32ab8 100644 (file)
@@ -11,7 +11,17 @@ else:
     from timeside.tests.api.examples import FileDecoder, WavEncoder
 
 image_file = './waveform.png'
-source = os.path.join(os.path.dirname(__file__), "../samples/sweep_source.mp3")
+
+# mono
+#source = os.path.join(os.path.dirname(__file__), "../samples/sweep_source.wav")
+#source = os.path.join(os.path.dirname(__file__), "../samples/guitar.wav")
+#source = os.path.join(os.path.dirname(__file__), "../samples/sweep_source.mp3")
+
+# stereo
+source = os.path.join(os.path.dirname(__file__), "../samples/sweep.wav")
+#source = os.path.join(os.path.dirname(__file__), "../samples/guitar_stereo.wav")
+#source = os.path.join(os.path.dirname(__file__), "/home/momo/music/flac/Isabelle Aboulker/Mon imagier des instruments/16 - Isabelle Aboulker - 16 instru.flac")
+#source = os.path.join(os.path.dirname(__file__), "/home/momo/music/ogg/Emilie_Jolie/01 - Henri Salvador - Prologue.ogg")
 
 decoder  = FileDecoder(source)
 waveform = examples.Waveform(width=1024, height=256, output=image_file, bg_color=(0,0,0), color_scheme='default')