placev.c 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. /*
  2. $Log$
  3. Revision 1.15 2004/06/26 03:50:14 markster
  4. Merge source cleanups (bug #1911)
  5. Revision 1.14 2003/02/12 13:59:15 matteo
  6. mer feb 12 14:56:57 CET 2003
  7. Revision 1.1.1.1 2003/02/12 13:59:15 matteo
  8. mer feb 12 14:56:57 CET 2003
  9. Revision 1.3 2001/04/12 21:27:53 markh
  10. app_record now supports wildcards of sort so your output file is not overwritten every time it's run. File.h got a documentation update on the ast_fileexists to include the return call. Watch out for the placea.c placev.c code, it's updates have not been tested yet. Just a few parenthesis to make it compile nicer on newer gcc versions with all the -W flags set.
  11. Revision 1.2 2000/01/05 08:20:39 markster
  12. Some OSS fixes and a few lpc changes to make it actually work
  13. * Revision 1.1 1996/08/19 22:31:02 jaf
  14. * Initial revision
  15. *
  16. */
  17. /* -- translated by f2c (version 19951025).
  18. You must link the resulting object file with the libraries:
  19. -lf2c -lm (in that order)
  20. */
  21. #include "f2c.h"
  22. #ifdef P_R_O_T_O_T_Y_P_E_S
  23. extern int placev_(integer *osbuf, integer *osptr, integer *oslen, integer *obound, integer *vwin, integer *af, integer *lframe, integer *minwin, integer *maxwin, integer *dvwinl, integer *dvwinh);
  24. #endif
  25. /* ****************************************************************** */
  26. /* PLACEV Version 48 */
  27. /* $Log$
  28. * Revision 1.15 2004/06/26 03:50:14 markster
  29. * Merge source cleanups (bug #1911)
  30. *
  31. * Revision 1.14 2003/02/12 13:59:15 matteo
  32. * mer feb 12 14:56:57 CET 2003
  33. *
  34. * Revision 1.1.1.1 2003/02/12 13:59:15 matteo
  35. * mer feb 12 14:56:57 CET 2003
  36. *
  37. * Revision 1.3 2001/04/12 21:27:53 markh
  38. * app_record now supports wildcards of sort so your output file is not overwritten every time it's run. File.h got a documentation update on the ast_fileexists to include the return call. Watch out for the placea.c placev.c code, it's updates have not been tested yet. Just a few parenthesis to make it compile nicer on newer gcc versions with all the -W flags set.
  39. *
  40. * Revision 1.2 2000/01/05 08:20:39 markster
  41. * Some OSS fixes and a few lpc changes to make it actually work
  42. *
  43. * Revision 1.1 1996/08/19 22:31:02 jaf
  44. * Initial revision
  45. * */
  46. /* Revision 1.6 1996/03/19 20:42:19 jaf */
  47. /* Added some conditions satisfied by the output values in VWIN. */
  48. /* Revision 1.5 1996/03/19 18:37:56 jaf */
  49. /* Strengthened the specification of which indices of VWIN are read and */
  50. /* written. */
  51. /* Revision 1.4 1996/03/15 16:38:33 jaf */
  52. /* One tiny comment added. */
  53. /* Revision 1.3 1996/03/15 16:36:13 jaf */
  54. /* Added comments giving In/Out status of arguments. */
  55. /* Revision 1.2 1996/03/12 23:56:01 jaf */
  56. /* Comments added explaining that none of the local variables of this */
  57. /* subroutine need to be saved from one invocation to the next. */
  58. /* Revision 1.1 1996/02/07 14:48:39 jaf */
  59. /* Initial revision */
  60. /* ****************************************************************** */
  61. /* Input: */
  62. /* OSBUF Buffer which holds sorted indexes of onsets */
  63. /* I believe that only indices 1 through OSPTR-1 can be read. */
  64. /* OSLEN */
  65. /* OSPTR Free pointer into OSBUF */
  66. /* AF */
  67. /* LFRAME */
  68. /* MINWIN */
  69. /* MAXWIN */
  70. /* DVWINL */
  71. /* DVWINH (This argument is never used. Should it be?) */
  72. /* Input/Output: */
  73. /* VWIN Buffer of Voicing Window Positions (Modified) */
  74. /* Index (2,AF-1) is read. */
  75. /* Indices (1,AF) and (2,AF) are written, */
  76. /* and then possibly read. */
  77. /* All other indices are unused. */
  78. /* In all cases, the final values will satsify the condition:*/
  79. /* VWIN(2,AF)-VWIN(1,AF)+1 .LE. MAXWIN */
  80. /* I'm not certain yet, but they may also satisfy: */
  81. /* MINWIN .LE. VWIN(2,AF)-VWIN(1,AF)+1 */
  82. /* Output: */
  83. /* OBOUND This variable is set by this procedure and used */
  84. /* in placing analysis windows (PLACEA). Bit 1 */
  85. /* indicates whether an onset bounds the left side */
  86. /* of the voicing window, and bit 2 indicates whether */
  87. /* an onset bounds the right side of the voicing window. */
  88. /* This subroutine has no local state. */
  89. /* Subroutine */ int placev_(integer *osbuf, integer *osptr, integer *oslen,
  90. integer *obound, integer *vwin, integer *af, integer *lframe, integer
  91. *minwin, integer *maxwin, integer *dvwinl, integer *dvwinh)
  92. {
  93. /* System generated locals */
  94. integer i__1, i__2;
  95. /* Local variables */
  96. logical crit;
  97. integer i__, q, osptr1, hrange, lrange;
  98. /* Arguments */
  99. /* Local variables that need not be saved */
  100. /* Variables */
  101. /* LRANGE, HRANGE Range in which window is placed */
  102. /* OSPTR1 OSPTR excluding samples in 3F */
  103. /* Local state */
  104. /* None */
  105. /* Voicing Window Placement */
  106. /* __________________ __________________ ______________ */
  107. /* | | | */
  108. /* | 1F | 2F | 3F ... */
  109. /* |__________________|__________________|______________ */
  110. /* Previous | */
  111. /* Window | */
  112. /* ...________| */
  113. /* | | */
  114. /* ------>| This window's placement range |<------ */
  115. /* | | */
  116. /* There are three cases. Note that these are different from those */
  117. /* given in the LPC-10e phase 1 report. */
  118. /* 1. If there are no onsets in this range, then the voicing window */
  119. /* is centered in the pitch window. If such a placement is not within
  120. */
  121. /* the window's placement range, then the window is placed in the left-
  122. */
  123. /* most portion of the placement range. Its length is always MAXWIN. */
  124. /* 2. If the first onset is in 2F and there is sufficient room to place
  125. */
  126. /* the window immediately before this onset, then the window is placed
  127. */
  128. /* there, and its length is set to the maximum possible under these */
  129. /* constraints. */
  130. /* "Critical Region Exception": If there is another onset in 2F */
  131. /* such that a window can be placed between the two onsets, the */
  132. /* window is placed there (ie, as in case 3). */
  133. /* 3. Otherwise, the window is placed immediately after the onset. The
  134. */
  135. /* window's length */
  136. /* is the longest length that can fit in the range under these constraint
  137. s,*/
  138. /* except that the window may be shortened even further to avoid overlapp
  139. ing*/
  140. /* other onsets in the placement range. In any case, the window's length
  141. */
  142. /* is at least MINWIN. */
  143. /* Note that the values of MINWIN and LFRAME must be chosen such */
  144. /* that case 2 = false implies case 3 = true. This means that */
  145. /* MINWIN <= LFRAME/2. If this were not the case, then a fourth case */
  146. /* would have to be added for when the window cannot fit either before
  147. */
  148. /* or after the onset. */
  149. /* Note also that onsets which weren't in 2F last time may be in 1F this
  150. */
  151. /* time, due to the filter delays in computing onsets. The result is tha
  152. t*/
  153. /* occasionally a voicing window will overlap that onset. The only way
  154. */
  155. /* to circumvent this problem is to add more delay in processing input
  156. */
  157. /* speech. In the trade-off between delay and window-placement, window
  158. */
  159. /* placement lost. */
  160. /* Compute the placement range */
  161. /* Parameter adjustments */
  162. --osbuf;
  163. vwin -= 3;
  164. /* Function Body */
  165. /* Computing MAX */
  166. i__1 = vwin[((*af - 1) << 1) + 2] + 1, i__2 = (*af - 2) * *lframe + 1;
  167. lrange = max(i__1,i__2);
  168. hrange = *af * *lframe;
  169. /* Compute OSPTR1, so the following code only looks at relevant onsets. */
  170. for (osptr1 = *osptr - 1; osptr1 >= 1; --osptr1) {
  171. if (osbuf[osptr1] <= hrange) {
  172. goto L90;
  173. }
  174. }
  175. L90:
  176. ++osptr1;
  177. /* Check for case 1 first (fast case): */
  178. if (osptr1 <= 1 || osbuf[osptr1 - 1] < lrange) {
  179. /* Computing MAX */
  180. i__1 = vwin[((*af - 1) << 1) + 2] + 1;
  181. vwin[(*af << 1) + 1] = max(i__1,*dvwinl);
  182. vwin[(*af << 1) + 2] = vwin[(*af << 1) + 1] + *maxwin - 1;
  183. *obound = 0;
  184. } else {
  185. /* Search backward in OSBUF for first onset in range. */
  186. /* This code relies on the above check being performed first. */
  187. for (q = osptr1 - 1; q >= 1; --q) {
  188. if (osbuf[q] < lrange) {
  189. goto L100;
  190. }
  191. }
  192. L100:
  193. ++q;
  194. /* Check for case 2 (placement before onset): */
  195. /* Check for critical region exception: */
  196. i__1 = osptr1 - 1;
  197. for (i__ = q + 1; i__ <= i__1; ++i__) {
  198. if (osbuf[i__] - osbuf[q] >= *minwin) {
  199. crit = TRUE_;
  200. goto L105;
  201. }
  202. }
  203. crit = FALSE_;
  204. L105:
  205. /* Computing MAX */
  206. i__1 = (*af - 1) * *lframe, i__2 = lrange + *minwin - 1;
  207. if (! crit && osbuf[q] > max(i__1,i__2)) {
  208. vwin[(*af << 1) + 2] = osbuf[q] - 1;
  209. /* Computing MAX */
  210. i__1 = lrange, i__2 = vwin[(*af << 1) + 2] - *maxwin + 1;
  211. vwin[(*af << 1) + 1] = max(i__1,i__2);
  212. *obound = 2;
  213. /* Case 3 (placement after onset) */
  214. } else {
  215. vwin[(*af << 1) + 1] = osbuf[q];
  216. L110:
  217. ++q;
  218. if (q >= osptr1) {
  219. goto L120;
  220. }
  221. if (osbuf[q] > vwin[(*af << 1) + 1] + *maxwin) {
  222. goto L120;
  223. }
  224. if (osbuf[q] < vwin[(*af << 1) + 1] + *minwin) {
  225. goto L110;
  226. }
  227. vwin[(*af << 1) + 2] = osbuf[q] - 1;
  228. *obound = 3;
  229. return 0;
  230. L120:
  231. /* Computing MIN */
  232. i__1 = vwin[(*af << 1) + 1] + *maxwin - 1;
  233. vwin[(*af << 1) + 2] = min(i__1,hrange);
  234. *obound = 1;
  235. }
  236. }
  237. return 0;
  238. } /* placev_ */