Digitized Sound
Volume Number: 6
Issue Number: 5
Column Tag: Basic School
Related Info: Sound Manager
Playing Digitized Sound
in QuickBasic
By Robert Spencer, East Lyme, CT
Digitized Sound in QuickBasic
While Microsoft QuickBasic is my favorite language for getting things done
quickly, it doesn’t have the power to produce applications as rich in Mac features as
Pascal or C. Fortunately, Microsoft gives us the ability to add to the language with
“pure code resources”, or MBPC’s, which can be added to QuickBasic itself and/or
applications it creates. MBPC’s themselves must be written in Pascal or C, and
compiled with the glue routines that QuickBasic needs. Once added to the resource fork
of QuickBasic, an MBPC simply adds a new statement to the language. When this
statement is encountered, control is passed to the compiled code. From my point of
view this is a great way to work -- I get the quick turnaround time and comforting
environment of an interpreter (it takes care of the user interface, memory
management, printing, MultiFinder, DA’s, etc.), but when necessary for speed or
language extension, I can write simple, short compiled routines.
In this article I use MBPC’s to demonstrate one of the things that you can’t do
directly in QuickBasic: play digitized sound -- not just MacinTalk-like speech, but the
high-quality music and voices that add so much pizzazz to HyperCard and games.
The QuickBasic manual and disks give examples for code resource writing with
MPW Pascal, MPW C, and Lightspeed C. As Murphy’s Law would have it, my second
language is THINK Pascal -- but fortunately the MPW Pascal glue routines supplied by
Microsoft work without modification in THINK Pascal 2.0. The two MBPC resources
shown below are SetSoundVol, which allows you to set the speaker volume from within
QuickBasic, and PlaySound, which lets you play any digitized ‘snd ‘ resource (note the
trailing space in ‘snd ‘). These new commands can be used in either interpreted or
compiled Microsoft QuickBasic 1.0.