src/audio/SDL_wave.c
branchSDL-1.2
changeset 12800 e52413f52586
parent 6227 e11fd9609d10
child 12801 388987dff7bf
equal deleted inserted replaced
12786:4e73be7b4787 12800:e52413f52586
   262 		9493, 10442, 11487, 12635, 13899, 15289, 16818, 18500, 20350,
   262 		9493, 10442, 11487, 12635, 13899, 15289, 16818, 18500, 20350,
   263 		22385, 24623, 27086, 29794, 32767
   263 		22385, 24623, 27086, 29794, 32767
   264 	};
   264 	};
   265 	Sint32 delta, step;
   265 	Sint32 delta, step;
   266 
   266 
       
   267 	/* Clamp index value. The inital value can be invalid. */
       
   268 	if ( state->index > 88 ) {
       
   269 		state->index = 88;
       
   270 	} else
       
   271 	if ( state->index < 0 ) {
       
   272 		state->index = 0;
       
   273 	}
       
   274 
   267 	/* Compute difference and new sample value */
   275 	/* Compute difference and new sample value */
   268 	step = step_table[state->index];
   276 	step = step_table[state->index];
   269 	delta = step >> 3;
   277 	delta = step >> 3;
   270 	if ( nybble & 0x04 ) delta += step;
   278 	if ( nybble & 0x04 ) delta += step;
   271 	if ( nybble & 0x02 ) delta += (step >> 1);
   279 	if ( nybble & 0x02 ) delta += (step >> 1);
   273 	if ( nybble & 0x08 ) delta = -delta;
   281 	if ( nybble & 0x08 ) delta = -delta;
   274 	state->sample += delta;
   282 	state->sample += delta;
   275 
   283 
   276 	/* Update index value */
   284 	/* Update index value */
   277 	state->index += index_table[nybble];
   285 	state->index += index_table[nybble];
   278 	if ( state->index > 88 ) {
       
   279 		state->index = 88;
       
   280 	} else
       
   281 	if ( state->index < 0 ) {
       
   282 		state->index = 0;
       
   283 	}
       
   284 
   286 
   285 	/* Clamp output sample */
   287 	/* Clamp output sample */
   286 	if ( state->sample > max_audioval ) {
   288 	if ( state->sample > max_audioval ) {
   287 		state->sample = max_audioval;
   289 		state->sample = max_audioval;
   288 	} else
   290 	} else