[gst-devel] a stupid question
David Schleef
ds at schleef.org
Tue Mar 18 12:18:56 CET 2003
On Tue, Mar 18, 2003 at 05:34:52PM +0100, Thomas Vander Stichele wrote:
> Hey,
>
> I'm picking up development again for an old gstreamer app I did two years
> ago that I need to use again pretty soon.
>
> The concept was pretty simple: the app is supposed to record bits of audio
> coming in on the sound card, and each consecutive run of audio that
> crosses a given threshold for a set amount of time should be recorded to
> it's own file.
>
> So the end result is a bunch of .wav files (or oggs, whatever) that each
> hold a piece of audio as it was read by someone.
>
> The most important thing to get right in this app is the fact that the app
> should actually continuously pre-record to monitor the level, and when the
> threshold is crossed, it should also store the previous 0.5 secs of audio,
> so that the crossing of the threshold is stored as well, since that
> typically also contains audio to keep.
What you describe is pretty close to one of my target applications.
I've been working toward it in the context of gst-sci, so some
of the elements have unfamiliar names.
The following script does what you are talking about, to
single-sample accuracy (it's important to me...). This version
doesn't do pre- and post- triggering, but that was a simple
parameter to 'gate', IIRC. The plplotsink thread is only for
monitoring purposes.
'comedisrc' is source for Comedi devices.
'envelope' converts an evenly-sampled data stream (like audio) into
some approximation of its amplitude. (Implemented as rectification
and low-pass filtering.)
'trigger' converts an evenly-sampled data stream into a timestamp
stream, which is just a sequence of sparse {$time,1} or {$time,0}
points to indicate enabling or disabling a gate
'gate' chops up an input stream based on triggers received on the
trigger_sink pad, optionally sending a NEW_MEDIA event when a
new segment starts.
One of these days, I'll get the time to update gst-sci for 0.6.0,
and do a release.
dave...
#!/bin/sh
gst-launch $* \
comedisrc rate=10000 ! \
tee silent=1 \
tee0.src%d\!sink { queue ! \
envelope ! \
decimate ! \
framer chunk_size=1000 max_rate=20 ! \
plplotsink marker=0.001,1.0 zero=true \
} \
tee0.src%d\!sink { queue ! \
envelope ! \
trigger set_level=1.0 reset_level=0.5 ! \
queue \
} src!gate0.trigger_sink \
tee0.src%d\!sink { queue \
} src!gate0.sink \
{ \
gate ! \
filesink location=x%d \
} \
2>&1
More information about the gstreamer-devel
mailing list