TempoControl.pas
2.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
{ UNIT TempoControl.pas
--------------------------------- TempoControl -----------------------------
MidiPlayer2 test program
Copyright 2011 Silhwan Hyun, All Rights Reserved
This unit is free. It may be used both in commercial and non-commercial software either in
original or in modified form.
This unit can be freely distributed in any way and by any means provided this copyright
notice is preserved.
Author : Silhwan Hyun (e-mail addr : hyunsh@hanafos.com)
Author's comment : Please let me know if you have any idea to improve or to debug this unit.
Revision History
Ver 0.9.0 May 28 2012
- Initial release
----------------------------------------------------------------------------}
unit TempoControl;
{$DEFINE MULTI_LANGUAGE}
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, {$IFDEF MULTI_LANGUAGE}gnugettext,{$ENDIF} ComCtrls;
type
TTempoControlForm = class(TForm)
tbTempo: TTrackBar;
tbPitch: TTrackBar;
Tempo: TLabel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
btnClose: TButton;
edTempo: TEdit;
edPitch: TEdit;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
btnReset: TButton;
procedure FormShow(Sender: TObject);
procedure tbTempoChange(Sender: TObject);
procedure tbPitchChange(Sender: TObject);
procedure btnCloseClick(Sender: TObject);
procedure btnResetClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
TempoControlForm: TTempoControlForm;
implementation
{$R *.dfm}
uses MIDITest;
procedure TTempoControlForm.btnCloseClick(Sender: TObject);
begin
Close;
end;
procedure TTempoControlForm.FormCreate(Sender: TObject);
begin
{$IFDEF MULTI_LANGUAGE}
TranslateComponent(self);
{$ENDIF}
end;
procedure TTempoControlForm.FormShow(Sender: TObject);
begin
tbTempo.Position := 250 - round(MainForm.MidiPlayer.Speed * 100.0);
tbPitch.Position := 0 - MainForm.MidiPlayer.Pitch;
edTempo.Text := intToStr(250 - tbTempo.Position) + '%';
if tbPitch.Position < 0 then
edPitch.Text := '+' + intToStr(0 - tbPitch.Position)
else
edPitch.Text := intToStr(0 - tbPitch.Position);
end;
procedure TTempoControlForm.tbPitchChange(Sender: TObject);
begin
MainForm.MidiPlayer.Pitch := 0 - tbPitch.Position;
if tbPitch.Position < 0 then
edPitch.Text := '+' + intToStr(0 - tbPitch.Position)
else
edPitch.Text := intToStr(0 - tbPitch.Position);
end;
procedure TTempoControlForm.tbTempoChange(Sender: TObject);
begin
MainForm.MidiPlayer.Speed := (250 - tbTempo.Position) / 100.0;
edTempo.Text := intToStr(250 - tbTempo.Position) + '%';
end;
procedure TTempoControlForm.btnResetClick(Sender: TObject);
begin
tbTempo.Position := 150; // ** MainForm.MidiPlayer.Speed <= (250 - tbTempo.Position) / 100.0;
tbPitch.Position := 0;
end;
end.