Delphi Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
델파이 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
FreePascal/Lazarus
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
델마당
볼랜드포럼 광고 모집

델파이 Q&A
Delphi Programming Q&A
[2629] [정보] BAIKSK님의 스피커 제어 자료..
이정욱 [ ] 1250 읽음    1998-04-30 05:58
안녕하세요... 아이디 도둑 민성기 입니다.
자료실의 자료를 받아 보았더니... 2개의 워드 파일 모두
워드 메크로 바이러스에 감염되어 있었습니다.
조심하시구요... ^^;

BAIKSK님이 올리신 자료를 여기에 일반 텍스트로 다시 올리
겠습니당... (용서해 주시겠죠..?? ^^; )

// 사용법은 코드를 보시면 아실 겁니다.
// 참고로, 다른 파일에 Frequency별 음색을 요약해 두었습니다.

unit sound;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TSoundForm = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure PLAY_Manual_InitializedSignal;
    procedure PLAY_Auto_InitializedSignal;
    procedure PLAY_Fail;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  SoundForm: TSoundForm;

implementation

{$R *.DFM}

(*----------------------------------------------------------------*)
procedure SetPort(address, value: Word);
// 포트에 값을 집어넣기.
(*----------------------------------------------------------------*)
var
   bValue: Byte;
begin
   bValue := trunc(value and 255);
   asm
      mov DX, address
      mov AL, bValue
      out DX, AL
   end;
end;

(*----------------------------------------------------------------*)
function GetPort(address: Word): Word;
// 포트의 값을 얻어오기.
(*----------------------------------------------------------------*)
var
  bValue: Byte;
begin
  asm
    mov DX, address
    in  AL, DX
    mov bValue, AL
  end;
  result := bValue;
end;

(*----------------------------------------------------------------*)
procedure NoSound;
// 사운드 끄기.
(*----------------------------------------------------------------*)
var
  wValue: Word;
begin
  wValue := GetPort($61);
  wValue := wValue and $FC;
  SetPort($61, wValue);
end;

(*----------------------------------------------------------------*)
procedure Sound_on(Freq: Word);
// 사운드 켜기.
(*----------------------------------------------------------------*)
var
  B: Word;
begin
  if Freq > 18 then begin
    Freq := Word(1193181 div LongInt(Freq));
    B := GetPort($61);

    if (B and 3) = 0 then begin
      SetPort($61, B or 3);
      SetPort($43, $B6);
    end;

    SetPort($42, Freq);
    SetPort($42, (Freq SHR 8));
  end;
end;

(*----------------------------------------------------------------*)
procedure Delay(MSecs: Integer);
// 주어진 시간만큼 멈추기.
(*----------------------------------------------------------------*)
var
   FirstTickCount : LongInt;
begin
   FirstTickCount:=GetTickCount;
   repeat
      Application.ProcessMessages;
   until ((GetTickCount-FirstTickCount) >= LongInt(MSecs));
end;

(*----------------------------------------------------------------*)
procedure Play(Freq: Word; MSecs: Integer);
(*----------------------------------------------------------------*)
begin
   Sound_on(Freq);
   Delay(MSecs);
   NoSound;
end;

(*----------------------------------------------------------------*)
procedure TSoundForm.Button1Click(Sender: TObject);
(*----------------------------------------------------------------*)
var
  I: Integer;
begin
  for I := 1 to 6 do begin
    if I Mod 2 = 0 then
      Play(90, 150)
    else
      Play(10, 150);
//    Delay(30);
  end;
end;

procedure TSoundForm.PLAY_Manual_InitializedSignal;   //수정해서 쓰세요
(*----------------------------------------------------------------*)
var
  I: Integer;
begin
      Play(523, 150);
      Play(659, 150);
      Play(784, 150);
end;

procedure TSoundForm.PLAY_Fail;                    //수정해서 쓰세요
(*----------------------------------------------------------------*)
var
  I: Integer;
begin
      Play(100, 150);
      Play(80, 150);
      Play(50, 150);
      Play(20, 150);
      Play(1, 150);
end;

procedure TSoundForm.PLAY_Auto_InitializedSignal;     // 수정해서 쓰세요
(*----------------------------------------------------------------*)
var
  I: Integer;
begin
      Play(523, 150);
end;

end.






/**********************************************************/
/*****************      sound label      ******************/
/**********************************************************/


// Sound.pas 파일에서는 아래 음계 중 숫자만 갖다 쓰시면 됩니다.

#define C0    261       //도   --> 저음계
#define D0    293       //레
#define E0_b  311       //미 b
#define E0    329       //미
#define F0    349       //파
#define G0    392       //솔
#define A0    440       //라
#define B0_b  466       //시
#define C1    523       //도   --> 여기서부터가 기본음계
#define D1    587
#define E1_b  622
#define E1    659
#define F     698
#define G     784
#define A1_b  830
#define A     880
#define B1_b  933
#define B     988
#define C2    1046     // 도  --> 고음계
#define D2    1174
#define E2_b  1244
#define E2    1318
#define F2    1396
#define G2_b  1479
#define G2    1567
#define A2_b  1661
#define A2    1760
#define B2_b  1864
#define B2    1975
#define C3    2098     // 도   --> 듣기 거북할걸요...
#define D3_b  2217
#define D3    2349
#define E3    2637
#define F3    2793





+ -

관련 글 리스트
2629 [정보] BAIKSK님의 스피커 제어 자료.. 이정욱 1250 1998/04/30
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.