1 --- al_filter.c 2006-05-08 17:41:52.845524459 +0200
2 +++ new/al_filter.c 2006-05-08 17:39:45.001112085 +0200
5 * 2.0 is an arbitrary constant, and likely to be changed.
7 -#define TPITCH_MAX 256
8 +#define TPITCH_MAX 2048
11 * The default software time domain filters.
14 for(i = 0; i < nc; i++) {
20 * Kind of breaking convention here and actually using
22 offsets = tpitch_lookup.offsets[ l_index ];
23 fractionals = tpitch_lookup.fractionals[ l_index ];
25 - /* don't run past end */
27 if(((clen + 1) * pitch * sizeof(ALshort)) >=
28 (samp->size - src->srcParams.soundpos))
30 @@ -1394,13 +1394,27 @@
31 * be necessary, but seems to improve performance quite
34 - for(j = 0; j < clen; j++)
36 + for(j=0; j < len; j++)
40 - int offset = offsets[j];
41 - int nextoffset = offsets[j+1];
42 - float frac = fractionals[j];
44 + /* We have reached the end of the sample.
45 + For looping samples: start over from the start,
46 + else fill with blanks and continue. */
47 + if( _alSourceIsLooping( src ) == AL_TRUE ) {
48 + obufptr = samp->orig_buffers[i];
51 + memset( &bufptr[j], 0, (len-j)*sizeof *bufptr );
56 + int offset = offsets[sj];
57 + int nextoffset = offsets[sj+1];
58 + float frac = fractionals[sj];
59 float firstsample = obufptr[offset];
60 float nextsample = obufptr[nextoffset];
62 @@ -1414,9 +1428,22 @@
66 - int offset = offsets[j];
67 - int nextoffset = offsets[j+1];
68 - float frac = fractionals[j];
70 + /* We have reached the end of the sample.
71 + For looping samples: start over from the start,
72 + else fill with blanks and continue. */
73 + if( _alSourceIsLooping( src ) == AL_TRUE ) {
74 + obufptr = samp->orig_buffers[i];
77 + memset( &bufptr[j], 0, (len-j)*sizeof *bufptr );
82 + int offset = offsets[sj];
83 + int nextoffset = offsets[sj+1];
84 + float frac = fractionals[sj];
85 int firstsample = obufptr[offset];
86 int nextsample = obufptr[nextoffset];
88 @@ -1429,10 +1456,8 @@
89 bufptr[j] = MAX(finalsample, canon_min);
96 - memset(&bufptr[j], 0, (len-j)*sizeof *bufptr);
100 @@ -1468,15 +1493,12 @@
101 if( _alSourceIsLooping( src ) == AL_TRUE ) {
104 + * Note: in the resampling loop we already detected if
105 + * this was a looping sample. We still have to reset
106 + * soundpos to the correct value though...
109 - * This isn't right. soundpos should be set to
110 - * something different, and we may need to carry
111 - * over info so that the sound loops properly.
114 - /* FIXME: kind of kludgy */
115 - src->srcParams.soundpos = 0;
116 + src->srcParams.soundpos %= samp->size;
119 * let _alMixSources know it's time for this source
120 @@ -1547,7 +1569,7 @@
121 * Iterate over each buffers[0..nc-1]
123 for(i = 0; i < nc; i++) {
129 @@ -1575,7 +1597,7 @@
133 - /* don't run past end */
134 + /* check for end */
135 if(((clen + 1) * pitch * sizeof(ALshort)) >=
136 (samp->size - src->srcParams.soundpos))
138 @@ -1591,19 +1613,28 @@
139 * be necessary, but seems to improve performance quite
142 - for(j = 0; j < clen; j++)
144 + for(j = 0; j < len; j++)
146 - /* make sure we don't go past end of last source */
148 - assert(((j+1)*pitch)*2 <
149 - samp->size - src->srcParams.soundpos);
152 - float foffset = j * pitch;
154 + /* We have reached the end of the sample.
155 + For looping samples: start over from the start,
156 + else fill with blanks and continue. */
157 + if( _alSourceIsLooping( src ) == AL_TRUE ) {
158 + obufptr = samp->orig_buffers[i];
161 + memset( &bufptr[j], 0, (len-j)*sizeof *bufptr );
166 + float foffset = sj * pitch;
167 int offset = (int) foffset;
168 float frac = foffset - offset;
169 - int firstsample = obufptr[(int) (j * pitch)];
170 - int nextsample = obufptr[(int)((j+1) * pitch)];
171 + int firstsample = obufptr[(int) (sj * pitch)];
172 + int nextsample = obufptr[(int)((sj+1) * pitch)];
175 /* do a little interpolation */
176 @@ -1613,12 +1644,7 @@
177 finalsample = MIN(finalsample, canon_max);
178 bufptr[j] = MAX(finalsample, canon_min);
182 - /* JIV FIXME: use memset */
183 - for( ; j < len; j++)
190 @@ -1649,16 +1675,13 @@
192 if( _alSourceIsLooping( src ) == AL_TRUE ) {
196 + * Note: in the resampling loop we already detected if
197 + * this was a looping sample. We still have to reset
198 + * soundpos to the correct value though...
201 - * This isn't right. soundpos should be set to
202 - * something different, and we may need to carry
203 - * over info so that the sound loops properly.
206 - /* FIXME: kind of kludgy */
207 - src->srcParams.soundpos = 0;
208 + src->srcParams.soundpos %= samp->size;
211 * let _alMixSources know it's time for this source