5 uses System.Classes, System.SysUtils, Math, spWav;
7 function effect8BitWav(const sp: SpParam): integer;
8 function effect16BitWav(const sp: SpParam): integer;
9 function sinc(x: Single): Single;
11 function effectwav(const sp: SpParam): integer;
15 function effect8BitWav(const sp: SpParam): integer;
19 function effect16BitWav(const sp: SpParam): integer;
23 i, k, a, b, pmin, pmax: integer;
24 len, temp_size, offset0, offset1, p, q: integer;
25 m, ma, pitch, rate: Single;
26 pMem, pCpy, pRes: array of SmallInt;
32 temp_size := trunc(sp.samplePerSec * sp.bitsPerSample * sp.channels * 0.01);
33 pmin := trunc(sp.samplePerSec * sp.bitsPerSample * sp.channels * 0.005);
34 pmax := trunc(sp.samplePerSec * sp.bitsPerSample * sp.channels * 0.02);
35 SetLength(r, pmax - pmin);
36 offset0 := sp.posOfData;
37 offset1 := sp.posOfData;
39 len := trunc(sp.sizeOfData / (rate * sp.channels));
42 s := TMemoryStream.Create;
43 s.Write(sp.pWav^, sp.sizeOfData);
45 s.Read(Pointer(pRes)^, s.Size);
48 k := (sp.sizeOfData - sp.posOfData) div sp.channels;
49 for b := 0 to pmax - pmin - 1 do
52 for a := sp.posOfData to sp.posOfData + temp_size do
53 r[b] := r[b] + pMem[a] * pMem[a + b];
60 while offset1 + 2 * pmax < len do
66 pCpy[offset1 + i] := pRes[offset0 + i];
67 pCpy[offset1 + i + p] := trunc(pRes[offset0 + p + i] * (p - i) / p +
68 pRes[offset0 + i] * i / p);
70 q := trunc(rate * p / (1.0 - rate) + 0.5);
71 for i := p to q - 1 do
73 if offset1 + i + p >= len then
75 pCpy[offset1 + p + i] := pMem[offset0 + i];
81 for i := sp.posOfData to k - 1 do
85 for a := q - j div 2 to q + j div 2 do
86 if (a >= sp.posOfData) and (a < len) then
87 pMem[i] := pCpy[a] + pRes[a] * trunc(sinc(pi * (m - a)))
99 function sinc(x: Single): Single;
104 result := sin(x) / x;
109 Writeln('
\82Ì
\82±
\82¬
\82è
\94g');
110 Writeln('
\97á
\81Feffect.wav 100 2000');
113 function effectwav(const sp: SpParam): integer;
115 if sp.channels = 1 then
117 Writeln('
\83X
\83e
\83\8c\83I
\83t
\83@
\83C
\83\8b\82É
\82µ
\82Ä
\82
\82¾
\82³
\82¢');
120 if sp.bitsPerSample = 8 then
121 result := effect8BitWav(sp)
123 result := effect16BitWav(sp);