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 = [] right = []
position = 0 position = 0
def __init__(self, uri, samplerate=22050, channels=2): def __init__(self, uri, channels=2):
gst.Pipeline.__init__(self) gst.Pipeline.__init__(self)
self.duration = -1 self.duration = -1
self.framerate = 25 self.framerate = 25
self.samplerate = samplerate
self.channels = channels self.channels = channels
self.uri = uri self.uri = uri
@ -54,9 +53,12 @@ class Audio(gst.Pipeline):
def _sbinPadAddedCb(self, unused_sbin, pad): def _sbinPadAddedCb(self, unused_sbin, pad):
caps = pad.get_caps() caps = pad.get_caps()
if 'audio' in str(caps): if 'audio' in str(caps):
self.samplerate = caps[0]['rate']
pad.link(self.queue.get_pad("sink")) pad.link(self.queue.get_pad("sink"))
self.queue.link(self.conv) 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, self.rate.link(self.sink,
gst.Caps("audio/x-raw-int,rate=%s,channels=%s,width=16,depth=16" % gst.Caps("audio/x-raw-int,rate=%s,channels=%s,width=16,depth=16" %
(self.samplerate, self.channels))) (self.samplerate, self.channels)))
@ -92,9 +94,9 @@ class Audio(gst.Pipeline):
else: else:
start = crop start = crop
end = int(self.tile_height/2) end = int(self.tile_height/2)
#for i in range(0, self.tile_height):
for i in range(start, end): for i in range(start, end):
self.tiles[tile].putpixel((tilePos, i), p) self.tiles[tile].putpixel((tilePos, i), p)
#left #left
pixel = np.asarray(self.left[:samples_per_pixel]) pixel = np.asarray(self.left[:samples_per_pixel])
self.left = self.left[samples_per_pixel:] self.left = self.left[samples_per_pixel:]