Asterisk - The Open Source Telephony Project GIT-master-7e7a603
Macros | Functions | Variables
synths.c File Reference
#include "f2c.h"
Include dependency graph for synths.c:

Go to the source code of this file.

Macros

#define contrl_1   contrl_
 

Functions

int synths_ (integer *voice, integer *pitch, real *rms, real *rc, real *speech, integer *k, struct lpc10_decoder_state *st)
 

Variables

static real c_b2 = .7f
 
struct {
   logical   corrp
 
   integer   lframe
 
   integer   order
 
contrl_
 

Macro Definition Documentation

◆ contrl_1

#define contrl_1   contrl_

Definition at line 59 of file synths.c.

Function Documentation

◆ synths_()

int synths_ ( integer voice,
integer pitch,
real rms,
real rc,
real speech,
integer k,
struct lpc10_decoder_state st 
)

Definition at line 170 of file synths.c.

172{
173 /* Initialized data */
174
175 real *buf;
176 integer *buflen;
177
178 /* System generated locals */
179 integer i__1;
180 real r__1, r__2;
181
182 /* Local variables */
183 real rmsi[16];
184 integer nout, ivuv[16], i__, j;
185 extern /* Subroutine */ int deemp_(real *, integer *, struct lpc10_decoder_state *);
186 real ratio;
187 integer ipiti[16];
188 real g2pass;
189 real pc[10];
190 extern /* Subroutine */ int pitsyn_(integer *, integer *, integer *, real
191 *, real *, integer *, integer *, integer *, real *, real *,
192 integer *, real *, struct lpc10_decoder_state *);
193 real rci[160] /* was [10][16] */;
194
195/* $Log$
196 * Revision 1.16 2004/06/26 03:50:14 markster
197 * Merge source cleanups (bug #1911)
198 *
199 * Revision 1.15 2003/09/27 02:45:37 markster
200 * Fix various compiler warnings (bug #322)
201 *
202 * Revision 1.2 2003/09/27 02:45:37 markster
203 * Fix various compiler warnings (bug #322)
204 *
205 * Revision 1.1.1.1 2003/02/12 13:59:15 matteo
206 * mer feb 12 14:56:57 CET 2003
207 *
208 * Revision 1.2 2000/01/05 08:20:39 markster
209 * Some OSS fixes and a few lpc changes to make it actually work
210 *
211 * Revision 1.2 1996/08/20 20:42:59 jaf
212 * Removed all static local variables that were SAVE'd in the Fortran
213 * code, and put them in struct lpc10_decoder_state that is passed as an
214 * argument.
215 *
216 * Removed init function, since all initialization is now done in
217 * init_lpc10_decoder_state().
218 *
219 * Revision 1.1 1996/08/19 22:30:33 jaf
220 * Initial revision
221 * */
222/* Revision 1.3 1996/03/29 22:03:47 jaf */
223/* Removed definitions for any constants that were no longer used. */
224
225/* Revision 1.2 1996/03/26 19:34:33 jaf */
226/* Added comments indicating which constants are not needed in an */
227/* application that uses the LPC-10 coder. */
228
229/* Revision 1.1 1996/02/07 14:43:51 jaf */
230/* Initial revision */
231
232/* LPC Configuration parameters: */
233/* Frame size, Prediction order, Pitch period */
234/* Arguments */
235/* $Log$
236 * Revision 1.16 2004/06/26 03:50:14 markster
237 * Merge source cleanups (bug #1911)
238 *
239 * Revision 1.15 2003/09/27 02:45:37 markster
240 * Fix various compiler warnings (bug #322)
241 *
242 * Revision 1.2 2003/09/27 02:45:37 markster
243 * Fix various compiler warnings (bug #322)
244 *
245 * Revision 1.1.1.1 2003/02/12 13:59:15 matteo
246 * mer feb 12 14:56:57 CET 2003
247 *
248 * Revision 1.2 2000/01/05 08:20:39 markster
249 * Some OSS fixes and a few lpc changes to make it actually work
250 *
251 * Revision 1.2 1996/08/20 20:42:59 jaf
252 * Removed all static local variables that were SAVE'd in the Fortran
253 * code, and put them in struct lpc10_decoder_state that is passed as an
254 * argument.
255 *
256 * Removed init function, since all initialization is now done in
257 * init_lpc10_decoder_state().
258 *
259 * Revision 1.1 1996/08/19 22:30:33 jaf
260 * Initial revision
261 * */
262/* Revision 1.3 1996/03/29 22:05:55 jaf */
263/* Commented out the common block variables that are not needed by the */
264/* embedded version. */
265
266/* Revision 1.2 1996/03/26 19:34:50 jaf */
267/* Added comments indicating which constants are not needed in an */
268/* application that uses the LPC-10 coder. */
269
270/* Revision 1.1 1996/02/07 14:44:09 jaf */
271/* Initial revision */
272
273/* LPC Processing control variables: */
274
275/* *** Read-only: initialized in setup */
276
277/* Files for Speech, Parameter, and Bitstream Input & Output, */
278/* and message and debug outputs. */
279
280/* Here are the only files which use these variables: */
281
282/* lpcsim.f setup.f trans.f error.f vqsetup.f */
283
284/* Many files which use fdebug are not listed, since it is only used in */
285/* those other files conditionally, to print trace statements. */
286/* integer fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */
287/* LPC order, Frame size, Quantization rate, Bits per frame, */
288/* Error correction */
289/* Subroutine SETUP is the only place where order is assigned a value, */
290/* and that value is 10. It could increase efficiency 1% or so to */
291/* declare order as a constant (i.e., a Fortran PARAMETER) instead of as
292*/
293/* a variable in a COMMON block, since it is used in many places in the */
294/* core of the coding and decoding routines. Actually, I take that back.
295*/
296/* At least when compiling with f2c, the upper bound of DO loops is */
297/* stored in a local variable before the DO loop begins, and then that is
298*/
299/* compared against on each iteration. */
300/* Similarly for lframe, which is given a value of MAXFRM in SETUP. */
301/* Similarly for quant, which is given a value of 2400 in SETUP. quant */
302/* is used in only a few places, and never in the core coding and */
303/* decoding routines, so it could be eliminated entirely. */
304/* nbits is similar to quant, and is given a value of 54 in SETUP. */
305/* corrp is given a value of .TRUE. in SETUP, and is only used in the */
306/* subroutines ENCODE and DECODE. It doesn't affect the speed of the */
307/* coder significantly whether it is .TRUE. or .FALSE., or whether it is
308*/
309/* a constant or a variable, since it is only examined once per frame. */
310/* Leaving it as a variable that is set to .TRUE. seems like a good */
311/* idea, since it does enable some error-correction capability for */
312/* unvoiced frames, with no change in the coding rate, and no noticeable
313*/
314/* quality difference in the decoded speech. */
315/* integer quant, nbits */
316/* *** Read/write: variables for debugging, not needed for LPC algorithm
317*/
318
319/* Current frame, Unstable frames, Output clip count, Max onset buffer,
320*/
321/* Debug listing detail level, Line count on listing page */
322
323/* nframe is not needed for an embedded LPC10 at all. */
324/* nunsfm is initialized to 0 in SETUP, and incremented in subroutine */
325/* ERROR, which is only called from RCCHK. When LPC10 is embedded into */
326/* an application, I would recommend removing the call to ERROR in RCCHK,
327*/
328/* and remove ERROR and nunsfm completely. */
329/* iclip is initialized to 0 in SETUP, and incremented in entry SWRITE in
330*/
331/* sread.f. When LPC10 is embedded into an application, one might want */
332/* to cause it to be incremented in a routine that takes the output of */
333/* SYNTHS and sends it to an audio device. It could be optionally */
334/* displayed, for those that might want to know what it is. */
335/* maxosp is never initialized to 0 in SETUP, although it probably should
336*/
337/* be, and it is updated in subroutine ANALYS. I doubt that its value */
338/* would be of much interest to an application in which LPC10 is */
339/* embedded. */
340/* listl and lincnt are not needed for an embedded LPC10 at all. */
341/* integer nframe, nunsfm, iclip, maxosp, listl, lincnt */
342/* common /contrl/ fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */
343/* common /contrl/ quant, nbits */
344/* common /contrl/ nframe, nunsfm, iclip, maxosp, listl, lincnt */
345/* Parameters/constants */
346/* Local variables that need not be saved */
347/* Local state */
348/* BUF is a buffer of speech samples that would have been returned
349*/
350/* by the older version of SYNTHS, but the newer version doesn't, */
351/* so that the newer version can always return MAXFRM samples on */
352/* every call. This has the effect of delaying the return of */
353/* samples for one additional frame time. */
354
355/* Indices 1 through BUFLEN contain samples that are left over from
356*/
357/* the last call to SYNTHS. Given the way that PITSYN works, */
358/* BUFLEN should always be in the range MAXFRM-MAXPIT+1 through */
359/* MAXFRM, inclusive, after a call to SYNTHS is complete. */
360
361/* On the first call to SYNTHS (or the first call after */
362/* reinitializing with the entry INITSYNTHS), BUFLEN is MAXFRM, and
363*/
364/* a frame of silence is always returned. */
365 /* Parameter adjustments */
366 if (voice) {
367 --voice;
368 }
369 if (rc) {
370 --rc;
371 }
372 if (speech) {
373 --speech;
374 }
375
376 /* Function Body */
377 buf = &(st->buf[0]);
378 buflen = &(st->buflen);
379
380/* Computing MAX */
381 i__1 = min(*pitch,156);
382 *pitch = max(i__1,20);
383 i__1 = contrl_1.order;
384 for (i__ = 1; i__ <= i__1; ++i__) {
385/* Computing MAX */
386/* Computing MIN */
387 r__2 = rc[i__];
388 r__1 = min(r__2,.99f);
389 rc[i__] = max(r__1,-.99f);
390 }
391 pitsyn_(&contrl_1.order, &voice[1], pitch, rms, &rc[1], &contrl_1.lframe,
392 ivuv, ipiti, rmsi, rci, &nout, &ratio, st);
393 if (nout > 0) {
394 i__1 = nout;
395 for (j = 1; j <= i__1; ++j) {
396
397/* Add synthesized speech for pitch period J to the en
398d of */
399/* BUF. */
400
401 irc2pc_(&rci[j * 10 - 10], pc, &contrl_1.order, &c_b2, &g2pass);
402 bsynz_(pc, &ipiti[j - 1], &ivuv[j - 1], &buf[*buflen], &rmsi[j - 1]
403 , &ratio, &g2pass, st);
404 deemp_(&buf[*buflen], &ipiti[j - 1], st);
405 *buflen += ipiti[j - 1];
406 }
407
408/* Copy first MAXFRM samples from BUF to output array SPEECH
409*/
410/* (scaling them), and then remove them from the beginning of
411 */
412/* BUF. */
413
414 for (i__ = 1; i__ <= 180; ++i__) {
415 speech[i__] = buf[i__ - 1] / 4096.f;
416 }
417 *k = 180;
418 *buflen += -180;
419 i__1 = *buflen;
420 for (i__ = 1; i__ <= i__1; ++i__) {
421 buf[i__ - 1] = buf[i__ + 179];
422 }
423 }
424 return 0;
425} /* synths_ */
int bsynz_(real *coef, integer *ip, integer *iv, real *sout, real *rms, real *ratio, real *g2pass, struct lpc10_decoder_state *st)
Definition: bsynz.c:122
int deemp_(real *x, integer *n, struct lpc10_decoder_state *st)
Definition: deemp.c:106
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
int irc2pc_(real *rc, real *pc, integer *order, real *gprime, real *g2pass)
Definition: irc2pc.c:82
int pitsyn_(integer *order, integer *voice, integer *pitch, real *rms, real *rc, integer *lframe, integer *ivuv, integer *ipiti, real *rmsi, real *rci, integer *nout, real *ratio, struct lpc10_decoder_state *st)
Definition: pitsyn.c:132
#define min(a, b)
Definition: f2c.h:197
#define max(a, b)
Definition: f2c.h:198
float real
Definition: lpc10.h:79
INT32 integer
Definition: lpc10.h:80
real buf[360]
Definition: lpc10.h:163
integer buflen
Definition: lpc10.h:164
static real c_b2
Definition: synths.c:63
#define contrl_1
Definition: synths.c:59

References bsynz_(), lpc10_decoder_state::buf, buf, lpc10_decoder_state::buflen, c_b2, contrl_1, deemp_(), irc2pc_(), max, min, and pitsyn_().

Referenced by lpc10_decode().

Variable Documentation

◆ c_b2

real c_b2 = .7f
static

Definition at line 63 of file synths.c.

Referenced by synths_().

◆ 

struct { ... } contrl_

◆ corrp

logical corrp

Definition at line 56 of file synths.c.

◆ lframe

integer lframe

Definition at line 55 of file synths.c.

◆ order

integer order

Definition at line 55 of file synths.c.