use source samplerate

This commit is contained in:
j 2010-11-25 12:03:57 +01:00
parent 21b75ac85f
commit bcb4036f48

View file

@ -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:]