Sunteți pe pagina 1din 8

PASCAL TURBO

ALGORITMO PARA NOTAS MUSICALES:

Uses Crt;

Var CantNotas:array[1..50] of Longint; {Vector que almacena las notas} Frecuencia:array[1..7] of Longint; {Vector para las octavas}

Var T:char; a,i,n,s,o:Word;

Label z,y;

Procedure Cuadro;

Var g1:integer;

Begin

Textcolor(White); Gotoxy(2,2);Write(''); Gotoxy(2,23);write(''); Gotoxy(15,2);write(''); Gotoxy(15,23);write('');

For g1:=3 To 14 Do

Begin gotoxy(g1,2);write(''); gotoxy(g1,5);write(''); gotoxy(g1,8);write(''); gotoxy(g1,11);write(''); gotoxy(g1,14);write(''); gotoxy(g1,17);write(''); gotoxy(g1,20);write(''); gotoxy(g1,23);write(''); End;

for g1:=3 To 22 Do Begin Gotoxy(2,g1);Write(''); Gotoxy(15,g1);Write(''); End;

End;

Procedure N_0;

Begin Frecuencia[1]:= 32; Frecuencia[2]:= 36; Frecuencia[3]:= 41; Frecuencia[4]:= 44;

Frecuencia[5]:= 49; Frecuencia[6]:= 55; Frecuencia[7]:= 62; End;

Procedure N_1; {Procedimento que cambia la frecuencia de las notas}

Begin s:=Frecuencia[n]; For i:=1 to o do Begin s:=Frecuencia[n]*2; End; End;

Procedure N_2; {Procedimento para el sonido} Begin sound(s); delay(100); nosound; a:=a+1; End;

procedure N_3; Begin For i:=1 to a do begin

sound(CantNotas[i]); delay(200); nosound; delay(100); end; End;

BEGIN N_0; clrscr; o:=3; a:=0; repeat y: Clrscr;

Cuadro; Textcolor (White); gotoxy (6,4); Writeln ('c=DO'); gotoxy (6,7); Writeln ('d=RE'); gotoxy (6,10); Writeln ('e=MI'); gotoxy (6,13); Writeln ('f=FA'); gotoxy (6,16); Writeln ('g=SOL'); gotoxy (6,19); Writeln ('a=LA'); gotoxy (6,22); Writeln ('b=SI');

Textcolor (Yellow); gotoxy (32,8); Writeln ('Proyecto Examen de Recuperacion'); Textcolor (Red); gotoxy (31,12); Writeln ('Notas que se estan almacenando: ',a); Textcolor (White); gotoxy (32,17); writeln ('Para aumentar de octava tecla +'); gotoxy (32,15); writeln ('Para disminuir de octava tecla -'); gotoxy (32,19); writeln ('Para Reproducir ''P'''); gotoxy (52,19); T:=readkey;

{Aumenta de octava}

if (T='+') and (o<5) and (o>0) then Begin o:= o+1; End;

{Disminuye de octava}

if (T='-') and (o<5) and (o>0) then Begin o:=o-1; End;

if T='c'then begin n:=1;

N_1; N_2; end; if T='d'then begin n:=2; N_1; N_2; end; if T='e' then begin n:=3; N_1; N_2; end; if T='f' then begin n:=4; N_1; N_2; end; if T='g' then begin n:=5; N_1; N_2; end;

if T='a' then begin n:=6; N_1; N_2; end; if T='b' then begin n:=7; N_1; N_2; end; if T='p' then begin N_3; goto z; end; CantNotas[a]:=s; Until (T='s') or (a=50);

z: Clrscr; Gotoxy(27,5); Writeln('Para Salir Presione la Tecla ''t'' '); Gotoxy(23,7); Write('Presione cualquier tecla para Continuar: '); read(T);

If T='t' Then Begin

Halt(1); End Else Goto y;

END.

S-ar putea să vă placă și