self.len = 0
self.pad = pad
+ def nframes(self, input_nframes):
+ """Return the total number of frames that this adapter will output according to the
+ input_nframes argument"""
+
+ nframes = input_nframes
+ if self.pad:
+ mod = input_nframes % self.buffer_size
+ if mod:
+ nframes += self.buffer_size - mod
+
+ return nframes
+
+
def process(self, frames, eod):
"""Returns an iterator over tuples of the form (buffer, eod) where buffer is a
fixed-sized block of data, and eod indicates whether this is the last block.
adapter = FixedSizeInputAdapter(4, 2)
stdout.write("%s simple test" % adapter.__class__.__name__)
+expected = len(data)
+actual = adapter.nframes(len(data))
+if actual != expected:
+ raise Exception("%d != %d nframes", (actual, expected))
+
test(adapter, data[0:1], False, [])
test(adapter, data[1:5], False, [data[0:4]], False)
test(adapter, data[5:12], False, [data[4:8], data[8:12]], False)
adapter = FixedSizeInputAdapter(4, 2, pad=True)
stdout.write("%s padding test" % adapter.__class__.__name__)
+expected = len(data) + 2
+actual = adapter.nframes(len(data))
+if actual != expected:
+ raise Exception("%d != %d nframes", (actual, expected))
+
test(adapter, data[0:21], False, [data[0:4], data[4:8], data[8:12], data[12:16], data[16:20]], False)
test(adapter, data[21:22], True, [[
[20, 42],