Информационный сервер для программистов: Исходники со всего света. Паскальные исходники со всего света
  Powered by Поисковый сервер Яndex: Найдется ВСЁ!
На Главную Исходники Форум Информер Страны мира
   Звуки и Музыка    >>    tone
   
 
 Tone - Sound Module for PC Speaker   Richard R. Sands 29.05.91

Простой модуль для генерации тонов на спикере. Написан на встроенном АСМе, предназначен для замены стандартных процедур Sound, NoSound, Delay.
Simple tone playing module for PC Speaker. Replaces standard sound/nosound procedures. Written in BASM.



1k 
 

{> Cut here. FileName= TONETEST.PAS } Program ToneTest; USES Tone; begin ErrorBeep; Delay(500); AttentionBeep; Delay(500); BoundsBeep; Delay(500); Beep(440, 250); end. {> Cut here. FileName= TONE.PAS } UNIT Tone; {$S-,R-,D-,L-} (* TONE.PAS - Sound Module for Turbo Pascal 6.0 - Turbo Vision * Written by Richard R. Sands * Compuserve ID 70274,103 * January 1991 * * NOTE: Do Not Overlay *) INTERFACE Procedure Sound(Hz:Word); Procedure NoSound; Procedure Delay(MS : Word); Procedure Beep(Hz, MS:Word); { Same as Sound(Hz); Delay(MS); NoSound; ...but with more efficient code. } Procedure BoundsBeep; { Used for signalling a boundry or invalid command } Procedure ErrorBeep; { Used for signalling an error condition } Procedure AttentionBeep; { Used for signalling the user } IMPLEMENTATION VAR OneMS : Word; { ------------------------------------------------------------- } Procedure Beep(Hz, MS:Word); assembler; { Make the Sound at Frequency Hz for MS milliseconds } ASM MOV BX,Hz MOV AX,34DDH MOV DX,0012H CMP DX,BX JNC @Stop DIV BX MOV BX,AX IN AL,61H TEST AL,3 JNZ @99 OR AL,3 OUT 61H,AL MOV AL,0B6H OUT 43H,AL @99: MOV AL,BL OUT 42H,AL MOV AL,BH OUT 42H,AL @Stop: {$IFOPT G+} PUSH MS {$ELSE } MOV AX, MS { push delay time } PUSH AX {$ENDIF } CALL Delay { and wait... } IN AL, $61 { Now turn off the speaker } AND AL, $FC OUT $61, AL end; { ------------------------------------------------------------- } Procedure BoundsBeep; assembler; asm {$IFOPT G+ } PUSH 1234 { Pa