5 uses System.Classes, System.SysUtils, Math, spWav;
7 function effect16BitWav(const sp: SpParam): integer;
8 function sinc(x: Single): Single;
9 function effectwav(const sp: SpParam): integer;
15 function effect16BitWav(const sp: SpParam): integer;
19 i, k, a, b, pmin, pmax: integer;
20 len, temp_size, offset0, offset1, p, q: integer;
21 m, ma, pitch, rate: Single;
22 pMem, pCpy, pRes: array of SmallInt;
28 temp_size := trunc(sp.samplePerSec * sp.bitsPerSample * sp.channels * 0.01);
29 pmin := trunc(sp.samplePerSec * sp.bitsPerSample * sp.channels * 0.005);
30 pmax := trunc(sp.samplePerSec * sp.bitsPerSample * sp.channels * 0.02);
31 SetLength(r, pmax - pmin);
35 len := trunc(sp.sizeOfData - sp.posOfData / (rate * sp.channels));
39 s := TMemoryStream.Create;
40 s.Write(sp.pWav^, sp.sizeOfData);
41 s.Position := sp.posOfData;
42 s.Read(Pointer(pRes)^, s.Size);
43 s.Position := sp.posOfData;
44 s.Read(Pointer(pCpy)^, s.Size);
48 for b := 0 to pmax - pmin - 1 do
51 for a := 0 to temp_size do
52 r[b] := r[b] + pRes[a] * pRes[a + b];
59 while offset1 + 2 * pmax < len do
63 pCpy[offset1 + i] := pRes[offset0 + i];
64 pCpy[offset1 + i + p] :=
65 trunc((pRes[offset0 + p + i] * (p - i) + pRes[offset0 + i] * i) / p);
67 q := trunc(rate * p / (1.0 - rate) + 0.5);
68 for i := p to q - 1 do
70 if offset1 + p + i >= len then
72 pCpy[offset1 + p + i] := pRes[offset0 + i];
78 k := trunc(len / pitch);
79 for i := 0 to k - 1 do
83 for a := q - j div 2 to q + j div 2 do
84 if (a >= 0) and (a < len) then
85 pMem[i] := pCpy[a] + pRes[a] * trunc(sinc(pi * (m - a)))
92 s := TMemoryStream.Create;
94 s.Write(sp.pWav^, sp.posOfData);
95 s.Write(Pointer(pMem)^, sp.sizeOfData - sp.posOfData);
97 s.Read(sp.pWav^, s.Size);
107 function sinc(x: Single): Single;
112 result := sin(x) / x;
115 function effectwav(const sp: SpParam): integer;
117 if sp.channels = 1 then
119 Form2.ListBox1.Items.Add('
\83X
\83e
\83\8c\83I
\83t
\83@
\83C
\83\8b\82É
\82µ
\82Ä
\82
\82¾
\82³
\82¢');
123 result := effect16BitWav(sp);