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: 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));
41 k := (sp.sizeOfData - sp.posOfData) div sp.channels;
42 for b := 0 to pmax - pmin - 1 do
45 for a := sp.posOfData to sp.posOfData + temp_size do
46 r[b] := r[b] + pMem[a] * pMem[a + b];
53 while offset1 + 2 * pmax < len do
59 pCpy[offset1 + i] := pMem[offset0 + i];
60 pCpy[offset1 + i + p] := trunc(pMem[offset0 + p + i] * (p - i) / p +
61 pMem[offset0 + i] * i / p);
63 q := trunc(rate * p / (1.0 - rate) + 0.5);
64 for i := p to q - 1 do
66 if offset1 + i + p >= k then
68 pCpy[offset1 + p + i] := pMem[offset0 + i];
74 for i := sp.posOfData to k - 1 do
78 for a := q - j div 2 to q + j div 2 do
79 if (a >= sp.posOfData) and (a < k) then
80 pMem[i] := pCpy[a] + pMem[a] * trunc(sinc(pi * (m - a)))
91 function sinc(x: Single): Single;
101 Writeln('
\82Ì
\82±
\82¬
\82è
\94g');
102 Writeln('
\97á
\81Feffect.wav 100 2000');
105 function effectwav(const sp: SpParam): integer;
107 if sp.channels = 1 then
109 Writeln('
\83X
\83e
\83\8c\83I
\83t
\83@
\83C
\83\8b\82É
\82µ
\82Ä
\82
\82¾
\82³
\82¢');
112 if sp.bitsPerSample = 8 then
113 result := effect8BitWav(sp)
115 result := effect16BitWav(sp);