PERCOBAAN 8

MEMBUAT APLIKASI SUARA PIANO

 

1.     Tujuan.        Agar Bamasis mampu membuat aplikasi suara Aplikasi Piano menggunakan tool sndplaysound.

2.       Alat dan Bahan.

          a.       Laptop;

          b.       Aplikasi Delphi;

c.        Tool Button;

d.       Tool Edit;

e.       SndPlaySound; dan

e.       Shape.

3.       Dasar Teori.


a.    Tool Button digunakan untuk membuat tombol (button) di antarmuka pengguna. TButton memungkinkan pengguna untuk memicu suatu aksi atau perintah ketika tombol tersebut diklik. Tombol sangat berguna dalam aplikasi Delphi untuk menjalankan berbagai macam perintah.





 

b.       Tool Edit Dalam Delphi 8, fungsi t edit biasanya merujuk pada komponen TEdit, yang digunakan untuk membuat kontrol input teks di antarmuka pengguna. Komponen ini memungkinkan pengguna untuk mengetikkan teks atau memodifikasi teks yang sudah ada.



  

c.        SndPlaySound pada Aplikasi Delphi adalah bagian dari Library MMSystem yang digunakan untuk memutar file suara atau nada tertentu dalam format wave (.wav) di aplikasi Delphi. Fungsi ini memungkinkan untuk memutarkan efek suara atau nada secara sederhana tanpa perlu melibatkan manipulasi lebih lanjut terhadap aliran suara.

 

Berikut adalah contoh coding dari fungsi SndPlaySound:

 

SndPlaySound(lpszSound: PChar; fuSound: UINT): BOOL; stdcall;

      

d.       Tool Shape dalam Delphi adalah komponen grafis yang digunakan untuk menggambar bentuk-bentuk geometris pada aplikasi yang sedang dikembangkan. Komponen ini memungkinkan pengguna untuk menampilkan berbagai bentuk seperti persegi, lingkaran, dan segitiga, serta mengatur warna dan ukuran sesuai kebutuhan desain aplikasi.



 4.       Langkah-langkah Percobaan.

 

a.               Flowchart.

 



b.       Coding

 

unit Unit3;

 

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;

 

type

  TForm3 = class(TForm)

    Button1: TButton;

    Button2: TButton;

    Button3: TButton;

    Button4: TButton;

    Button5: TButton;

    Button6: TButton;

    Button7: TButton;

    Button8: TButton;

    Button9: TButton;

    Button10: TButton;

    Button11: TButton;

    Button12: TButton;

    Button13: TButton;

    Button14: TButton;

    Label1: TLabel;

    Label2: TLabel;

    Shape1: TShape;

    Shape2: TShape;

    Shape3: TShape;

    Shape4: TShape;

    Shape5: TShape;

    Shape6: TShape;

    Shape7: TShape;

    Shape8: TShape;

    Shape9: TShape;

    Shape10: TShape;

    Shape11: TShape;

    Shape12: TShape;

    Shape13: TShape;

    Shape14: TShape;

    Shape16: TShape;

    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);

  private

    { Private declarations }

  public

    { Public declarations }

  end;

 

var

  Form3: TForm3;

 

implementation

 

{$R *.dfm}

 

procedure TForm3.Button10Click(Sender: TObject);

begin

sndPlaysound('D:\YOSSY\SEMESTER 3\BAHASA PEMROGRAMAN\DIRDIKBINJAR\YOSSY\PERCOBAAN 8\NADA 2\10.wav',SND_NODEFAULT OR SND_ASYNC);

shape1.Visible:=false;

shape2.Visible:=false;

shape3.Visible:=false;

shape4.Visible:=false;

shape5.Visible:=false;

shape6.Visible:=false;

shape7.Visible:=false;

shape8.Visible:=false;

shape9.Visible:=false;

shape10.Visible:=true;

shape11.Visible:=false;

shape12.Visible:=false;

shape13.Visible:=false;

shape14.Visible:=false;

end;

 

procedure TForm3.Button11Click(Sender: TObject);

begin

sndPlaysound('D:\YOSSY\SEMESTER 3\BAHASA PEMROGRAMAN\DIRDIKBINJAR\YOSSY\PERCOBAAN 8\NADA 2\11.wav',SND_NODEFAULT OR SND_ASYNC);

shape1.Visible:=false;

shape2.Visible:=false;

shape3.Visible:=false;

shape4.Visible:=false;

shape5.Visible:=false;

shape6.Visible:=false;

shape7.Visible:=false;

shape8.Visible:=false;

shape9.Visible:=false;

shape10.Visible:=false;

shape11.Visible:=true;

shape12.Visible:=false;

shape13.Visible:=false;

shape14.Visible:=false;

end;

 

procedure TForm3.Button12Click(Sender: TObject);

begin

sndPlaysound('D:\YOSSY\SEMESTER 3\BAHASA PEMROGRAMAN\DIRDIKBINJAR\YOSSY\PERCOBAAN 8\NADA 2\12.wav',SND_NODEFAULT OR SND_ASYNC);

