function effect8BitWav(const sp: SpParam): integer;
var
i, delayStart: integer;
+ k: Single;
pMem, pCpy: array of Byte;
s: TMemoryStream;
L, R, DuetL, DuetR: SmallInt;
pMem := sp.pWav;
pCpy := s.Memory;
delayStart := sp.samplePerSec * sp.cycleuSec;
- for i := delayStart to sp.sizeOfData div (sp.bitsPerSample *
- SizeOf(Byte)) do
+ i := delayStart + sp.posOfData;
+ k := 8 * sp.sizeOfData / sp.bitsPerSample;
+ while i < k do
begin
L := pMem[i + 0];
R := pMem[i + 1];
DuetR := pCpy[i + 1 - delayStart];
inc(L, DuetL);
inc(R, DuetR);
- pMem[i+0]:=L;
- pMem[i+1]:=R;
+
+ pMem[i + 0] := L;
+ pMem[i + 1] := R;
+ inc(i, 2);
end;
except
result := -1;
function effect16BitWav(const sp: SpParam): integer;
var
i, delayStart: integer;
+ k: Single;
pMem, pCpy: array of SmallInt;
s: TMemoryStream;
L, R, DuetL, DuetR: SmallInt;
begin
result := 0;
+ s := TMemoryStream.Create;
try
- s := TMemoryStream.Create;
- s.ReadBuffer(sp.pWav^, sp.sizeOfData);
+ SetLength(pCpy, sp.sizeOfData);
+ s.Write(sp.pWav^, sp.sizeOfData);
+ s.Position := 0;
+ s.Read(Pointer(pCpy)^, sp.sizeOfData);
pMem := sp.pWav;
- pCpy := s.Memory;
- delayStart := sp.samplePerSec * sp.cycleuSec;
- for i := delayStart to sp.sizeOfData div (sp.bitsPerSample *
- SizeOf(SmallInt)) do
+ delayStart := sp.posOfData + sp.samplePerSec * sp.cyclicSec;
+ i := delayStart + sp.posOfData;
+ k := 8 * sp.sizeOfData / sp.bitsPerSample;
+ while i < k do
begin
L := pMem[i + 0];
R := pMem[i + 1];
DuetR := pCpy[i + 1 - delayStart];
inc(L, DuetL);
inc(R, DuetR);
- L := SmallInt(max(-32768, min(32767, L)));
- R := SmallInt(max(-32768, min(32767, R)));
+ L := max(-32768, min(32767, L));
+ R := max(-32768, min(32767, R));
pMem[i + 0] := L;
pMem[i + 1] := R;
+ inc(i, 2);
end;
except
result := -1;
end;
+ s.Free;
+ Finalize(pCpy);
end;
procedure usage;
<DCC_RemoteDebug>true</DCC_RemoteDebug>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_1_Win32)'!=''">
- <Debugger_RunParams>toujyo.wav effect.wav</Debugger_RunParams>
+ <Debugger_RunParams>toujyo.wav </Debugger_RunParams>
<DCC_RemoteDebug>false</DCC_RemoteDebug>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_1_Win64)'!=''">