Skip to content

Instantly share code, notes, and snippets.

@tomaes
Created May 4, 2020 07:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomaes/72624052db073776843bb4d602f5e173 to your computer and use it in GitHub Desktop.
Save tomaes/72624052db073776843bb4d602f5e173 to your computer and use it in GitHub Desktop.
Audio micro game. Make it through 12 rounds of approximate frequency estimation.
program Hz; {sound micro game; 2020-5-4}
uses crt;
var f,q,p,r: integer; s: string;
begin
clrscr;
writeln('Guess My Frequency (20-2000Hz)');
randomize;
r := 0; s := '';
repeat
f := random(1980)+20;
sound(f); delay(200); nosound;
write('Hz? ');
readln(q);
inc(r);
inc(p,200);
dec(p,abs(q-f));
if (q-f > 0) then s := '+' else s := '';
writeln('/\/:',f,' a-b:', s, q-f, ' $:', p);
until (r = 12) or (p < 0);
writeln(r, ' round[s]');
if (p > 400) then writeln('Well done!');
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment