[asterisk-commits] russell: branch russell/jack r96171 - /team/russell/jack/apps/app_jack.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jan 2 21:52:03 CST 2008


Author: russell
Date: Wed Jan  2 21:52:02 2008
New Revision: 96171

URL: http://svn.digium.com/view/asterisk?view=rev&rev=96171
Log:
When transferring audio to/from jack, normalize the samples in floating point
from -1.0 to 1.0 instead of FLT_MIN to FLT_MAX.  I'm not sure if all applications
communicating via jack do this, but the one that I currently care about (pure-data)
uses this range.

Modified:
    team/russell/jack/apps/app_jack.c

Modified: team/russell/jack/apps/app_jack.c
URL: http://svn.digium.com/view/asterisk/team/russell/jack/apps/app_jack.c?view=diff&rev=96171&r1=96170&r2=96171
==============================================================================
--- team/russell/jack/apps/app_jack.c (original)
+++ team/russell/jack/apps/app_jack.c Wed Jan  2 21:52:02 2008
@@ -220,12 +220,12 @@
 		}
 
 		for (i = 0; i < total_out_buf_used; i++)
-			s_buf[i] = f_buf[i] * (SHRT_MAX / FLT_MAX);
+			s_buf[i] = f_buf[i] * (SHRT_MAX / 1.0);
 	} else {
 		/* No resampling needed */
 
 		for (i = 0; i < nframes; i++)
-			s_buf[i] = in_buf[i] * (SHRT_MAX / FLT_MAX);
+			s_buf[i] = in_buf[i] * (SHRT_MAX / 1.0);
 	}
 
 	res = jack_ringbuffer_write(jack_data->input_rb, (const char *) s_buf, sizeof(s_buf));
@@ -409,7 +409,7 @@
 		memset(in_buf, 0, sizeof(in_buf));
 
 		for (i = 0; i < f->samples; i++)
-			in_buf[i] = s_buf[i] * (FLT_MAX / SHRT_MAX);
+			in_buf[i] = s_buf[i] * (1.0 / SHRT_MAX);
 
 		while (total_in_buf_used < ARRAY_LEN(in_buf)) {
 			int in_buf_used;
@@ -440,7 +440,7 @@
 		/* No resampling needed */
 
 		for (i = 0; i < f->samples; i++)
-			f_buf[i] = s_buf[i] * (FLT_MAX / SHRT_MAX);
+			f_buf[i] = s_buf[i] * (1.0 / SHRT_MAX);
 
 		f_buf_used = f->samples;
 	}




More information about the asterisk-commits mailing list