summaryrefslogtreecommitdiff
path: root/frame.c
diff options
context:
space:
mode:
authorKevin P. Fleming <kpfleming@digium.com>2005-10-28 16:20:44 +0000
committerKevin P. Fleming <kpfleming@digium.com>2005-10-28 16:20:44 +0000
commit0d34142f7e1509f2d8c896eb8cec90ed8c745d50 (patch)
tree5edb99afb7e5ac855b6542c4642f2053d755adcb /frame.c
parentd47e839c322330787c45099673bcf7e2b710f5f3 (diff)
add API function to perform volume adjustment on a frame of SLINEAR data
documentation cleanup git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6874 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'frame.c')
-rwxr-xr-xframe.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/frame.c b/frame.c
index 5d9ddab11..7b4fa4ddf 100755
--- a/frame.c
+++ b/frame.c
@@ -1252,3 +1252,22 @@ int ast_codec_get_len(int format, int samples)
return len;
}
+
+int ast_frame_adjust_volume(struct ast_frame *f, int adjustment)
+{
+ int count;
+ short *fdata = f->data;
+
+ if ((f->frametype != AST_FRAME_VOICE) || (f->subclass != AST_FORMAT_SLINEAR))
+ return -1;
+
+ for (count = 0; count < f->samples; count++) {
+ if (adjustment > 0) {
+ fdata[count] *= abs(adjustment);
+ } else if (adjustment < 0) {
+ fdata[count] /= abs(adjustment);
+ }
+ }
+
+ return 0;
+}