Metronome: Difference between revisions
Content added Content deleted
m (→{{header|J}}) |
No edit summary |
||
Line 520: | Line 520: | ||
bpb \ bpm \ |
bpb \ bpm \ |
||
</pre> |
</pre> |
||
=={{header|Java}}== |
|||
<lang java> |
|||
class Metronome{ |
|||
double bpm; |
|||
int measure, counter; |
|||
public Metronome(double bpm, int measure){ |
|||
this.bpm = bpm; |
|||
this.measure = measure; |
|||
} |
|||
public void start(){ |
|||
while(true){ |
|||
try { |
|||
Thread.sleep((long)(1000*(60/bpm))); |
|||
}catch(InterruptedException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
counter++; |
|||
if (counter%measure==0){ |
|||
System.out.println("TICK"); |
|||
}else{ |
|||
System.out.println("TOCK"); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
public class test { |
|||
public static void main(String[] args) { |
|||
Metronome metronome1 = new Metronome(240,3); |
|||
metronome1.start(); |
|||
} |
|||
} |
|||
</lang> |
|||
=={{header|Liberty BASIC}}== |
=={{header|Liberty BASIC}}== |
||
Requires two supplied wav files for accentuated & standard sounds. |
Requires two supplied wav files for accentuated & standard sounds. |