September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
16
Task/Metronome/Kotlin/metronome.kotlin
Normal file
16
Task/Metronome/Kotlin/metronome.kotlin
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
// version 1.1.2
|
||||
|
||||
fun metronome(bpm: Int, bpb: Int, maxBeats: Int = Int.MAX_VALUE) {
|
||||
val delay = 60_000L / bpm
|
||||
var beats = 0
|
||||
do {
|
||||
Thread.sleep(delay)
|
||||
if (beats % bpb == 0) print("\nTICK ")
|
||||
else print("tick ")
|
||||
beats++
|
||||
}
|
||||
while (beats < maxBeats)
|
||||
println()
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) = metronome(120, 4, 20) // limit to 20 beats
|
||||
14
Task/Metronome/Ruby/metronome.rb
Normal file
14
Task/Metronome/Ruby/metronome.rb
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/ruby
|
||||
|
||||
bpm = Integer(ARGV[0]) rescue 60 # sets BPM by the first command line argument, set to 60 if none provided
|
||||
msr = Integer(ARGV[1]) rescue 4 # sets number of beats in a measure by the second command line argument, set to 4 if none provided
|
||||
i = 0
|
||||
|
||||
loop do
|
||||
(msr-1).times do
|
||||
puts "\a"
|
||||
sleep(60.0/bpm)
|
||||
end
|
||||
puts "\aAND #{i += 1}"
|
||||
sleep(60.0/bpm)
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue