September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
1
Task/Metronome/00META.yaml
Normal file
1
Task/Metronome/00META.yaml
Normal file
|
|
@ -0,0 +1 @@
|
|||
--- {}
|
||||
20
Task/Metronome/AWK/metronome.awk
Normal file
20
Task/Metronome/AWK/metronome.awk
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# syntax: GAWK -f METRONOME.AWK
|
||||
@load "time"
|
||||
BEGIN {
|
||||
metronome(120,6,10)
|
||||
metronome(72,4)
|
||||
exit(0)
|
||||
}
|
||||
function metronome(beats_per_min,beats_per_bar,limit, beats,delay,errors) {
|
||||
print("")
|
||||
if (beats_per_min+0 <= 0) { print("error: beats per minute is invalid") ; errors++ }
|
||||
if (beats_per_bar+0 <= 0) { print("error: beats per bar is invalid") ; errors++ }
|
||||
if (limit+0 <= 0) { limit = 999999 }
|
||||
if (errors > 0) { return }
|
||||
delay = 60 / beats_per_min
|
||||
printf("delay=%f",delay)
|
||||
while (beats < limit) {
|
||||
printf((beats++ % beats_per_bar == 0) ? "\nTICK" : " tick")
|
||||
sleep(delay)
|
||||
}
|
||||
}
|
||||
22
Task/Metronome/Ada/metronome.ada
Normal file
22
Task/Metronome/Ada/metronome.ada
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
|
||||
--This package is for the delay.
|
||||
with Ada.Calendar; use Ada.Calendar;
|
||||
|
||||
--This package adds sound
|
||||
with Ada.Characters.Latin_1;
|
||||
|
||||
procedure Main is
|
||||
|
||||
begin
|
||||
|
||||
Put_Line ("Hello, this is 60 BPM");
|
||||
|
||||
loop
|
||||
|
||||
Ada.Text_IO.Put (Ada.Characters.Latin_1.BEL);
|
||||
delay 0.9; --Delay in seconds. If you change to 0.0 the program will crash.
|
||||
|
||||
end loop;
|
||||
|
||||
end Main;
|
||||
|
|
@ -8,7 +8,7 @@ class Metronome{
|
|||
public void start(){
|
||||
while(true){
|
||||
try {
|
||||
Thread.sleep((long)(1000*(60/bpm)));
|
||||
Thread.sleep((long)(1000*(60.0/bpm)));
|
||||
}catch(InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
|||
20
Task/Metronome/Perl/metronome.pl
Normal file
20
Task/Metronome/Perl/metronome.pl
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
use Time::HiRes qw(sleep gettimeofday);
|
||||
|
||||
local $| = 1; # autoflush
|
||||
|
||||
my $beats_per_minute = shift || 72;
|
||||
my $beats_per_bar = shift || 4;
|
||||
|
||||
my $i = 0;
|
||||
my $duration = 60 / $beats_per_minute;
|
||||
my $base_time = gettimeofday() + $duration;
|
||||
|
||||
for (my $next_time = $base_time ; ; $next_time += $duration) {
|
||||
if ($i++ % $beats_per_bar == 0) {
|
||||
print "\nTICK";
|
||||
}
|
||||
else {
|
||||
print " tick";
|
||||
}
|
||||
sleep($next_time - gettimeofday());
|
||||
}
|
||||
20
Task/Metronome/Sidef/metronome.sidef
Normal file
20
Task/Metronome/Sidef/metronome.sidef
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
func metronome (beats_per_minute = 72, beats_per_bar = 4) {
|
||||
|
||||
var counter = 0
|
||||
var duration = 60/beats_per_minute
|
||||
var base_time = Time.micro+duration
|
||||
|
||||
STDOUT.autoflush(true)
|
||||
|
||||
for next_time in (base_time..Inf `by` duration) {
|
||||
if (counter++ %% beats_per_bar) {
|
||||
print "\nTICK"
|
||||
}
|
||||
else {
|
||||
print " tick"
|
||||
}
|
||||
Sys.sleep(next_time - Time.micro)
|
||||
}
|
||||
}
|
||||
|
||||
say metronome(ARGV.map{ Num(_) }...)
|
||||
Loading…
Add table
Add a link
Reference in a new issue