summaryrefslogtreecommitdiffstats
path: root/gst
diff options
context:
space:
mode:
authorYouness Alaoui <youness.alaoui@collabora.co.uk>2007-08-22 20:16:53 +0000
committerEdward Hervey <bilboed@bilboed.com>2009-02-21 17:48:00 +0100
commit71b9b27c29730abc4f4a8bcb3d073fa614c98f39 (patch)
tree738e54aca66b77bfd9fa1ea788852bf43769fb1e /gst
parentaae79855ca1b0b9ca0848b44dd0119553c4dac4a (diff)
downloadgst-plugins-bad-71b9b27c29730abc4f4a8bcb3d073fa614c98f39.tar.gz
gst-plugins-bad-71b9b27c29730abc4f4a8bcb3d073fa614c98f39.tar.bz2
gst-plugins-bad-71b9b27c29730abc4f4a8bcb3d073fa614c98f39.zip
[MOVED FROM GST-P-FARSIGHT] The DTMF tone generator now respects the volume argument passed in the event
20070822201653-4f0f6-8b7ff874006e11f5a74d0fd91e5a9a43cd082ada.gz
Diffstat (limited to 'gst')
-rw-r--r--gst/dtmf/gstdtmfsrc.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/gst/dtmf/gstdtmfsrc.c b/gst/dtmf/gstdtmfsrc.c
index 6a3e6e65..f04119c1 100644
--- a/gst/dtmf/gstdtmfsrc.c
+++ b/gst/dtmf/gstdtmfsrc.c
@@ -621,6 +621,7 @@ gst_dtmf_src_generate_tone(GstDTMFSrcEvent *event, DTMF_KEY key, float duration,
gint tone_size;
double i = 0;
double amplitude, f1, f2;
+ double volume_factor;
/* Create a buffer for the tone */
tone_size = ((duration/1000)*SAMPLE_RATE*SAMPLE_SIZE*CHANNELS)/8;
@@ -630,6 +631,8 @@ gst_dtmf_src_generate_tone(GstDTMFSrcEvent *event, DTMF_KEY key, float duration,
p = (gint16 *) GST_BUFFER_MALLOCDATA (buffer);
+ volume_factor = pow (10, (-event->volume) / 20);
+
/*
* For each sample point we calculate 'x' as the
* the amplitude value.
@@ -643,6 +646,9 @@ gst_dtmf_src_generate_tone(GstDTMFSrcEvent *event, DTMF_KEY key, float duration,
amplitude = (f1 + f2) / 2;
+ /* Adjust the volume */
+ amplitude *= volume_factor;
+
/* Make the [-1:1] interval into a [-32767:32767] interval */
amplitude *= 32767;