shape1.Visible:=false;

shape2.Visible:=false;

shape3.Visible:=false;

shape4.Visible:=false;

shape5.Visible:=false;

shape6.Visible:=false;

shape7.Visible:=false;

shape8.Visible:=false;

shape9.Visible:=false;

shape10.Visible:=false;

shape11.Visible:=false;

shape12.Visible:=true;

shape13.Visible:=false;

shape14.Visible:=false;

end;

 

procedure TForm3.Button13Click(Sender: TObject);

begin

sndPlaysound('D:\YOSSY\SEMESTER 3\BAHASA PEMROGRAMAN\DIRDIKBINJAR\YOSSY\PERCOBAAN 8\NADA 2\13.wav',SND_NODEFAULT OR SND_ASYNC);

shape1.Visible:=false;

shape2.Visible:=false;

shape3.Visible:=false;

shape4.Visible:=false;

shape5.Visible:=false;

shape6.Visible:=false;

shape7.Visible:=false;

shape8.Visible:=false;

shape9.Visible:=false;

shape10.Visible:=false;

shape11.Visible:=false;

shape12.Visible:=false;

shape13.Visible:=true;

shape14.Visible:=false;

end;

 

procedure TForm3.Button14Click(Sender: TObject);

begin

sndPlaysound('D:\YOSSY\SEMESTER 3\BAHASA PEMROGRAMAN\DIRDIKBINJAR\YOSSY\PERCOBAAN 8\NADA 2\14.wav',SND_NODEFAULT OR SND_ASYNC);

shape1.Visible:=false;

shape2.Visible:=false;

shape3.Visible:=false;

shape4.Visible:=false;

shape5.Visible:=false;

shape6.Visible:=false;

shape7.Visible:=false;

shape8.Visible:=false;

shape9.Visible:=false;

shape10.Visible:=false;

shape11.Visible:=false;

shape12.Visible:=false;

shape13.Visible:=false;

shape14.Visible:=true;

end;

 

procedure TForm3.Button1Click(Sender: TObject);

begin

sndPlaysound('D:\YOSSY\SEMESTER 3\BAHASA PEMROGRAMAN\DIRDIKBINJAR\YOSSY\PERCOBAAN 8\NADA 2\1.wav',SND_NODEFAULT OR SND_ASYNC);

shape1.Visible:=true;

shape2.Visible:=false;

shape3.Visible:=false;

shape4.Visible:=false;

shape5.Visible:=false;

shape6.Visible:=false;

shape7.Visible:=false;

shape8.Visible:=false;

shape9.Visible:=false;

shape10.Visible:=false;

shape11.Visible:=false;

shape12.Visible:=false;

shape13.Visible:=false;

shape14.Visible:=false;

end;

 

procedure TForm3.Button2Click(Sender: TObject);

begin

sndPlaysound('D:\YOSSY\SEMESTER 3\BAHASA PEMROGRAMAN\DIRDIKBINJAR\YOSSY\PERCOBAAN 8\NADA 2\2.wav',SND_NODEFAULT OR SND_ASYNC);

shape1.Visible:=false;

shape2.Visible:=true;

shape3.Visible:=false;

shape4.Visible:=false;

shape5.Visible:=false;

shape6.Visible:=false;

shape7.Visible:=false;

shape8.Visible:=false;

shape9.Visible:=false;

shape10.Visible:=false;

shape11.Visible:=false;

shape12.Visible:=false;

shape13.Visible:=false;

shape14.Visible:=false;

end;

 

procedure TForm3.Button3Click(Sender: TObject);

begin

sndPlaysound('D:\YOSSY\SEMESTER 3\BAHASA PEMROGRAMAN\DIRDIKBINJAR\YOSSY\PERCOBAAN 8\NADA 2\3.wav',SND_NODEFAULT OR SND_ASYNC);

shape1.Visible:=false;

shape2.Visible:=false;

shape3.Visible:=true;

shape4.Visible:=false;

shape5.Visible:=false;

shape6.Visible:=false;

shape7.Visible:=false;

shape8.Visible:=false;

shape9.Visible:=false;

shape10.Visible:=false;

shape11.Visible:=false;

shape12.Visible:=false;

shape13.Visible:=false;

shape14.Visible:=false;

end;

 

procedure TForm3.Button4Click(Sender: TObject);

begin

sndPlaysound('D:\YOSSY\SEMESTER 3\BAHASA PEMROGRAMAN\DIRDIKBINJAR\YOSSY\PERCOBAAN 8\NADA 2\4.wav',SND_NODEFAULT OR SND_ASYNC);

shape1.Visible:=false;

shape2.Visible:=false;

shape3.Visible:=false;

shape4.Visible:=true;

shape5.Visible:=false;

shape6.Visible:=false;

shape7.Visible:=false;

shape8.Visible:=false;

shape9.Visible:=false;

shape10.Visible:=false;

