0
0

Following proc loads mod in my app. In mods, there are 8bit mono samples with no looping. If this proc is wrong, please tell me where, because I really don’t know what to do to make this work

Copied sample plays ok, but when I put in into module, it sounds bad…

[code:b6mg4skl]
procedure LoadMod(FileName:pchar);
var
i,count:integer;
oldSample,newSample:pointer;
module:pointer;
freq,vol,pan,freq2,vol2,pan2,pri,len,mode:integer;
oldLen1,oldLen2:cardinal;
oldPtr1,oldPtr2:pointer;
newLen1,newLen2:cardinal;
newPtr1,newPtr2:pointer;

begin
module:=FMUSIC_LoadSong(FileName);
Assert(module<>nil);

count:=FMUSIC_GetNumSamples(module);
for i:=0 to count-1 do begin
oldSample:=FMUSIC_GetSample(module,i);

  len:=FSOUND_Sample_GetLength(oldSample); 
  if len=0 then 
     continue; 

  FSOUND_Sample_GetDefaultsEx(oldSample,freq,vol,pan,pri,freq2,vol2,pan2); 
  mode:=FSOUND_Sample_GetMode(oldSample); 


  newSample:=FSOUND_Sample_Alloc(FSOUND_FREE,len,mode,freq,vol,pan,pri); 

  FSOUND_Sample_Lock(newSample,0,len,newPtr1,newPtr2,newLen1,newLen2); 
  FSOUND_Sample_Lock(oldSample,0,newLen1,oldPtr1,oldPtr2,oldLen1,oldLen2); 

  Move(oldPtr1^,newPtr1^,newLen1); 

  FSOUND_Sample_Unlock(oldSample,oldPtr1,oldPtr2,oldLen1,oldLen2); 
  FSOUND_Sample_Unlock(newSample,newPtr1,newPtr2,newLen1,newLen2); 

  FSOUND_Sample_SetDefaultsEx(newSample,freq,vol,pan,pri,freq2,vol2,pan2); 
  FSOUND_Sample_GetLoopPoints(oldSample,freq,vol); 
  FSOUND_Sample_SetLoopPoints(newSample,freq,vol); 

  FMUSIC_SetSample(module,i,newSample); 

end;

FMUSIC_SetRowCallback(module,CallBackProc,1);
end;
[/code:b6mg4skl]

  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.