PERCOBAAN 8
PIANO
1. Tujuan : Agar Bintara Mahasiswa mampu membuat program piano menggunakan Delphi.
2. Alat dan Bahan.
a. Laptop.b. Delphi.
c. Image.
d. Shape.
e. Label.
3. Landasan Teori.
a. Image pada Delphi, komponen Image digunakan untuk menampilkan gambar atau foto dalam aplikasi. Komponen Image dapat digunakan untuk menampilkan gambar statis atau dinamis dalam aplikasi Delphi. Komponen ini berguna untuk menambahkan visualisasi pada aplikasi, seperti menampilkan logo, gambar, atau foto.
b. Shape pada Delphi, komponen Shape digunakan untuk membuat berbagai bentuk grafis seperti lingkaran, elips, bujur sangkar dan bentuk lainnya.
c. Label pada Delphi, komponen visual yang digunakan untuk menampilkan teks pada aplikasi.
d. Tampilan Running LED dengan menggunakan Shape pada Delphi, merupakan hasil visualiasi dari pergerakan Shape, sehingga membuat seakan-akan bergerak.
4. Langkah-Langkah Percobaan.
a . Membuat Flowchart.
b. Membuat Coding.
unit Unit2;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls,MMSystem,
Vcl.Imaging.pngimage;
type
TForm2 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
Button8: TButton;
Shape1: TShape;
Shape2: TShape;
Shape3: TShape;
Shape4: TShape;
Shape5: TShape;
Shape6: TShape;
Shape7: TShape;
Shape8: TShape;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Image1: TImage;
Shape9: TShape;
Shape10: TShape;
Shape11: TShape;
Shape12: TShape;
Shape13: TShape;
Shape14: TShape;
Shape15: TShape;
Button9: TButton;
Button10: TButton;
Button11: TButton;
Button12: TButton;
Button13: TButton;
Button14: TButton;
Button15: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
procedure Button10Click(Sender: TObject);
procedure Button11Click(Sender: TObject);
procedure Button12Click(Sender: TObject);
procedure Button13Click(Sender: TObject);
procedure Button14Click(Sender: TObject);
procedure Button15Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.Button10Click(Sender: TObject);
begin
sndPlaySound('D:\KOM8\PERCOBAAN8\NADA\10.wav', SND_ASYNC);
SHAPE1.Brush.Color:= clwhite;
SHAPE2.Brush.Color:= clwhite;
SHAPE3.Brush.Color:= clwhite;
SHAPE4.Brush.Color:= clwhite;
SHAPE5.Brush.Color:= clwhite;
SHAPE6.Brush.Color:= clwhite;
SHAPE7.Brush.Color:= clwhite;
SHAPE8.Brush.Color:= clwhite;
SHAPE9.Brush.Color:= clwhite;
SHAPE10.Brush.Color:= clpurple;
SHAPE11.Brush.Color:= clwhite;
SHAPE12.Brush.Color:= clwhite;
SHAPE13.Brush.Color:= clwhite;
SHAPE14.Brush.Color:= clwhite;
SHAPE15.Brush.Color:= clwhite;
end;
procedure TForm2.Button11Click(Sender: TObject);
begin
sndPlaySound('D:\KOM8\PERCOBAAN8\NADA\11.wav', SND_ASYNC);
SHAPE1.Brush.Color:= clwhite;
SHAPE2.Brush.Color:= clwhite;
SHAPE3.Brush.Color:= clwhite;
SHAPE4.Brush.Color:= clwhite;
SHAPE5.Brush.Color:= clwhite;
SHAPE6.Brush.Color:= clwhite;
SHAPE7.Brush.Color:= clwhite;
SHAPE8.Brush.Color:= clwhite;
SHAPE9.Brush.Color:= clwhite;
SHAPE10.Brush.Color:= clwhite;
SHAPE11.Brush.Color:= clpurple;
SHAPE12.Brush.Color:= clwhite;
SHAPE13.Brush.Color:= clwhite;
SHAPE14.Brush.Color:= clwhite;
SHAPE15.Brush.Color:= clwhite;
end;
procedure TForm2.Button12Click(Sender: TObject);
begin
sndPlaySound('D:\KOM8\PERCOBAAN8\NADA\12.wav', SND_ASYNC);
SHAPE1.Brush.Color:= clwhite;
SHAPE2.Brush.Color:= clwhite;
SHAPE3.Brush.Color:= clwhite;
SHAPE4.Brush.Color:= clwhite;
SHAPE5.Brush.Color:= clwhite;
SHAPE6.Brush.Color:= clwhite;
SHAPE7.Brush.Color:= clwhite;
SHAPE8.Brush.Color:= clwhite;
SHAPE9.Brush.Color:= clwhite;
SHAPE10.Brush.Color:= clwhite;
SHAPE11.Brush.Color:= clwhite;
SHAPE12.Brush.Color:= clpurple;
SHAPE13.Brush.Color:= clwhite;
SHAPE14.Brush.Color:= clwhite;
SHAPE15.Brush.Color:= clwhite;
end;
procedure TForm2.Button13Click(Sender: TObject);
begin
sndPlaySound('D:\KOM8\PERCOBAAN8\NADA\13.wav', SND_ASYNC);
SHAPE1.Brush.Color:= clwhite;
SHAPE2.Brush.Color:= clwhite;
SHAPE3.Brush.Color:= clwhite;
SHAPE4.Brush.Color:= clwhite;
SHAPE5.Brush.Color:= clwhite;
SHAPE6.Brush.Color:= clwhite;
SHAPE7.Brush.Color:= clwhite;
SHAPE8.Brush.Color:= clwhite;
SHAPE9.Brush.Color:= clwhite;
SHAPE10.Brush.Color:= clwhite;
SHAPE11.Brush.Color:= clwhite;
SHAPE12.Brush.Color:= clwhite;
SHAPE13.Brush.Color:= clpurple;
SHAPE14.Brush.Color:= clwhite;
SHAPE15.Brush.Color:= clwhite;
end;
procedure TForm2.Button14Click(Sender: TObject);
begin
sndPlaySound('D:\KOM8\PERCOBAAN8\NADA\14.wav', SND_ASYNC);
SHAPE1.Brush.Color:= clwhite;
SHAPE2.Brush.Color:= clwhite;
SHAPE3.Brush.Color:= clwhite;
SHAPE4.Brush.Color:= clwhite;
SHAPE5.Brush.Color:= clwhite;
SHAPE6.Brush.Color:= clwhite;
SHAPE7.Brush.Color:= clwhite;
SHAPE8.Brush.Color:= clwhite;
SHAPE9.Brush.Color:= clwhite;
SHAPE10.Brush.Color:= clwhite;
SHAPE11.Brush.Color:= clwhite;
SHAPE12.Brush.Color:= clwhite;
SHAPE13.Brush.Color:= clwhite;
SHAPE14.Brush.Color:= clpurple;
SHAPE15.Brush.Color:= clwhite;
end;
procedure TForm2.Button15Click(Sender: TObject);
begin
sndPlaySound('D:\KOM8\PERCOBAAN8\NADA\8.wav', SND_ASYNC);
SHAPE1.Brush.Color:= clwhite;
SHAPE2.Brush.Color:= clwhite;
SHAPE3.Brush.Color:= clwhite;
SHAPE4.Brush.Color:= clwhite;
SHAPE5.Brush.Color:= clwhite;
SHAPE6.Brush.Color:= clwhite;
SHAPE7.Brush.Color:= clwhite;
SHAPE8.Brush.Color:= clwhite;
SHAPE9.Brush.Color:= clwhite;
SHAPE10.Brush.Color:= clwhite;
SHAPE11.Brush.Color:= clwhite;
SHAPE12.Brush.Color:= clwhite;
SHAPE13.Brush.Color:= clwhite;
SHAPE14.Brush.Color:= clwhite;
SHAPE15.Brush.Color:= clpurple;
end;
procedure TForm2.Button1Click(Sender: TObject);
begin
sndPlaySound('D:\KOM8\PERCOBAAN8\NADA\1.wav', SND_ASYNC);
SHAPE1.Brush.Color:= clpurple;
SHAPE2.Brush.Color:= clwhite;
SHAPE3.Brush.Color:= clwhite;
SHAPE4.Brush.Color:= clwhite;
SHAPE5.Brush.Color:= clwhite;
SHAPE6.Brush.Color:= clwhite;
SHAPE7.Brush.Color:= clwhite;
SHAPE8.Brush.Color:= clwhite;
SHAPE9.Brush.Color:= clwhite;
SHAPE10.Brush.Color:= clwhite;
SHAPE11.Brush.Color:= clwhite;
SHAPE12.Brush.Color:= clwhite;
SHAPE13.Brush.Color:= clwhite;
SHAPE14.Brush.Color:= clwhite;
SHAPE15.Brush.Color:= clwhite;
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
sndPlaySound('D:\KOM8\PERCOBAAN8\NADA\2.wav', SND_ASYNC);
SHAPE1.Brush.Color:= clwhite;
SHAPE2.Brush.Color:= clpurple;
SHAPE3.Brush.Color:= clwhite;
SHAPE4.Brush.Color:= clwhite;
SHAPE5.Brush.Color:= clwhite;
SHAPE6.Brush.Color:= clwhite;
SHAPE7.Brush.Color:= clwhite;
SHAPE8.Brush.Color:= clwhite;
SHAPE9.Brush.Color:= clwhite;
SHAPE10.Brush.Color:= clwhite;
SHAPE11.Brush.Color:= clwhite;
SHAPE12.Brush.Color:= clwhite;
SHAPE13.Brush.Color:= clwhite;
SHAPE14.Brush.Color:= clwhite;
SHAPE15.Brush.Color:= clwhite;
end;
procedure TForm2.Button3Click(Sender: TObject);
begin
sndPlaySound('D:\KOM8\PERCOBAAN8\NADA\3.wav', SND_ASYNC);
SHAPE1.Brush.Color:= clwhite;
SHAPE2.Brush.Color:= clwhite;
SHAPE3.Brush.Color:= clpurple;
SHAPE4.Brush.Color:= clwhite;
SHAPE5.Brush.Color:= clwhite;
SHAPE6.Brush.Color:= clwhite;
SHAPE7.Brush.Color:= clwhite;
SHAPE8.Brush.Color:= clwhite;
SHAPE9.Brush.Color:= clwhite;
SHAPE10.Brush.Color:= clwhite;
SHAPE11.Brush.Color:= clwhite;
SHAPE12.Brush.Color:= clwhite;
SHAPE13.Brush.Color:= clwhite;
SHAPE14.Brush.Color:= clwhite;
SHAPE15.Brush.Color:= clwhite;
end;
procedure TForm2.Button4Click(Sender: TObject);
begin
sndPlaySound('D:\KOM8\PERCOBAAN8\NADA\4.wav', SND_ASYNC);
SHAPE1.Brush.Color:= clwhite;
SHAPE2.Brush.Color:= clwhite;
SHAPE3.Brush.Color:= clwhite;
SHAPE4.Brush.Color:= clpurple;
SHAPE5.Brush.Color:= clwhite;
SHAPE6.Brush.Color:= clwhite;
SHAPE7.Brush.Color:= clwhite;
SHAPE8.Brush.Color:= clwhite;
SHAPE9.Brush.Color:= clwhite;
SHAPE10.Brush.Color:= clwhite;
SHAPE11.Brush.Color:= clwhite;
SHAPE12.Brush.Color:= clwhite;
SHAPE13.Brush.Color:= clwhite;
SHAPE14.Brush.Color:= clwhite;
SHAPE15.Brush.Color:= clwhite;
end;
procedure TForm2.Button5Click(Sender: TObject);
begin
sndPlaySound('D:\KOM8\PERCOBAAN8\NADA\5.wav', SND_ASYNC);
SHAPE1.Brush.Color:= clwhite;
SHAPE2.Brush.Color:= clwhite;
SHAPE3.Brush.Color:= clwhite;
SHAPE4.Brush.Color:= clwhite;
SHAPE5.Brush.Color:= clpurple;
SHAPE6.Brush.Color:= clwhite;
SHAPE7.Brush.Color:= clwhite;
SHAPE8.Brush.Color:= clwhite;
SHAPE9.Brush.Color:= clwhite;
SHAPE10.Brush.Color:= clwhite;
SHAPE11.Brush.Color:= clwhite;
SHAPE12.Brush.Color:= clwhite;
SHAPE13.Brush.Color:= clwhite;
SHAPE14.Brush.Color:= clwhite;
SHAPE15.Brush.Color:= clwhite;
end;
procedure TForm2.Button6Click(Sender: TObject);
begin
sndPlaySound('D:\KOM8\PERCOBAAN8\NADA\6.wav', SND_ASYNC);
SHAPE1.Brush.Color:= clwhite;
SHAPE2.Brush.Color:= clwhite;
SHAPE3.Brush.Color:= clwhite;
SHAPE4.Brush.Color:= clwhite;
SHAPE5.Brush.Color:= clwhite;
SHAPE6.Brush.Color:= clpurple;
SHAPE7.Brush.Color:= clwhite;
SHAPE8.Brush.Color:= clwhite;
SHAPE9.Brush.Color:= clwhite;
SHAPE10.Brush.Color:= clwhite;
SHAPE11.Brush.Color:= clwhite;
SHAPE12.Brush.Color:= clwhite;
SHAPE13.Brush.Color:= clwhite;
SHAPE14.Brush.Color:= clwhite;
SHAPE15.Brush.Color:= clwhite;
end;
procedure TForm2.Button7Click(Sender: TObject);
begin
sndPlaySound('D:\KOM8\PERCOBAAN8\NADA\7.wav', SND_ASYNC);
SHAPE1.Brush.Color:= clwhite;
SHAPE2.Brush.Color:= clwhite;
SHAPE3.Brush.Color:= clwhite;
SHAPE4.Brush.Color:= clwhite;
SHAPE5.Brush.Color:= clwhite;
SHAPE6.Brush.Color:= clwhite;
SHAPE7.Brush.Color:= clpurple;
SHAPE8.Brush.Color:= clwhite;
SHAPE9.Brush.Color:= clwhite;
SHAPE10.Brush.Color:= clwhite;
SHAPE11.Brush.Color:= clwhite;
SHAPE12.Brush.Color:= clwhite;
SHAPE13.Brush.Color:= clwhite;
SHAPE14.Brush.Color:= clwhite;
SHAPE15.Brush.Color:= clwhite;
end;
procedure TForm2.Button8Click(Sender: TObject);
begin
sndPlaySound('D:\KOM8\PERCOBAAN8\NADA\8.wav', SND_ASYNC);
SHAPE1.Brush.Color:= clwhite;
SHAPE2.Brush.Color:= clwhite;
SHAPE3.Brush.Color:= clwhite;
SHAPE4.Brush.Color:= clwhite;
SHAPE5.Brush.Color:= clwhite;
SHAPE6.Brush.Color:= clwhite;
SHAPE7.Brush.Color:= clwhite;
SHAPE8.Brush.Color:= clpurple;
SHAPE9.Brush.Color:= clwhite;
SHAPE10.Brush.Color:= clwhite;
SHAPE11.Brush.Color:= clwhite;
SHAPE12.Brush.Color:= clwhite;
SHAPE13.Brush.Color:= clwhite;
SHAPE14.Brush.Color:= clwhite;
SHAPE15.Brush.Color:= clwhite;
end;
procedure TForm2.Button9Click(Sender: TObject);
begin
sndPlaySound('D:\KOM8\PERCOBAAN8\NADA\9.wav', SND_ASYNC);
SHAPE1.Brush.Color:= clwhite;
SHAPE2.Brush.Color:= clwhite;
SHAPE3.Brush.Color:= clwhite;
SHAPE4.Brush.Color:= clwhite;
SHAPE5.Brush.Color:= clwhite;
SHAPE6.Brush.Color:= clwhite;
SHAPE7.Brush.Color:= clwhite;
SHAPE8.Brush.Color:= clwhite;
SHAPE9.Brush.Color:= clpurple;
SHAPE10.Brush.Color:= clwhite;
SHAPE11.Brush.Color:= clwhite;
SHAPE12.Brush.Color:= clwhite;
SHAPE13.Brush.Color:= clwhite;
SHAPE14.Brush.Color:= clwhite;
SHAPE15.Brush.Color:= clwhite;
end;
end.
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls,MMSystem,
Vcl.Imaging.pngimage;
type
TForm2 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
Button8: TButton;
Shape1: TShape;
Shape2: TShape;
Shape3: TShape;
Shape4: TShape;
Shape5: TShape;
Shape6: TShape;
Shape7: TShape;
Shape8: TShape;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Image1: TImage;
Shape9: TShape;
Shape10: TShape;
Shape11: TShape;
Shape12: TShape;
Shape13: TShape;
Shape14: TShape;
Shape15: TShape;
Button9: TButton;
Button10: TButton;
Button11: TButton;
Button12: TButton;
Button13: TButton;
Button14: TButton;
Button15: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
procedure Button10Click(Sender: TObject);
procedure Button11Click(Sender: TObject);
procedure Button12Click(Sender: TObject);
procedure Button13Click(Sender: TObject);
procedure Button14Click(Sender: TObject);
procedure Button15Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.Button10Click(Sender: TObject);
begin
sndPlaySound('D:\KOM8\PERCOBAAN8\NADA\10.wav', SND_ASYNC);
SHAPE1.Brush.Color:= clwhite;
SHAPE2.Brush.Color:= clwhite;
SHAPE3.Brush.Color:= clwhite;
SHAPE4.Brush.Color:= clwhite;
SHAPE5.Brush.Color:= clwhite;
SHAPE6.Brush.Color:= clwhite;
SHAPE7.Brush.Color:= clwhite;
SHAPE8.Brush.Color:= clwhite;
SHAPE9.Brush.Color:= clwhite;
SHAPE10.Brush.Color:= clpurple;
SHAPE11.Brush.Color:= clwhite;
SHAPE12.Brush.Color:= clwhite;
SHAPE13.Brush.Color:= clwhite;
SHAPE14.Brush.Color:= clwhite;
SHAPE15.Brush.Color:= clwhite;
end;
procedure TForm2.Button11Click(Sender: TObject);
begin
sndPlaySound('D:\KOM8\PERCOBAAN8\NADA\11.wav', SND_ASYNC);
SHAPE1.Brush.Color:= clwhite;
SHAPE2.Brush.Color:= clwhite;
SHAPE3.Brush.Color:= clwhite;
SHAPE4.Brush.Color:= clwhite;
SHAPE5.Brush.Color:= clwhite;
SHAPE6.Brush.Color:= clwhite;
SHAPE7.Brush.Color:= clwhite;
SHAPE8.Brush.Color:= clwhite;
SHAPE9.Brush.Color:= clwhite;
SHAPE10.Brush.Color:= clwhite;
SHAPE11.Brush.Color:= clpurple;
SHAPE12.Brush.Color:= clwhite;
SHAPE13.Brush.Color:= clwhite;
SHAPE14.Brush.Color:= clwhite;
SHAPE15.Brush.Color:= clwhite;
end;
procedure TForm2.Button12Click(Sender: TObject);
begin
sndPlaySound('D:\KOM8\PERCOBAAN8\NADA\12.wav', SND_ASYNC);
SHAPE1.Brush.Color:= clwhite;
SHAPE2.Brush.Color:= clwhite;
SHAPE3.Brush.Color:= clwhite;
SHAPE4.Brush.Color:= clwhite;
SHAPE5.Brush.Color:= clwhite;
SHAPE6.Brush.Color:= clwhite;
SHAPE7.Brush.Color:= clwhite;
SHAPE8.Brush.Color:= clwhite;
SHAPE9.Brush.Color:= clwhite;
SHAPE10.Brush.Color:= clwhite;
SHAPE11.Brush.Color:= clwhite;
SHAPE12.Brush.Color:= clpurple;
SHAPE13.Brush.Color:= clwhite;
SHAPE14.Brush.Color:= clwhite;
SHAPE15.Brush.Color:= clwhite;
end;
procedure TForm2.Button13Click(Sender: TObject);
begin
sndPlaySound('D:\KOM8\PERCOBAAN8\NADA\13.wav', SND_ASYNC);
SHAPE1.Brush.Color:= clwhite;
SHAPE2.Brush.Color:= clwhite;
SHAPE3.Brush.Color:= clwhite;
SHAPE4.Brush.Color:= clwhite;
SHAPE5.Brush.Color:= clwhite;
SHAPE6.Brush.Color:= clwhite;
SHAPE7.Brush.Color:= clwhite;
SHAPE8.Brush.Color:= clwhite;
SHAPE9.Brush.Color:= clwhite;
SHAPE10.Brush.Color:= clwhite;
SHAPE11.Brush.Color:= clwhite;
SHAPE12.Brush.Color:= clwhite;
SHAPE13.Brush.Color:= clpurple;
SHAPE14.Brush.Color:= clwhite;
SHAPE15.Brush.Color:= clwhite;
end;
procedure TForm2.Button14Click(Sender: TObject);
begin
sndPlaySound('D:\KOM8\PERCOBAAN8\NADA\14.wav', SND_ASYNC);
SHAPE1.Brush.Color:= clwhite;
SHAPE2.Brush.Color:= clwhite;
SHAPE3.Brush.Color:= clwhite;
SHAPE4.Brush.Color:= clwhite;
SHAPE5.Brush.Color:= clwhite;
SHAPE6.Brush.Color:= clwhite;
SHAPE7.Brush.Color:= clwhite;
SHAPE8.Brush.Color:= clwhite;
SHAPE9.Brush.Color:= clwhite;
SHAPE10.Brush.Color:= clwhite;
SHAPE11.Brush.Color:= clwhite;
SHAPE12.Brush.Color:= clwhite;
SHAPE13.Brush.Color:= clwhite;
SHAPE14.Brush.Color:= clpurple;
SHAPE15.Brush.Color:= clwhite;
end;
procedure TForm2.Button15Click(Sender: TObject);
begin
sndPlaySound('D:\KOM8\PERCOBAAN8\NADA\8.wav', SND_ASYNC);
SHAPE1.Brush.Color:= clwhite;
SHAPE2.Brush.Color:= clwhite;
SHAPE3.Brush.Color:= clwhite;
SHAPE4.Brush.Color:= clwhite;
SHAPE5.Brush.Color:= clwhite;
SHAPE6.Brush.Color:= clwhite;
SHAPE7.Brush.Color:= clwhite;
SHAPE8.Brush.Color:= clwhite;
SHAPE9.Brush.Color:= clwhite;
SHAPE10.Brush.Color:= clwhite;
SHAPE11.Brush.Color:= clwhite;
SHAPE12.Brush.Color:= clwhite;
SHAPE13.Brush.Color:= clwhite;
SHAPE14.Brush.Color:= clwhite;
SHAPE15.Brush.Color:= clpurple;
end;
procedure TForm2.Button1Click(Sender: TObject);
begin
sndPlaySound('D:\KOM8\PERCOBAAN8\NADA\1.wav', SND_ASYNC);
SHAPE1.Brush.Color:= clpurple;
SHAPE2.Brush.Color:= clwhite;
SHAPE3.Brush.Color:= clwhite;
SHAPE4.Brush.Color:= clwhite;
SHAPE5.Brush.Color:= clwhite;
SHAPE6.Brush.Color:= clwhite;
SHAPE7.Brush.Color:= clwhite;
SHAPE8.Brush.Color:= clwhite;
SHAPE9.Brush.Color:= clwhite;
SHAPE10.Brush.Color:= clwhite;
SHAPE11.Brush.Color:= clwhite;
SHAPE12.Brush.Color:= clwhite;
SHAPE13.Brush.Color:= clwhite;
SHAPE14.Brush.Color:= clwhite;
SHAPE15.Brush.Color:= clwhite;
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
sndPlaySound('D:\KOM8\PERCOBAAN8\NADA\2.wav', SND_ASYNC);
SHAPE1.Brush.Color:= clwhite;
SHAPE2.Brush.Color:= clpurple;
SHAPE3.Brush.Color:= clwhite;
SHAPE4.Brush.Color:= clwhite;
SHAPE5.Brush.Color:= clwhite;
SHAPE6.Brush.Color:= clwhite;
SHAPE7.Brush.Color:= clwhite;
SHAPE8.Brush.Color:= clwhite;
SHAPE9.Brush.Color:= clwhite;
SHAPE10.Brush.Color:= clwhite;
SHAPE11.Brush.Color:= clwhite;
SHAPE12.Brush.Color:= clwhite;
SHAPE13.Brush.Color:= clwhite;
SHAPE14.Brush.Color:= clwhite;
SHAPE15.Brush.Color:= clwhite;
end;
procedure TForm2.Button3Click(Sender: TObject);
begin
sndPlaySound('D:\KOM8\PERCOBAAN8\NADA\3.wav', SND_ASYNC);
SHAPE1.Brush.Color:= clwhite;
SHAPE2.Brush.Color:= clwhite;
SHAPE3.Brush.Color:= clpurple;
SHAPE4.Brush.Color:= clwhite;
SHAPE5.Brush.Color:= clwhite;
SHAPE6.Brush.Color:= clwhite;
SHAPE7.Brush.Color:= clwhite;
SHAPE8.Brush.Color:= clwhite;
SHAPE9.Brush.Color:= clwhite;
SHAPE10.Brush.Color:= clwhite;
SHAPE11.Brush.Color:= clwhite;
SHAPE12.Brush.Color:= clwhite;
SHAPE13.Brush.Color:= clwhite;
SHAPE14.Brush.Color:= clwhite;
SHAPE15.Brush.Color:= clwhite;
end;
procedure TForm2.Button4Click(Sender: TObject);
begin
sndPlaySound('D:\KOM8\PERCOBAAN8\NADA\4.wav', SND_ASYNC);
SHAPE1.Brush.Color:= clwhite;
SHAPE2.Brush.Color:= clwhite;
SHAPE3.Brush.Color:= clwhite;
SHAPE4.Brush.Color:= clpurple;
SHAPE5.Brush.Color:= clwhite;
SHAPE6.Brush.Color:= clwhite;
SHAPE7.Brush.Color:= clwhite;
SHAPE8.Brush.Color:= clwhite;
SHAPE9.Brush.Color:= clwhite;
SHAPE10.Brush.Color:= clwhite;
SHAPE11.Brush.Color:= clwhite;
SHAPE12.Brush.Color:= clwhite;
SHAPE13.Brush.Color:= clwhite;
SHAPE14.Brush.Color:= clwhite;
SHAPE15.Brush.Color:= clwhite;
end;
procedure TForm2.Button5Click(Sender: TObject);
begin
sndPlaySound('D:\KOM8\PERCOBAAN8\NADA\5.wav', SND_ASYNC);
SHAPE1.Brush.Color:= clwhite;
SHAPE2.Brush.Color:= clwhite;
SHAPE3.Brush.Color:= clwhite;
SHAPE4.Brush.Color:= clwhite;
SHAPE5.Brush.Color:= clpurple;
SHAPE6.Brush.Color:= clwhite;
SHAPE7.Brush.Color:= clwhite;
SHAPE8.Brush.Color:= clwhite;
SHAPE9.Brush.Color:= clwhite;
SHAPE10.Brush.Color:= clwhite;
SHAPE11.Brush.Color:= clwhite;
SHAPE12.Brush.Color:= clwhite;
SHAPE13.Brush.Color:= clwhite;
SHAPE14.Brush.Color:= clwhite;
SHAPE15.Brush.Color:= clwhite;
end;
procedure TForm2.Button6Click(Sender: TObject);
begin
sndPlaySound('D:\KOM8\PERCOBAAN8\NADA\6.wav', SND_ASYNC);
SHAPE1.Brush.Color:= clwhite;
SHAPE2.Brush.Color:= clwhite;
SHAPE3.Brush.Color:= clwhite;
SHAPE4.Brush.Color:= clwhite;
SHAPE5.Brush.Color:= clwhite;
SHAPE6.Brush.Color:= clpurple;
SHAPE7.Brush.Color:= clwhite;
SHAPE8.Brush.Color:= clwhite;
SHAPE9.Brush.Color:= clwhite;
SHAPE10.Brush.Color:= clwhite;
SHAPE11.Brush.Color:= clwhite;
SHAPE12.Brush.Color:= clwhite;
SHAPE13.Brush.Color:= clwhite;
SHAPE14.Brush.Color:= clwhite;
SHAPE15.Brush.Color:= clwhite;
end;
procedure TForm2.Button7Click(Sender: TObject);
begin
sndPlaySound('D:\KOM8\PERCOBAAN8\NADA\7.wav', SND_ASYNC);
SHAPE1.Brush.Color:= clwhite;
SHAPE2.Brush.Color:= clwhite;
SHAPE3.Brush.Color:= clwhite;
SHAPE4.Brush.Color:= clwhite;
SHAPE5.Brush.Color:= clwhite;
SHAPE6.Brush.Color:= clwhite;
SHAPE7.Brush.Color:= clpurple;
SHAPE8.Brush.Color:= clwhite;
SHAPE9.Brush.Color:= clwhite;
SHAPE10.Brush.Color:= clwhite;
SHAPE11.Brush.Color:= clwhite;
SHAPE12.Brush.Color:= clwhite;
SHAPE13.Brush.Color:= clwhite;
SHAPE14.Brush.Color:= clwhite;
SHAPE15.Brush.Color:= clwhite;
end;
procedure TForm2.Button8Click(Sender: TObject);
begin
sndPlaySound('D:\KOM8\PERCOBAAN8\NADA\8.wav', SND_ASYNC);
SHAPE1.Brush.Color:= clwhite;
SHAPE2.Brush.Color:= clwhite;
SHAPE3.Brush.Color:= clwhite;
SHAPE4.Brush.Color:= clwhite;
SHAPE5.Brush.Color:= clwhite;
SHAPE6.Brush.Color:= clwhite;
SHAPE7.Brush.Color:= clwhite;
SHAPE8.Brush.Color:= clpurple;
SHAPE9.Brush.Color:= clwhite;
SHAPE10.Brush.Color:= clwhite;
SHAPE11.Brush.Color:= clwhite;
SHAPE12.Brush.Color:= clwhite;
SHAPE13.Brush.Color:= clwhite;
SHAPE14.Brush.Color:= clwhite;
SHAPE15.Brush.Color:= clwhite;
end;
procedure TForm2.Button9Click(Sender: TObject);
begin
sndPlaySound('D:\KOM8\PERCOBAAN8\NADA\9.wav', SND_ASYNC);
SHAPE1.Brush.Color:= clwhite;
SHAPE2.Brush.Color:= clwhite;
SHAPE3.Brush.Color:= clwhite;
SHAPE4.Brush.Color:= clwhite;
SHAPE5.Brush.Color:= clwhite;
SHAPE6.Brush.Color:= clwhite;
SHAPE7.Brush.Color:= clwhite;
SHAPE8.Brush.Color:= clwhite;
SHAPE9.Brush.Color:= clpurple;
SHAPE10.Brush.Color:= clwhite;
SHAPE11.Brush.Color:= clwhite;
SHAPE12.Brush.Color:= clwhite;
SHAPE13.Brush.Color:= clwhite;
SHAPE14.Brush.Color:= clwhite;
SHAPE15.Brush.Color:= clwhite;
end;
end.
b. Pembahasan.
1). Dalam menjalankan program piano ini, kita membutuhkan button yang digunakan untuk membunyikan suara sesuai dengan tangga nada. terdapat 15 tangga nada berbeda di antaranya tangga nada Do, Re, Mi, Fa, Sol, La, Si dan seterusnya.
2). Terdapat juga shape untuk tampilan apabila button ditekan dan mengeluarkan suara. shape kan berwarna clpurple apabila ditekan dan mengeluarkan suara dan berwarna clwhite apabila tidak ditekan.
3). suara yang bisa dihasilkan apabila memasukkan funsi tool sndPlaySound (lokasi file) dan tidak lupa juga menambahkan uses MMsystem.
6. Kesimpulan.
Percobaan kali ini untuk menjalankan program piano dengan menggunakan Button sebagai note untuk mengghasilkan bunyi, terdapat tool fungsi yang digunakan juga untuk menginput file suara yang sudah ada.