shape11.Visible:=false;

shape12.Visible:=false;

shape13.Visible:=false;

shape14.Visible:=false;

end;

 

procedure TForm3.Button5Click(Sender: TObject);

begin

sndPlaysound('D:\YOSSY\SEMESTER 3\BAHASA PEMROGRAMAN\DIRDIKBINJAR\YOSSY\PERCOBAAN 8\NADA 2\5.wav',SND_NODEFAULT OR SND_ASYNC);

shape1.Visible:=false;

shape2.Visible:=false;

shape3.Visible:=false;

shape4.Visible:=false;

shape5.Visible:=true;

shape6.Visible:=false;

shape7.Visible:=false;

shape8.Visible:=false;

shape9.Visible:=false;

shape10.Visible:=false;

shape11.Visible:=false;

shape12.Visible:=false;

shape13.Visible:=false;

shape14.Visible:=false;

end;

 

procedure TForm3.Button6Click(Sender: TObject);

begin

sndPlaysound('D:\YOSSY\SEMESTER 3\BAHASA PEMROGRAMAN\DIRDIKBINJAR\YOSSY\PERCOBAAN 8\NADA 2\6.wav',SND_NODEFAULT OR SND_ASYNC);

shape1.Visible:=false;

shape2.Visible:=false;

shape3.Visible:=false;

shape4.Visible:=false;

shape5.Visible:=false;

shape6.Visible:=true;

shape7.Visible:=false;

shape8.Visible:=false;

shape9.Visible:=false;

shape10.Visible:=false;

shape11.Visible:=false;

shape12.Visible:=false;

shape13.Visible:=false;

shape14.Visible:=false;

end;

 

procedure TForm3.Button7Click(Sender: TObject);

begin

sndPlaysound('D:\YOSSY\SEMESTER 3\BAHASA PEMROGRAMAN\DIRDIKBINJAR\YOSSY\PERCOBAAN 8\NADA 2\7.wav',SND_NODEFAULT OR SND_ASYNC);

shape1.Visible:=false;

shape2.Visible:=false;

shape3.Visible:=false;

shape4.Visible:=false;

shape5.Visible:=false;

shape6.Visible:=false;

shape7.Visible:=true;

shape8.Visible:=false;

shape9.Visible:=false;

shape10.Visible:=false;

shape11.Visible:=false;

shape12.Visible:=false;

shape13.Visible:=false;

shape14.Visible:=false;

end;

 

procedure TForm3.Button8Click(Sender: TObject);

begin

sndPlaysound('D:\YOSSY\SEMESTER 3\BAHASA PEMROGRAMAN\DIRDIKBINJAR\YOSSY\PERCOBAAN 8\NADA 2\8.wav',SND_NODEFAULT OR SND_ASYNC);

shape1.Visible:=false;

shape2.Visible:=false;

shape3.Visible:=false;

shape4.Visible:=false;

shape5.Visible:=false;

shape6.Visible:=false;

shape7.Visible:=false;

shape8.Visible:=true;

shape9.Visible:=false;

shape10.Visible:=false;

shape11.Visible:=false;

shape12.Visible:=false;

shape13.Visible:=false;

shape14.Visible:=false;

end;

 

procedure TForm3.Button9Click(Sender: TObject);

begin

sndPlaysound('D:\YOSSY\SEMESTER 3\BAHASA PEMROGRAMAN\DIRDIKBINJAR\YOSSY\PERCOBAAN 8\NADA 2\9.wav',SND_NODEFAULT OR SND_ASYNC);

shape1.Visible:=false;

shape2.Visible:=false;

shape3.Visible:=false;

shape4.Visible:=false;

shape5.Visible:=false;

shape6.Visible:=false;

shape7.Visible:=false;

shape8.Visible:=false;

shape9.Visible:=true;

shape10.Visible:=false;

shape11.Visible:=false;

shape12.Visible:=false;

shape13.Visible:=false;

shape14.Visible:=false;

end;

 

end.

5.       Hasil dan Pembahasan.

 

a.       Hasil Video.

 




b.       Pembahasan.

 

Pada percobaan Delphi kali ini, kita memanfaatkan untuk membuat simulasi piano. Tool yang digunakan dalam percobaan kali ini adalah Button, Label, Shape dan sndplaysound. Percobaan kali ini menggabungkan sistem kerja antara berbagai tool sehingga menghasilkan aplikasi simulator yang dapat digunakan untuk mengeluarkan suara notasi piano.

Sistem kerja aplikasi ini, pada saat form dirun maka akan muncul tampilan piano. Apabila kita menekan button 1 atau Do atau tombol lain secara bergantian, maka akan keluar suara dari piano tersebut. Kemudian pada percobaan ini juga terdapat tool baru itu sndplaySound. Fitur ini digunakan untuk penginputan sound yang berjenis file .wav.

                 

6.       Kesimpulan.           Percobaan kali ini sangat bermanfaat untuk siapapun yang membutuhkan simulator piano.