Newsgroups: comp.sys.apple2.programmer Path: news1.icaen!news.uiowa.edu!news.physics.uiowa.edu!math.ohio-state.edu!news.cis.ohio-state.edu!news.maxwell.syr.edu!logbridge.uoregon.edu!news.uoregon.edu!news.acsu.buffalo.edu!oswego!news From: edhel@LOSETHECAPITALWORDSbigfoot.com (Edhel Iaur, Esq.) Subject: Re: Programmin X-Nntp-Posting-Host: rocky-gw.oswego.edu Message-ID: <343001a1.18354420@129.3.17.35> Sender: news@oswego.Oswego.EDU (Network News) Organization: US-A2WUG, 1WSW X-Newsreader: Forte Free Agent 1.1/32.230 References: <01bccbce$e2880dc0$212da3cd@bartons.mcn.net> <60m6u2$a5s$1@darla.visi.com> Date: Mon, 29 Sep 1997 20:35:27 GMT Lines: 86 On 28 Sep 1997 18:16:34 GMT, nathan@visi.com (Nathan Mates) wrote: >[And despite what some twinks would like to keep saying, you >can't easily or reliably get any sound you may want out of Applesoft] Any sound, no. Aparently, the "BASIC FAQ" has been updated since my last reading :) Let us read: --- Some claim that by oddball combinations of accessing this softswitch (and usually in mathematical operations) that you can get something resembling sound and/or music out of the speaker. However, these, are wild hacks, and not very usable or easy to generate/modify. --- Here is (AFAIK) the "wild hack" mentioned--a great way to use this is to slap this line at the end of your program, and GOSUB to it whenever you want this more-cute sound, as opposed to the usual CHR$(7)--I wouldn't use it for music, but maybe I just don't know the right way to modify it: 10 Q = -16336 20W=PEEK(Q)+PEEK(Q)+PEEK(Q)+PEEK(Q)+PEEK(Q)+PEEK(Q)+PEEK(Q)+PEEK(Q) +PEEK(Q)+PEEK(Q)+PEEK(Q)+PEEK(Q)+PEEK(Q)+PEEK(Q)+PEEK(Q)+PEEK(Q) +PEEK(Q)+PEEK(Q)+PEEK(Q)+PEEK(Q)+PEEK(Q)+PEEK(Q)+PEEK(Q)+PEEK(Q) +PEEK(Q)+PEEK(Q)+PEEK(Q)+PEEK(Q)+PEEK(Q)+PEEK(Q) I *think* that's the right amount of +PEEK(Q)'s, anyway :) As you can see, it's much less boring making this kind of line with Program Writer, which lets you do macros. Try it, even at 1MHz, it's a cool sound :) Depending on which model Apple // you have, changing this from a PEEK thing to a POKE thing may make different sounds. I believe the //e will show the change, but the //c and IIgs won't. FWIW, I think I saw this on a Beagle Bros. disk. Some more FAQ stuff: --- Other beep tones and music require machine-language subroutines which are currently beyond the scope of this FAQ. --- This can be surprisingly easy, too. If I remember correctly, the routine for music is 9 bytes long. It's so short, I usually make it again every time I use it. Here I go, starting at 3:51 PM. Okay, I'm done at 4:03 PM (no, I'm NOT an excellent assembly programmer, doi!) Using the IIgs's miniassembler, I find that it took me a rusty 12 minutes, and more than 9 bytes :) Here's a routine, as needed by Applesoft BASIC guys: 10 FOR A = 768 TO 768 + 21 : REM 21 BYTES LONG. OH, WELL. 20 READ B : POKE A, B : GOTO 40 30 DATA 234, 234, 173, 0, 3, 174, 1, 3, 202, 224, 0, 208, 251, 172, 48, 192, 58, 201, 0, 208, 240, 96 35 REM PLAY SOME NOTES 40 FOR A = 1 TO 255 STEP 16 50 POKE 769, A 60 CALL 770 70 NEXT The 234's are just NOPs, so if you want to BSAVE MUSIC,A$300,L21 when you're done, and then BRUN MUSIC to load it, all it'll do is play a note instead of crashing--you should BLOAD this program to load it if you don't want that note played. If you want to save 2 bytes, you can save the music routine with BSAVE MUSIC,A$302,L19, but it'll probably crash if you BRUN it. POKE 768,x is how you change the note's length. x ranges from 0 to 255, with 1 being shortest, 255 being longest, and 0 being a hair longer than 255 (note: changing pitch changes the length a little bit, so you may need to alter your value of y to compensate). POKE 769,y changes the pitch of the note, with 1 being really righ-pitched, and 255 being low, and 0 being a hair lower than 255. Remember, system speed changes the way this routine sounds, pitchwise, and lengthwise. And that's the tunes according to Edhel :) PS: Yay, I'm a twink! :D If he said I was a twedge, I'd be dismayed. -- _ />____________________ +==Apple // Forever==+ || | |/ \| | |M#M#M#||____________________---__ +-37th Wisest Wizard-+ || | |`-.| | |#M#M#M||____________________--- +- Edhel Iaur, Esq. -+ ||/ \|\_/|/ \| \> http://members.aol.com/owsw/1WSW.Home.Page.html http://www.grin.net/~cturley/USA2WUG/FOUNDING.MEMBERS/HOME.PAGES/EDHEL ***For my correct email address, delete all the capital letters***