[gst-devel] amplitude modulation plugin
berti
bertrand.haut at brutele.be
Thu Aug 25 15:45:05 CEST 2005
I'm trying to make a amplitude modulation of a sound signal, i.e. simply
multiply the sound by sin(2*pi*f*t) where t is the time.
My plugin have the following caps
"audio/x-raw-int, width = (int) 16, depth = (int) 16, signed = (bool) true,
endianness = (int) 1234, rate = (int) 44100, channels = (int) 1"
so that I'm sure I will be able to connect it to sinesrc & osssink to simply
test it.
The main part of the code is :
out_buf = gst_buffer_copy (buf);
gint16 * data = (gint16 *) GST_BUFFER_DATA (out_buf);
int num_samples = GST_BUFFER_SIZE (out_buf) / sizeof (gint16);
int i=0;
double t=((double) GST_BUFFER_TIMESTAMP (buf)) * 10e-9; //the "time" of
this buffer in "s"
for (i=0; i < num_samples ; ++i){
data[i]=ByteSwap((gint16) ((double) ByteSwap(data[i]) *cos(2.0 * PI *
(double) filter->f * (t+ i / ((double) filter->rate)) )));
}
gst_pad_push (filter->srcpad, GST_DATA (out_buf));
-filter->f is the frequency of the modulation
-The ByteSwap simply convert a gint16 between Big and Little endian
representation.
The code compile and work, I can hear the variation of the frequency BUT there
is a lot of noise on the top of the sine signals. Where does this noise come
from ? The sound directly from the sinsrc element is perfect so I thought it
was possible to make a filter with perfect output.
--
Berti
ICQ 48978874
pgpkey B9514013C02E33FA
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20050825/6a2bb4d4/attachment.pgp>
More information about the gstreamer-devel
mailing list