OSDN Git Service

まずまず
[sample-delphi/sample-DELPHI.git] / effect.pas
1 unit effect;
2
3 interface
4
5 uses System.Classes, System.SysUtils, spWav;
6
7 function effect8BitWav(InInMem, InOutMem: TMemoryStream; sp: SpParam): integer;
8 function effect16BitWav(InInMem, InOutMem: TMemoryStream; sp: SpParam): integer;
9 procedure usage;
10
11 implementation
12
13 function effect8BitWav(InInMem, InOutMem: TMemoryStream; sp: SpParam): integer;
14 var
15   i, j: integer;
16   pInMem, pOutMem: TBytes;
17 begin
18   j := sp.sizeOfData - 2;
19   pInMem := InInMem.Memory;
20   pOutMem := InOutMem.Memory;
21   for i := 0 to sp.sizeOfData div 2 do
22   begin
23     pOutMem[2 * i] := pInMem[j];
24     pOutMem[2 * i + 1] := pInMem[j + 1];
25     dec(j, 2);
26   end;
27 end;
28
29 function effect16BitWav(InInMem, InOutMem: TMemoryStream; sp: SpParam): integer;
30 var
31   i, j, k: integer;
32   pInMem, pOutMem: TBytes;
33 begin
34   pInMem := InInMem.Memory;
35   pOutMem := InOutMem.Memory;
36   i := 0;
37   k := sp.sizeOfData div 2;
38   while i < k do
39   begin
40     pOutMem[i] := pInMem[j];
41     pOutMem[i + 1] := pInMem[j + 1];
42     inc(i, 2);
43     dec(j, 2);
44   end;
45 end;
46
47 procedure usage;
48 begin
49   Writeln('\82Ì\82±\82¬\82è\94g');
50   Writeln('\97á\81Feffect.wav 100 2000');
51 end;
52
53 end.