!========================================! ! ! ! IISound.System v4.2 ! ! ! !Digital Sound playback for the Apple IIe! ! ][+ version coming soon!! ! !========================================! ! By Philip Lamb : ShareWare 1994 ! !========================================! Playback engine by Michael Mahon : Freeware 1992 File selection dialogue by Karl Bunker Inspired by "SoftDAC" by Scott Alfter : Freeware 1992 This program is Shareware. Registration costs $15 US/$20 NZ and the more people register, the more likely I am to continue adding enhancements (like IBM .wav and Audio IFF readers!). Please distribute it as widely as possible, but make sure that these docs are with the program, intact and unchanged! Contents 1) Intro to sound on the Apple ][ 2) The IISound package 3) Program operation 4) Sound sources 5) Extra memory 6) Ramdisks 7) Shell programs 8) How the playback code works 9) Shareware notice 10) Registration info! 11) Contacts. 12) Registration form INTRO TO SOUND ON THE APPLE ][ Despite all its other great properties, the Apple ][ has always had serious limitations in recording and reproducing audio. These limits were repeatedly tested by talented programmers such as Paul Lutus, who in 1981 wrote Electric Duet, which produced real two-voice, reedy music! A host of other programs used similar techniques during the 80's, but the fundamental (harmonic?) tyranny of square waves continued. Then, in 1990, Scott Alfter wrote a little suite of programs to play Mac sound files on any Apple ][. Scott's IISound represented a new high water mark for audio reproduction on a non-GS Apple ][. It played 11 kHz. sampled sound files through the Apple speaker (or the cassette output) with reasonable fidelity--not great, still gravelly, but much better than had ever been heard before. It apparently inspired Michael Mahon to discover just how far you could go in making a vanilla Apple ][ sound like a IIGS or a Mac WITHOUT adding any hardware. His five bit playback engine, as appears in the program SOUND.EDITOR was the result. THE IISOUND PACKAGE The plyback engine in IISound works in substantially the same manner as Michael's, with only minor modification. Around this playback engine, I built a fully operational and user friendly system program, to handle sound loading and playback. Editing and saving features are being worked on right now, and should be out soon (if lotsa people register!) This distribution includes these files: IISound.System The biggie. Requires an Apple IIe with 128K or more memory. IISound.Mini A cut down version, for use only by shell programs. IISound.Docs You're reading em right now! IISound.Welcome A sample digitised sound to whet your appetite I am now readying, for version 5.0 of IISound: IISound.64K A version which runs in 64K, and requires only a ][+ IISound.Editor A plug in, fully featured DHR sound editor and saver. IISound.Player A Basic.System added cmd to play sound files from BASIC PROGRAM OPERATION The program is menu driven, including disk loads and saves (thank you Karl Bunker), and fairly self explanatory. Loading sounds: Up to 15 sounds can be loaded at once, but this is of course limited by the amount of memory that you have. [L] loads a standard sound file. [;] loads a sound file, but discards every 2nd byte, thus, 22.050 kHz sounds will load as though they are 11.025 kHz sounds (playback is still at 11.000 kHz though) ['] as above , except discards 3/4 bytes, thus allowing 44.1 kHz compact disk sounds to be played. (I am currently working on a modification to allow sounds of any frequency to be loaded and standardised to 11kHz. When this is done, then Audio IFF/ true .wav readers will appear!) A file selection dialogue box appears. As of version 4.2, IISound loads all sounds as raw sound data, thus the data headers on some sounds (eg the 64 byte header on $D8 (SND) type files) will also play, as noisy clicks. This problem will be removed (hopefully!) in v5.0 when it will identify and read Audio IFF & IBM .wav sounds and Mac sounds from a mac resource file (transferred using A2FX.) Playback! On the right side of the screen appears a list of the sounds currently loaded in memory. Each sound can be cued for instant playback just by pressing the key or the letter that appears beside the sound name. While one sound is playing, you can press a key for another sound to be played, and it will play immediately after the first has played. Unloading Sounds: Pressing [X] from the main menu will allow you to clear a sound from memory. You will be prompted to press the key corresponding to the sound you wish to clear. Clearing a sound causes all the sounds above it in memory (below it on the menu) to be shuffled down to consolidate memory. With several sounds loaded, this can take some time so be patient! Clearing the most recently loaded sound will be instant though. Other keys: [T] Toggles between speaker/cassette output. [Q] Quits IISound [R] reinits memory, clearing the current sound. [Ctrl-D] shows some low level info on the sound in memory. [>] and [<] switch between the two menus of keys. SOUND SOURCES Unfortunately, you can't (yet!) digitize sounds with much precision on an unaided Apple ][, but there are a wealth of 8-bit digitized sounds available in the IIGS, Mac and IBM worlds, and many can be easily downloaded from online services. On Internet, the USENET News groups alt.binaries.sounds.* carry thousands of megabytes of sounds. Many are in IBM .wav format which will usually play just fine. The FAQ for these groups will give you more info on how to decode them. EXTRA MEMORY IISound will identify and attempt to use all available memory on Ramworks type auxiliary slot memory cards. Because of the awkward nature of Apple II memory, and timing constraints, the program utilises only 46K of each 64K bank. With a standard 128K IIe, you'll get around 4.5 seconds playback. With a 1 meg ramcard though, you can have over 1 minute of sound. With the largest ramworks around (3 meg) you can have over 3.5 minutes of sound! RAMDISKS Upon startup, the program looks for any Ramdisk that may be using aux. mem. and it will graciously remove any slot 3 drive 2 ramdisk that you might have installed, whether it is the 64K volume created by ProDOS or the larger volume created by Applied Engineering's ProDrive software. If the ramdisk conatins files you will be given options of quitting (without touching /RAM), using only the first 64K of aux. mem. (thus skirting around ramdisks which leave this bank free) or removing the ramdisk. SHELL PROGRAMS IISound supports the Apple system program auto-run protocol, that is, it allows a file to be specified upon launching which will be automatically loaded into memory and played, finally returning control back to the launcher (through the ProDOS quit code). Either a partial or full pathname should be stored in memory before control is passed to IISound. The maximum length of the path is at $2005 (8197) in memory after IISound has been loaded. The length of the name should be stored at $2006 (8198) and the path in standard ascii immediately after. This function can be carried out nicely by "shells" like Davex, ECP-8 etc. Here is a sample invocation that works on ECP-8 or Davex shells: IISound.System /lambo/sound/welcome.raw This starts up IISound and plays the file /lambo/sound/welcome.raw. You don't have to specify a full pathname for the sound file; IISound will accept partial pathnames. If an invalid pathname is specified, IISound will return to your shell. If a valid pathname is given, IISound will load the sound, play it, and return to your shell. The shell feature works on both IISound.System and IISound.Mini, which will ONLY work through use of a shell utility, and which will only load 11kHz files. HOW THE PLAYBACK CODE WORKS It takes several bits of precision in converting digital samples to sound to make "good" sound, but the natural audio output capability of the Apple speaker (prior to the IIGS) is only one bit. You can decide when to "toggle" the speaker, but that's it--the cone is either all the way in (or headed there) or all the way out (or headed there). Experiments have shown that the human ear is essentially insensitive to the "polarity" of sound, so "in" and "out" can be interchanged in all the discussion that follows. (This is just as well, since the Apple I/O circuitry doesn't give us control over the polarity anyway!) Paul Lutus (and others) found that greater resolution in speaker movement could be achieved by toggling the speaker (in and out) at a high frequency, and then varying the "duty cycle" of the square wave. Changing the duty cycle (the fraction of the time the speaker is commanded to be "in," say) of a high frequency square wave can be thought of as causing the speaker cone to move to a position approximating the average value of the square wave, which is the duty cycle. This allows us to generate multiple tones by changing the duty cycle at an audio rate to approximate the value of the sum of the two (or more) tones. This latest DAC code has a long and distinguished pedigree. From Paul Lutus original work, to Scott Alfter's 3 bit, and later 4 bit playback code, to Michael Mahon's 5 bit engine, it has become cleaner, and crisper. Then with help from Greg Templeman, Michael completely rewrote his 5 bit code, to eliminate the 11KHz carrier (an annoying screech over the playback) that had previously limited the usefulness of any further improvements. His DAC522 code is the result, and is the playback engine (modified for use of auxiliary memory by me) used in IISound v4.2 As most sounds are sampled at multiples of 11.025 kHz, this is the most logical playback speed. Thus on an unaccelerated II, of clock speed 1.023 MHz we have 1023000 / 11025 = 93 cycles to playback each sample twice ( for 2* oversampling.) This latest DAC is composed of 16 different pulse generators, each of which has the job of producing two identical pulses with "on" times varying from 6 to 37 machine cycles and with a constant period of 46 cycles. The total period of the two pulses is 92 cycles, the closest even approximation to 11.025 kHz. (Actually, 11.092 kHz.) At the end of each generator, it jumps to the generator needed for the next sound sample. It's only coincidental if it winds up "looping" by vectoring to itself! The appropriate generator is selected by the most significant 4 bits of the sound sample, and the fifth-most significant bit is used to lengthen the duty cycle by 1 cycle, if it is set. As a result, this software DAC, aptly named DAC522, converts with a precision of 5 bits and a "carrier" frequency of 22.05 kHz. The average noise from 5 bit/ 2* oversampled playback is about 1.5%. The result, I think you'll agree, is excellent audio reproduction, out the standard ][ speaker. I listen to my Apple //e through a large amp and the output of this 5-bit software DAC is good enough to mimic a IIGS or a Mac, ! You can also use the cassette output (except on //c's) to listen, or record onto tape. NOTICE This program is SHAREWARE. This means that you can freely distribute it any way you like as long as you don't remove this notice, but if you use it regularly, you are expected to register the software (see instuctions below) With the tiny amount of new software being written for the II, registration is especially important. Positive reinforcement does work! The more people register, the more time I will put into making this software comparable to programs on bigger platforms. I can do this. Time is the onlny limiting factor, and registration helps offset this. I would ask that you do not distribute modified versions of this software, but send any ideas or code for modifications to me, and I will include them in my releases. This way the software won't diverge into mediocrity. Now for the important bit! REGISTRATION To assist me in making better versions of this software, please fill out the registration form below. If you include an Internet email address I will acknowledge the receipt of your form by email as soon as I recieve it. Registration, apart from giving me positive reinforcement that people want and use my software, entitles you to discounts of registration of future versions at minimal cost, so please take the time to fill this out and send it to me, along with the fee of $15 US/$20 NZ. Postage from the US costs only $0.90 so there isn't much of a premium! Please include any comments you would like to make, features you would like to see, bugs you have found, and what you like to use IISound to do. Thanks again! To register your copy of IISound v4.2 please send $15 US or $20 NZ to; Mail: Philip R. Lamb 30a Blighs Rd Christchurch 8005 New Zealand Email: p.lamb@csc.canterbury.ac.nz Finger: misc176@cantva.canterbury.ac.nz These addresses are likely to remain valid until at least 1997 and probably after that too! Other contacts: Michael Mahon Scott Alfter 1975 Adele Place Skunk Works Software Co. San Jose, CA 95125 4600 Swenson St. #163A USA Las Vegas, NV 89119 Internet: mahon@nsa.hp.com USA ~~~~~~~~~~~~~~~~~~~~~~~~~IISound v4.2 Registration Form~~~~~~~~~~~~~~~~~~ To register you copy of IISound v4.2 please send $15 US or $20 NZ to; Philip R. Lamb 30a Blighs Rd Christchurch 8005 New Zealand Name:____________________________________________________________________ Street:__________________________________________________________________ City:______________________________ State: ______________________________ Country:_________________________________ Zip Code:______________________ Email address:___________________________________________________________ Where did you obtain your copy of IISound v4.2? ____ Friend ____ User Group ____ Usenet News (comp.binaries.apple2) ____ Internet FTP site (Please specify: ____________________________ CPU: ____ Apple ][ or ][+ ____ Apple //e (unenhanced) ____ Apple //e (enhanced) ____ Apple IIc or IIc+ ____ Apple IIGS ____ Apple Emulator (Please specify: _______________________________ Comments:________________________________________________________________ _________________________________________________________________________ _________________________________________________________________________ _________________________________________________________________________ _________________________________________________________________________ _________________________________________________________________________ _________________________________________________________________________ _________________________________________________________________________ _________________________________________________________________________ Bugs encountered:________________________________________________________ _________________________________________________________________________ _________________________________________________________________________ _________________________________________________________________________ _________________________________________________________________________ _________________________________________________________________________ _________________________________________________________________________ _________________________________________________________________________ _________________________________________________________________________