mirror of
https://github.com/vishapoberon/compiler.git
synced 2026-04-06 21:32:26 +00:00
parent
6939e38e29
commit
da332ab43b
3 changed files with 70 additions and 0 deletions
3
src/test/sound/Readme.md
Normal file
3
src/test/sound/Readme.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
This is a modified example of sound generation taken from www.waltzballs.org/other/prog.html#audio
|
||||||
|
|
||||||
|
|
||||||
58
src/test/sound/beep.Mod
Normal file
58
src/test/sound/beep.Mod
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
MODULE beep;
|
||||||
|
IMPORT Files := OakFiles, rm:=oocRealMath, Unix;
|
||||||
|
|
||||||
|
CONST (*pi2=6.28318;*)
|
||||||
|
pi2 = 6.2831802368164062;
|
||||||
|
rate=44.1E3;
|
||||||
|
lf=20.0;
|
||||||
|
seconds=2.0;
|
||||||
|
|
||||||
|
VAR t,a,b,freq,xkm1,ykm1,est,gf:REAL;
|
||||||
|
i,e:LONGINT;
|
||||||
|
ai:INTEGER;
|
||||||
|
outvar: Files.File;
|
||||||
|
outfile: Files.Rider;
|
||||||
|
first: BOOLEAN;
|
||||||
|
|
||||||
|
PROCEDURE highpass(t,fhp,xk:REAL;VAR yk:REAL);
|
||||||
|
BEGIN
|
||||||
|
IF first THEN
|
||||||
|
est:=rm.exp(-pi2*fhp*t);
|
||||||
|
gf:=(1+est)/(1-est);first:=FALSE;
|
||||||
|
END(*IF*);
|
||||||
|
|
||||||
|
yk:=(xk-xkm1)/2;
|
||||||
|
xkm1:=xk;
|
||||||
|
xk:=yk;
|
||||||
|
yk:=est*ykm1+(1-est)*xk;
|
||||||
|
ykm1:=yk;
|
||||||
|
yk:=gf*yk;
|
||||||
|
END highpass;
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
t:=1.0/rate; xkm1:=0.0; ykm1:=0.0; first:=TRUE;
|
||||||
|
|
||||||
|
outvar:=Files.New("beepfile");
|
||||||
|
IF outvar # NIL THEN
|
||||||
|
Files.Set(outfile, outvar, 0);
|
||||||
|
ELSE
|
||||||
|
HALT(1)
|
||||||
|
END;
|
||||||
|
|
||||||
|
e:=ENTIER(rate*seconds);freq:=1000;
|
||||||
|
|
||||||
|
FOR i:=1 TO e DO
|
||||||
|
a:=3000*rm.sin(pi2*freq*i/rate);
|
||||||
|
(* highpass(t,lf,a,b);*)
|
||||||
|
(* ai:=SHORT(ENTIER(b));*)
|
||||||
|
ai:=SHORT(ENTIER(a));
|
||||||
|
IF i>ENTIER(rate*10/lf)THEN
|
||||||
|
Files.WriteInt(outfile, ai);;
|
||||||
|
END;
|
||||||
|
END;
|
||||||
|
|
||||||
|
Files.Register(outvar);
|
||||||
|
i:=Unix.System("oggenc -r -C 1 beepfile");
|
||||||
|
i:=Unix.System("ogg123 beepfile.ogg");
|
||||||
|
END beep.
|
||||||
|
|
||||||
9
src/test/sound/makefile
Normal file
9
src/test/sound/makefile
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
|
||||||
|
VOC = /opt/voc/bin/voc
|
||||||
|
|
||||||
|
all:
|
||||||
|
$(VOC) -M beep.Mod
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm *.o
|
||||||
|
rm *.c
|
||||||
Loading…
Add table
Add a link
Reference in a new issue