0
0

Hi there,

I am trying to mix a sample into a playing looping sample (see code below); the result is either a white noise sound or the correct sound, depending on the computer’s mood. Any ideas where I have gone wrong :roll: ? I’m using FMOD 3.72 on Windows.

Thanks for your help !

Sylvain.-
[code:3rk1p8pr]FSOUND_SAMPLE SRC, *DEST ;
int srcFreq, srcVol, srcPan, srcPri ;
int destFreq, destVol, destPan, destPri, destChannel, destCurrent ;
void *srcPtr1,
srcPtr2, *destPtr1, *destPtr2 ;
unsigned int srcLen1,srcLen2,destLen1,destLen2 ;

FSOUND_Init(32000, 64, FSOUND_HW3D);

SRC=FSOUND_Sample_Load(FSOUND_FREE,"chimes.wav",FSOUND_NORMAL,0,0) ;
FSOUND_Sample_GetDefaults(SRC,&srcFreq,&srcVol,&srcPan,&srcPri) ;

DEST=FSOUND_Sample_Alloc(FSOUND_FREE,10*FSOUND_Sample_GetLength(SRC), FSOUND_Sample_GetMode(SRC),srcFreq,srcVol,128,srcPri) ;
FSOUND_Sample_SetMode(DEST, FSOUND_LOOP_NORMAL);
FSOUND_Sample_GetDefaults(DEST,&destFreq, &destVol,&destPan,&destPri) ;
destChannel=FSOUND_PlaySound (FSOUND_FREE,DEST) ;

Sleep(50L) ;

destCurrent=FSOUND_GetCurrentPosition(destChannel)+50 ;

FSOUND_Sample_Lock(DEST,destCurrent,FSOUND_Sample_GetLength(SRC), &destPtr1,&destPtr2,&destLen1,&destLen2) ;

FSOUND_Sample_Lock(SRC,0,destLen1,&srcPtr1,&srcPtr2,&srcLen1,&srcLen2 ) ;
FSOUND_DSP_MixBuffers(destPtr1,srcPtr1,destLen1,destFreq,destVol, destPan,FSOUND_Sample_GetMode(DEST));
FSOUND_Sample_Unlock(SRC, srcPtr1, srcPtr2, srcLen1, srcLen2);

FSOUND_Sample_Lock(SRC,destLen1,destLen2,&srcPtr1,&srcPtr2,&srcLen1,&srcLen2) ;
FSOUND_DSP_MixBuffers(destPtr2,srcPtr2,destLen1,destFreq,destVol, destPan,FSOUND_Sample_GetMode(DEST)) ;
FSOUND_Sample_Unlock(SRC, srcPtr1, srcPtr2, srcLen1, srcLen2) ;

FSOUND_Sample_Unlock(DEST,destPtr1,destPtr2,destLen1,destLen2) ;

Sleep(8000L) ;

FSOUND_StopSound(destChannel) ;
FSOUND_Sample_Free(SRC) ;
FSOUND_Sample_Free(DEST) ;
FSOUND_Close();[/code:3rk1p8pr]

  • You must to post comments
0
0

Thanks a lot for your efficiency, Brett, it is much clearer now :)

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.