BBS: Inland Empire Archive Date: 07-09-92 (21:38) Number: 85 From: STEVE HALKO Refer#: NONE To: PHIL HODGES Recvd: NO Subj: Sounds, sounds, sounds.. Conf: (2) Quik_Bas
PH>SOUND..since it's way to limiting. I want to be able to specify
PH>frequency, velocity (the rate of change), acceleration (the rate of the
PH>rate of change) and duration.
This might give you a start, Phil. It's what I use as a replacement
for the SOUND statement to keep the FP emulator out of my programs.
The arguments are frequency (in Hz), and duration (in clock ticks):
SUB Sounds (Freq, Length) STATIC
'Ports 42h, 43h, and 61h control timer and speaker
'
'Divide clock frequency by sound frequency
'to get number of "clicks" clock must produce
Clicks = 1193280 \ Freq
LoByte = Clicks AND &HFF
HiByte = Clicks \ 256
'Tell timer that data is coming
OUT &H43, 182
'Send count to timer
OUT &H42, LoByte
OUT &H42, HiByte
'Turn speaker on by setting bits 0 and 1 of PPI chip.
SpkrOn = INP(&H61) OR &H3
OUT &H61, SpkrOn
'Leave speaker on
StopTime& = ReadTimer& + Length
DO WHILE ReadTimer& < StopTime&
LOOP
'Turn speaker off.
SpkrOff = INP(&H61) AND &HFC
OUT &H61, SpkrOff
END SUB
FUNCTION ReadTimer& STATIC
'[]=============================================================[]
'[] Returns the number of clock ticks since midnight []
'[] without invoking FP emulator like TIMER does []
'[]=============================================================[]
DEF SEG = &H40
Lo& = PEEK(&H6C) + 256& * PEEK(&H6D)
Hi& = PEEK(&H6E) + 256& * PEEK(&H6F)
ReadTimer& = (65536 * Hi&) + Lo&
END FUNCTION
* SLMR 2.1a * If you don't eat your meat, you can't have any pudding!
--- DB B1073/002487
* Origin: Gulf Coast BBS -QuickSHARE #2- (904)563-2547 HST/V.32bis (1:365/12)

Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET