Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!spool.mu.edu!cs.umn.edu!talon.UCS.ORST.EDU!orstcs!jacobs.CS.ORST.EDU!parkern From: parkern@jacobs.CS.ORST.EDU (Neil Parker) Newsgroups: comp.sys.apple2 Subject: Re: What's wrong with this Pascal program? Message-ID: <1991May25.100117.26892@lynx.CS.ORST.EDU> Date: 25 May 91 10:01:17 GMT Article-I.D.: lynx.1991May25.100117.26892 References: <5395@cernvax.cern.ch> Sender: @lynx.CS.ORST.EDU Reply-To: parkern@jacobs.CS.ORST.EDU (Neil Parker) Distribution: all Organization: The Universal Society for the Prevention of Reality Lines: 65 Nntp-Posting-Host: jacobs.cs.orst.edu In article <5395@cernvax.cern.ch> myb@cernvax.cern.ch (michel bornand) writes: >Hi everybody. Here is a simple Pascal program for Apple IIGS with should >produce a sound at 16kHz. It does not work. What's wrong with it? >What did I miss? Well...now that I'm at home where my manuals are, I guess I'll take a stab at this... >Pascal testsound; ^^^^^^ Huh? Do you mean "Program testsound;"? > >uses types,sound; > >var gparms:SoundParamBlock; > oneangle:array[1..16]of byte; ^^^ I don't know what version of Pascal you're using, but if it's TML Pascal, you'll need "packed" in front of "array"-- otherwise your 8-bit bytes will all be 16 bits wide... > >begin >[lotsa oneangle assignments deleted] > gparms.waveStart:=@oneangle[1]; > gparms.waveSize:=16; ^^ This says your waveform is 16 *PAGES* long, not 16 bytes! The smallest possible waveform is 1 page. > gparms.fredOffset:=311; > gparms.DOCBuffer:=1; ^ Toolbox Ref 3 says the HIGH byte is significant, not the low byte--this should be $100, not 1. > gparms.bufferSize:=$0800; ^^^^ Only the lowest 3 bits of this field are significant. The DOC buffer will be 2^bufferSize pages long. (Note that the resolution bits will also be initialized from this value, so changing it will change the pitch of your tone.) > gparms.nextWave:=@gparms; > gparms.volSetting:=255; > FFStartSound($0A01,@gparms); > >end. ^^^ Does your Pascal compiler generate an implicit QUIT call when execution "runs off the end" like this? I seem to recall reading somewhere that QUIT shuts down the tools, including the Sound Manager... Speaking of shutting down tools, did you remember to call SoundStartUp? I didn't see see it anywhere in your code sample... Suggestions: * Find out how your compiler handles array packing. * Make sure the length of your waveform is a multiple of 256. * Read pages 47-3 through 47-5 of Toolbox Ref 3. - Neil Parker -- Neil Parker No cute ASCII art...no cute quote...no cute parkern@jacobs.cs.orst.edu disclaimer...no deposit, no return... parker@corona.uoregon.edu (This space intentionally left blank: )