Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unsigned currentSample=0;
- void user_callback(void* userdata, void* _stream, int size, SDL_bool hasInput){
- if(userdata == NULL){ exit_early: memset(_stream,0,size); return; }
- kit_acodecPCM* pcm = userdata;
- Uint64 numSamples = pcm->numSamples;
- kit_acodecPCM_F32S* src = pcm->f32s;
- if(pcm->format != AUDIO_F32) goto exit_early;
- if(pcm->channels != 2) goto exit_early;
- if(currentSample >= numSamples) goto exit_early;
- memset(_stream,0,size);
- kit_acodecPCM_F32S* dst=_stream; int len=size/(2*4);
- for(int i=0; i<len; ++i){
- dst[i] = src[currentSample];
- dst[i].l *= 0.7;
- dst[i].r *= 0.7;
- if((++currentSample)>=numSamples){ currentSample=-1; break; }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement