From bcb4036f485715a7c96228b97e037cceff72a99c Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Thu, 25 Nov 2010 12:03:57 +0100 Subject: [PATCH] use source samplerate --- oxtimeline/audio.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/oxtimeline/audio.py b/oxtimeline/audio.py index c17afc2..be2a486 100644 --- a/oxtimeline/audio.py +++ b/oxtimeline/audio.py @@ -17,11 +17,10 @@ class Audio(gst.Pipeline): right = [] position = 0 - def __init__(self, uri, samplerate=22050, channels=2): + def __init__(self, uri, channels=2): gst.Pipeline.__init__(self) self.duration = -1 self.framerate = 25 - self.samplerate = samplerate self.channels = channels self.uri = uri @@ -54,9 +53,12 @@ class Audio(gst.Pipeline): def _sbinPadAddedCb(self, unused_sbin, pad): caps = pad.get_caps() if 'audio' in str(caps): + self.samplerate = caps[0]['rate'] pad.link(self.queue.get_pad("sink")) self.queue.link(self.conv) - self.conv.link(self.rate) + self.conv.link(self.rate, + gst.Caps("audio/x-raw-int,channels=%s,width=16,depth=16" % + (self.channels, ))) self.rate.link(self.sink, gst.Caps("audio/x-raw-int,rate=%s,channels=%s,width=16,depth=16" % (self.samplerate, self.channels))) @@ -92,9 +94,9 @@ class Audio(gst.Pipeline): else: start = crop end = int(self.tile_height/2) + #for i in range(0, self.tile_height): for i in range(start, end): self.tiles[tile].putpixel((tilePos, i), p) - #left pixel = np.asarray(self.left[:samples_per_pixel]) self.left = self.left[samples_per_pixel:]