mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-22 22:16:22 +00:00
[MOVED FROM GST-P-FARSIGHT] The DTMF tone generator now respects the volume argument passed in the event
20070822201653-4f0f6-8b7ff874006e11f5a74d0fd91e5a9a43cd082ada.gz
This commit is contained in:
parent
82072435f8
commit
16a5d7d91c
1 changed files with 6 additions and 0 deletions
|
@ -621,6 +621,7 @@ gst_dtmf_src_generate_tone(GstDTMFSrcEvent *event, DTMF_KEY key, float duration,
|
||||||
gint tone_size;
|
gint tone_size;
|
||||||
double i = 0;
|
double i = 0;
|
||||||
double amplitude, f1, f2;
|
double amplitude, f1, f2;
|
||||||
|
double volume_factor;
|
||||||
|
|
||||||
/* Create a buffer for the tone */
|
/* Create a buffer for the tone */
|
||||||
tone_size = ((duration/1000)*SAMPLE_RATE*SAMPLE_SIZE*CHANNELS)/8;
|
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);
|
p = (gint16 *) GST_BUFFER_MALLOCDATA (buffer);
|
||||||
|
|
||||||
|
volume_factor = pow (10, (-event->volume) / 20);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For each sample point we calculate 'x' as the
|
* For each sample point we calculate 'x' as the
|
||||||
* the amplitude value.
|
* the amplitude value.
|
||||||
|
@ -643,6 +646,9 @@ gst_dtmf_src_generate_tone(GstDTMFSrcEvent *event, DTMF_KEY key, float duration,
|
||||||
|
|
||||||
amplitude = (f1 + f2) / 2;
|
amplitude = (f1 + f2) / 2;
|
||||||
|
|
||||||
|
/* Adjust the volume */
|
||||||
|
amplitude *= volume_factor;
|
||||||
|
|
||||||
/* Make the [-1:1] interval into a [-32767:32767] interval */
|
/* Make the [-1:1] interval into a [-32767:32767] interval */
|
||||||
amplitude *= 32767;
|
amplitude *= 32767;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue