]> git.parisson.com Git - timeside.git/commitdiff
fix blocksize
authoryomguy <yomguy@parisson.com>
Wed, 26 Sep 2012 22:32:11 +0000 (00:32 +0200)
committeryomguy <yomguy@parisson.com>
Wed, 26 Sep 2012 22:32:11 +0000 (00:32 +0200)
tests/testinputadapter.py
timeside/core.py
timeside/grapher/core.py
timeside/grapher/waveform.py

index 5879955377ba2105170f9b2a8fc29cfcf6bb9d9a..319d8a3529abc7bcbce755785c1823d59c0fe8f4 100644 (file)
@@ -27,7 +27,7 @@ class TestFixedSizeInputAdapter(TestCase):
         "Test simple stream with two channels"
         adapter = FixedSizeInputAdapter(4, 2)
 
-        self.assertEquals(len(self.data), adapter.totalframes(len(self.data)))
+        self.assertEquals(len(self.data), adapter.blocksize(len(self.data)))
 
         self.assertIOEquals(adapter, self.data[0:1], False, [])
         self.assertIOEquals(adapter, self.data[1:5], False, [self.data[0:4]], False)
@@ -43,10 +43,10 @@ class TestFixedSizeInputAdapter(TestCase):
         "Test automatic padding support"
         adapter = FixedSizeInputAdapter(4, 2, pad=True)
 
-        self.assertEquals(len(self.data) + 2, adapter.totalframes(len(self.data)))
+        self.assertEquals(len(self.data) + 2, adapter.blocksize(len(self.data)))
 
-        self.assertIOEquals(adapter, self.data[0:21], False, 
-            [self.data[0:4], self.data[4:8], self.data[8:12], self.data[12:16], self.data[16:20]], 
+        self.assertIOEquals(adapter, self.data[0:21], False,
+            [self.data[0:4], self.data[4:8], self.data[8:12], self.data[12:16], self.data[16:20]],
             False)
 
         self.assertIOEquals(adapter, self.data[21:22], True, [[
@@ -60,8 +60,8 @@ class TestFixedSizeInputAdapter(TestCase):
         "Test a stream which contain a multiple number of buffers"
         adapter = FixedSizeInputAdapter(4, 2)
 
-        self.assertIOEquals(adapter, self.data[0:20], True, 
-            [self.data[0:4], self.data[4:8], self.data[8:12], self.data[12:16], self.data[16:20]], 
+        self.assertIOEquals(adapter, self.data[0:20], True,
+            [self.data[0:4], self.data[4:8], self.data[8:12], self.data[12:16], self.data[16:20]],
             True)
 
 
index b183f0b88c3156352870701b1cc8cd09c4385658..6bdf6d3b52c62c64ce7189a3978cfbb6040f7c66 100644 (file)
@@ -112,21 +112,15 @@ class FixedSizeInputAdapter(object):
         self.len         = 0
         self.pad         = pad
 
-    def totalframes(self, input_totalframes):
+    def blocksize(self, input_totalframes):
         """Return the total number of frames that this adapter will output according to the
         input_totalframes argument"""
 
-        totalframes = input_totalframes
+        blocksize = input_totalframes
         if self.pad:
             mod = input_totalframes % self.buffer_size
             if mod:
-                totalframes += self.buffer_size - mod
-
-        return totalframes
-
-    def blocksize(self, blocksize):
-        """Return the total number of frames that this adapter will output according to the
-        input_blocksize argument"""
+                blocksize += self.buffer_size - mod
 
         return blocksize
 
@@ -216,7 +210,7 @@ class ProcessPipe(object):
         # setup/reset processors and configure channels and samplerate throughout the pipe
         source.setup()
         #FIXME: wait for decoder mainloop
-        time.sleep(0.2)
+        time.sleep(0.1)
 
         last = source
         for item in items:
@@ -224,6 +218,7 @@ class ProcessPipe(object):
                        samplerate = last.samplerate(),
                        blocksize = last.blocksize(),
                        totalframes = last.totalframes())
+
             last = item
 
         # now stream audio data along the pipe
index 14811aae63fb04cdf69cfe37ed95dd6aa3d6d02d..952091d90c40d60c21ffec6fe0bfd1d6e3d19824 100644 (file)
@@ -155,7 +155,7 @@ class WaveformImage(object):
         self.samples_per_pixel = self.nframes / float(self.image_width)
         self.buffer_size = int(round(self.samples_per_pixel, 0))
         self.pixels_adapter = FixedSizeInputAdapter(self.buffer_size, 1, pad=False)
-        self.pixels_adapter_nframes = self.pixels_adapter.totalframes(self.nframes)
+        self.pixels_adapter_nframes = self.pixels_adapter.blocksize(self.nframes)
 
         self.lower = 800
         self.higher = 12000
@@ -402,7 +402,8 @@ class WaveformImageSimple(object):
         self.samples_per_pixel = self.nframes / float(self.image_width)
         self.buffer_size = int(round(self.samples_per_pixel, 0))
         self.pixels_adapter = FixedSizeInputAdapter(self.buffer_size, 1, pad=False)
-        self.pixels_adapter_nframes = self.pixels_adapter.totalframes(self.nframes)
+        self.pixels_adapter_nframes = self.pixels_adapter.blocksize(self.nframes)
+        print self.pixels_adapter_nframes
 
         self.image = Image.new("RGBA", (self.image_width, self.image_height))
         self.pixel = self.image.load()
@@ -503,7 +504,7 @@ class SpectrogramImage(object):
         self.samples_per_pixel = self.nframes / float(self.image_width)
         self.buffer_size = int(round(self.samples_per_pixel, 0))
         self.pixels_adapter = FixedSizeInputAdapter(self.buffer_size, 1, pad=False)
-        self.pixels_adapter_nframes = self.pixels_adapter.totalframes(self.nframes)
+        self.pixels_adapter_nframes = self.pixels_adapter.blocksize(self.nframes)
 
         self.lower = 100
         self.higher = 22050
index ad8db862fb7a1efa6db46fc9b7d189743a24b072..426ad7215f1be8baa4a06c52f9a2b16734ce81ec 100644 (file)
@@ -55,7 +55,7 @@ class Waveform(Processor):
     @interfacedoc
     def setup(self, channels=None, samplerate=None, blocksize=None, totalframes=None):
         super(Waveform, self).setup(channels, samplerate, blocksize, totalframes)
-        self.graph = WaveformImage(self.width, self.height, self.totalframes(),
+        self.graph = WaveformImage(self.width, self.height, totalframes,
                                     self.samplerate(), self.FFT_SIZE,
                                     bg_color=self.bg_color,
                                     color_scheme=self.color_scheme)