#include "SDL/SDL.h" #include "math.h" #define BUFFER_SIZE 1024 // Longitud del buffer, en samples #define SAMPLING_RATE 44100 // Este comentario esta extraido de SDL_audio.h, porque me ha molado /* This function is called when the audio device needs more data. * 'stream' is a pointer to the audio data buffer * 'len' is the length of that buffer in bytes. * Once the callback returns, the buffer will no longer be valid. * Stereo samples are stored in a LRLRLR ordering. */ void play_sen(void *userdata, Uint8 *stream, int len) { int i; int num_samples = len / 2; static int pos = 0; float buffer[num_samples]; Sint16 *dst_buf = (Sint16*) stream; for (i=0; i 1.0f) v = 1.0f; else if (v< -1.0f) v = -1.0f; dst_buf[i] = (Sint16)(32767.0f*v); } pos += num_samples; } void play_whitenoise(void *userdata, Uint8 *stream, int len) { int i; int num_samples = len / 2; Sint16 *buf = (Sint16*) stream; for (i = 0; i