Oppure

Loading
06/03/10 23:44
program menu;

uses crt;

var
	tasto:char;
	flag:boolean;
	cont:integer;


begin
cont:=0;
flag:=false;
repeat
	clrscr;
	textbackground(white);
	textcolor(black);
	gotoxy(1,1); writeln('Cosa vuoi fare?');
	gotoxy(30,15); writeln('Ascoltare musica');
	gotoxy(30,17); writeln('Registrare musica');
	gotoxy(30,19); writeln('Uscire');

repeat
tasto:=readkey;
until (tasto=#80) or (tasto=#72);

if (tasto=#80) then cont:=cont+1;
if (tasto=#72) then cont:=cont-1;
if cont=4 then cont:=1;
if cont=-1 then cont:=3;

case cont of
1:	begin
	clrscr;
	gotoxy(1,1); writeln('Cosa vuoi fare?');
	textcolor(red);
	gotoxy(30,15); writeln('Ascoltare musica');
	gotoxy(30,17); writeln('Registrare musica');
	gotoxy(30,19); writeln('Uscire');
	end;

2:	begin
	clrscr;
	gotoxy(1,1); writeln('Cosa vuoi fare?');
	gotoxy(30,15); writeln('Ascoltare musica');
	textcolor(red);
	gotoxy(30,17); writeln('Registrare musica');
	textcolor(black);
	gotoxy(30,19); writeln('Uscire');
	end;

3:	begin
	clrscr;
	gotoxy(1,1); writeln('Cosa vuoi fare?');
	gotoxy(30,15); writeln('Ascoltare musica');
	gotoxy(30,17); writeln('Registrare musica');
	textcolor(red);
	gotoxy(30,19); writeln('Uscire');
	flag:=true;
	end;
end;

until flag;
end.


avevo già postato..ma adesso ho modificato perchè ho risolto da solo..qualcuno mi sa spiegare perchè si vede il colore solo con l'ultima opzione?! :pat:
Ultima modifica effettuata da 06/03/10 23:59
07/03/10 9:57
Poggi Marco
Ciao.
Ho letto il programma, e mon ho capito bene cosa deve fare.

Comuncue l' errore è dovuto al fatto imposti count in maniera errata.
Puoi usare direttamente tasto nei case, ed eventualmente specificare il tasto da premere nei menu'.

Un altro errore e quello di riscrivere il menù all' inizio del ciclo repeat.
In questo modo cancelli quello che scrivi nei case.

Come mai con P aumenti count, mentre con H lo diminuisci?
Ultima modifica effettuata da Poggi Marco 07/03/10 11:00
aaa
07/03/10 14:19
XBarboX
Postato originariamente da Poggi Marco:
Comuncue

:om:
Ultima modifica effettuata da XBarboX 07/03/10 14:20
aaa
07/03/10 15:03
Poggi Marco
Postato originariamente da XBarboX:

Postato originariamente da Poggi Marco:
Comuncue

:om:



Opss...8-|

Chiedo scusa!
aaa
07/03/10 20:30
Sono tornato proprio ora da una giornati in un agriturismo e ho terminato il programma :)

purtroppo sul mio pc la funzione sound non va :( se qualcuno mi fa la cortesia di compilarlo e farmi sapere se funge o meno gliene sarei grato :)

program riproduttore_multimediale;


uses crt;

var
	tasto:char;
	flag:boolean;
	cont:integer;

{Procedura per riprodurre il suono}
procedure riproduci_suono(input:integer);
var
	intensita,durata:integer;
begin
intensita:=input mod 1000;
durata:=input-intensita;
sound(intensita);
delay(durata);
nosound;
end;

{Procedura per registrare il suono}
procedure registra;
var
	lunghezza,frequenza,codificato:integer;
	percorso:string[30];
	nota:string[3];
	uscita:boolean;
	file_output:textfile;
	tasto:char;

begin
CLRSCR;
uscita:=false;

write('Percorso in cui salvare il file audio : '); readln(percorso);
	assign(file_output,percorso);
	rewrite(file_output);
repeat
repeat
	clrscr;
	textcolor(black);
	gotoxy(1,1);
	writeln('Premi ESC per uscire (uscirà dopo aver digitato la nota da salvare)');
	gotoxy(20,6);
	write('Nota (DO/RE/MI/FA/SOL/LA/SI) : ');
	tasto:=readkey;
	if tasto=#27 then uscita:=true;
		textcolor(red);
		readln(nota);

until (nota='DO') or (nota='RE') or (nota='MI') or (nota='FA') or (nota='SOL') or (nota='LA') or (nota='SI') or uscita;
	textcolor(black);
	write('Durata (in secondi) : '); readln(lunghezza);



if nota='DO' then frequenza:=262
else if nota='RE' then frequenza:=294
else if nota='MI' then frequenza:=330
else if nota='FA' then frequenza:=349
else if nota='SOL' then frequenza:=392
else if nota='LA' then frequenza:=440
else if nota='SI' then frequenza:=494;


	codificato:=frequenza+lunghezza*1000;
	append(file_output);
	write(file_output,codificato);
	write(file_output,' ');
	close(file_output);

until uscita;

end;


{procedura per la riproduzione}
procedure riproduzione;

type contenitore=array[1..255] of integer;

var
	i,b:integer;
	letto:contenitore;
	percorso:string[30];
	file_input:textfile;

begin
write('Percorso file da riprodurre : '); readln(percorso);
assign(file_input,percorso);
reset(file_input);

i:=1;
while not eof(file_input) do
begin
  read(file_input, letto[i]);
  i:=i+1;
end; 

b:=i;
i:=1;

for i:=1 to b do
begin
riproduci_suono(letto[i]);
end;

end;




{Programma}
begin
cont:=0;
flag:=false;

	clrscr;
	textbackground(white);
	textcolor(white);
	gotoxy(1,1); writeln('Cosa vuoi fare?');
	gotoxy(30,15); writeln('Ascoltare musica');
	gotoxy(30,17); writeln('Registrare musica');
	gotoxy(30,19); writeln('Uscire');

repeat
repeat
tasto:=readkey;
until (tasto=#80) or (tasto=#72);

if (tasto=#80) then begin tasto:=' '; cont:=cont+1 end;
if (tasto=#72) then begin tasto:=' '; cont:=cont-1 end;
if cont=4 then cont:=1;
if cont=-1 then cont:=3;

case cont of
1:	begin
	clrscr;
	textcolor(white);
	gotoxy(1,1); writeln('Cosa vuoi fare?');
	textcolor(red);
	gotoxy(30,15); writeln('Ascoltare musica');
	textcolor(white);
	gotoxy(30,17); writeln('Registrare musica');
	gotoxy(30,19); writeln('Uscire');
	repeat
	begin
	tasto:=readkey;
	if tasto=#13 then riproduzione;
	end;
	until (tasto=#13) or (tasto=#80) or (tasto=#72);

	end;

2:	begin
	clrscr;
	textcolor(white);
	gotoxy(1,1); writeln('Cosa vuoi fare?');
	gotoxy(30,15); writeln('Ascoltare musica');
	textcolor(red);
	gotoxy(30,17); writeln('Registrare musica');
	textcolor(white);
	gotoxy(30,19); writeln('Uscire');
	repeat
	begin
	tasto:=readkey;
	if tasto=#13 then registra;
	end;
	until (tasto=#13) or (tasto=#80) or (tasto=#72) or (tasto=#27);
	end;

3:	begin
	clrscr;
	gotoxy(1,1); writeln('Cosa vuoi fare?');
	gotoxy(30,15); writeln('Ascoltare musica');
	gotoxy(30,17); writeln('Registrare musica');
	textcolor(red);
	gotoxy(30,19); writeln('Uscire');
	repeat
	begin
		tasto:=readkey;
		if tasto=#13 then 
			begin
			writeln('Bye bye :D'); delay(3000);	
			flag:=true
			end;
	end;
	until (tasto=#13) or (tasto=#80) or (tasto=#72);
	end;
end;

until flag;
end.


errori/consigli/migliorie sono ben accetti (sono un principiante ancora:rofl:) :D
07/03/10 21:11
Poggi Marco
Ho letto il programma, e la scelta del menu è ancore molto macchinosa.
Potresti accedere alle varie funzioni del programma, confrontando semplicemente la veriabile tasto.

La funzione di registrazione, è alquanto confusa.
La chiusura del file, avviene all' interno del ciclo repeat. In questo modo verra salvata solo la prima nota. Il mio consiglio è quello di salvare il valore "codificato" e "lunghezza" separatamente per ogni nota.
L' istruzione " write(file_output,' '); " è inutile e ti darà problemi in lettura. Infatti il comando write separa automaticamente i dati scritti su file.


Nella funzione procedure "riproduci_suono(input:integer); " usi il comando delay.
Purtroppo, esso si affida ai clok della cpu, quindi non è affidabile.
Sei costratto a programmarti una funzione apposita.








Ultima modifica effettuata da Poggi Marco 07/03/10 21:27
aaa
07/03/10 23:12
Per il menù cercherò di provvedere domani, anch'io mi sono reso conto che è abbastanza macchinoso..ma ho letto robe che, a mio avviso, sono peggiori..

la funzione di registrazione è l'unica cosa che al momento (almeno sul mio pc) funge :D salva tutto. la mia idea è quella di salvare la frequenza della nota e la sua durata in un unico numero chiamato codificato che poi appunto verra decodificato e riportato ad essere 2 numeri separati..

ciò che al momento mi da fastidio è la difficoltà nell'uscita dalle funzioni del programma..una volta terminata una determinata funzione vi è per forza il bisogno di premere freccia in giù o freccia in su per tornare al menù principale..però la cosa che mi interesserebbe maggiormente è sapere se si sente qualcosa..
08/03/10 13:16
program riproduttore_multimediale;


uses crt;

var flag,stop:boolean;

{Procedura per riprodurre il suono}
procedure riproduci_suono(input:integer);
var
	intensita,durata:integer;
begin
intensita:=input mod 1000;
durata:=input-intensita;
sound(intensita);
delay(durata);
nosound;
end;

{Procedura per registrare il suono}
procedure registra;
var
	lunghezza,frequenza,codificato:integer;
	percorso:string[30];
	nota:string[3];
	uscita:boolean;
	file_output:textfile;
	tasto:char;

begin
CLRSCR;
uscita:=false;

write('Percorso in cui salvare il file audio : '); readln(percorso);
	assign(file_output,percorso);
	rewrite(file_output);
repeat
repeat
	clrscr;
	textcolor(black);
	gotoxy(1,1);
	writeln('Premi ESC per uscire (uscirà dopo aver digitato la nota da salvare)');
	gotoxy(20,6);
	write('Nota (DO/RE/MI/FA/SOL/LA/SI) : ');
	tasto:=readkey;
	if tasto=#27 then uscita:=true;
		textcolor(red);
		readln(nota);

until (nota='DO') or (nota='RE') or (nota='MI') or (nota='FA') or (nota='SOL') or (nota='LA') or (nota='SI') or uscita;
	textcolor(black);
	write('Durata (in secondi) : '); readln(lunghezza);



if nota='DO' then frequenza:=262
else if nota='RE' then frequenza:=294
else if nota='MI' then frequenza:=330
else if nota='FA' then frequenza:=349
else if nota='SOL' then frequenza:=392
else if nota='LA' then frequenza:=440
else if nota='SI' then frequenza:=494;


	codificato:=frequenza+lunghezza*1000;
	append(file_output);
	write(file_output,codificato);
	write(file_output,' ');
	close(file_output);

until uscita;

end;


{procedura per la riproduzione}
procedure riproduzione;

type contenitore=array[1..255] of integer;

var
	i,b:integer;
	letto:contenitore;
	percorso:string[30];
	file_input:textfile;

begin
write('Percorso file da riprodurre : '); readln(percorso);
assign(file_input,percorso);
reset(file_input);

i:=1;
while not eof(file_input) do
begin
  read(file_input, letto[i]);
  i:=i+1;
end; 

b:=i;
i:=1;

for i:=1 to b do
begin
riproduci_suono(letto[i]);
end;

end;

{Menu}
procedure menu;


var
	tasto:char;
	move:boolean;
	cont:integer;


begin
cont:=0;
flag:=false;
move:=false;

	clrscr;
	textbackground(white);
	textcolor(white);
	gotoxy(1,1); writeln('Cosa vuoi fare?');
	gotoxy(30,15); writeln('Ascoltare musica');
	gotoxy(30,17); writeln('Registrare musica');
	gotoxy(30,19); writeln('Uscire');

repeat

stop:=false;

if move=false then
begin
repeat
tasto:=readkey;
until (tasto=#80) or (tasto=#72);
if (tasto=#80) then begin tasto:=' '; cont:=cont+1 end;
if (tasto=#72) then begin tasto:=' '; cont:=cont-1 end;
end;

if cont=4 then cont:=1;
if cont=-1 then cont:=3;
move:=false;

case cont of
1:	begin
	clrscr;
	textcolor(white);
	gotoxy(1,1); writeln('Cosa vuoi fare?');
	textcolor(red);
	gotoxy(30,15); writeln('Ascoltare musica');
	textcolor(white);
	gotoxy(30,17); writeln('Registrare musica');
	gotoxy(30,19); writeln('Uscire');
	repeat
	begin
	tasto:=readkey;
	if tasto=#13 then
	begin
	riproduzione;
	stop:=true
	end;
	if tasto=#80 then begin cont:=cont+1; move:=true end;
	if tasto=#72 then begin cont:=cont-1; move:=true end;
	end;
	until (tasto=#13) or (tasto=#80) or (tasto=#72) or stop;

	end;

2:	begin
	clrscr;
	textcolor(white);
	gotoxy(1,1); writeln('Cosa vuoi fare?');
	gotoxy(30,15); writeln('Ascoltare musica');
	textcolor(red);
	gotoxy(30,17); writeln('Registrare musica');
	textcolor(white);
	gotoxy(30,19); writeln('Uscire');
	repeat
	begin
	tasto:=readkey;
	if tasto=#13 then begin
	registra;
	stop:=true
	end;
	if tasto=#80 then begin cont:=cont+1; move:=true end;
	if tasto=#72 then begin cont:=cont-1; move:=true end;
	end;
	until (tasto=#13) or (tasto=#80) or (tasto=#72) or stop;
	end;

3:	begin
	clrscr;
	gotoxy(1,1); writeln('Cosa vuoi fare?');
	gotoxy(30,15); writeln('Ascoltare musica');
	gotoxy(30,17); writeln('Registrare musica');
	textcolor(red);
	gotoxy(30,19); writeln('Uscire');
	repeat
	begin
		tasto:=readkey;
		if tasto=#13 then 
			begin
			writeln('Bye bye :D'); delay(3000);	
			flag:=true
			end;
		if tasto=#80 then begin cont:=cont+1; move:=true end;
		if tasto=#72 then begin cont:=cont-1; move:=true end;
	end;
	until (tasto=#13) or (tasto=#80) or (tasto=#72);
	end;
end;

until flag OR stop;
end;



{Programma}
begin

repeat
menu
until flag;

end.


So che è mostruosamente brutto il menu, ma vorrei saperer se qualcuno sente l'audio. Se qualcuno mi vuole aiutare per favore provi a registrare qualcosa prima e poi provi a riprodurre.