1
# PiTiVi , Non-linear video editor
3
# pitivi/elements/arraysink.py
5
# Copyright (c) 2005, Edward Hervey <bilboed@bilboed.com>
7
# This program is free software; you can redistribute it and/or
8
# modify it under the terms of the GNU Lesser General Public
9
# License as published by the Free Software Foundation; either
10
# version 2.1 of the License, or (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
# Lesser General Public License for more details.
17
# You should have received a copy of the GNU Lesser General Public
18
# License along with this program; if not, write to the
19
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20
# Boston, MA 02111-1307, USA.
22
Stores audio samples in an array for plotting waveforms
26
gobject.threads_init()
31
class ArraySink(gst.BaseSink):
34
Stores audio samples in a numeric array of floats.
37
"audio/x-raw-float, width=(int) 32, "
38
"endianness = (int) LITTLE_ENDIAN, "
39
"channels = (int) 1, "
40
"rate = (int) [1, 96000]"
53
gst.BaseSink.__init__(self)
54
self.props.sync = False
60
self.samples = array.array('f')
62
def do_set_caps(self, caps):
63
if not caps[0].get_name() == "audio/x-raw-float":
65
self.rate = caps[0]["rate"]
68
def do_render(self, buf):
69
self.samples.fromstring(buf[:buf.size])
70
self.duration += buf.duration
73
def do_preroll(self, buf):
74
return self.do_render(buf)
76
gobject.type_register(ArraySink)