unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, MPlayer, ExtCtrls, Math;
type
TForm1 =
class(TForm)
Button1: TButton;
MediaPlayer1: TMediaPlayer;
Edit1: TEdit;
Panel1: TPanel;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
TimeBetweenTicks: Integer;
Abort: Boolean;
Freq, Start, Stop: Int64;
bpmTicks: Int64;
Frequency, TicksPerMinute: Int64;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
TempTicks, LastBeatTicks: Int64;
bpm: Integer;
begin
bpm := StrToInt(Edit1.Text);
QueryPerformanceCounter(LastBeatTicks);
MediaPlayer1.play;
// Am Anfang gleich den ersten Schlag abspielen
while Panel1.Caption='
ON'
do // solange wie das Metronom laufen soll..
begin
QueryPerformanceCounter(TempTicks);
if SameValue(LastBeatTicks - TempTicks, bpmTicks
div bpm, Frequency
div 10000)
then
begin
MediaPlayer1.Play;
LastBeatTicks := TempTicks;
end;
end;
end;
end.