PLAYWAY and MIDPLAY2 (by Bruce Cichowlas 71760,554) November 30, 1992 DISCLAIMER: BOTH OF THESE PROGRAMS ARE QUICKIES WRITTEN TO AMUSE MY 1,4, AND 6 YEAR OLDS AND ARE THEREFORE NOT REPRESENTATIVE OF THE PROFESSIONAL QUALITY CODE (WHICH I PRODUCE FOR A LIVING). THESE WERE UPLOADED AT THE REQUEST OF SEVERAL INDIVIDUALS IN THE FORUM. PURPOSE AND SUMMARY (for both programs): Kids like to hear sounds, particularly if they can control them. In these activities, they get to use the mouse to select and start up sounds (.WAV or .MID). If they get bored with one, another will get started soon after they press another button. Each program displays the name of the file it is playing. To stop either, you must double click on the close box (or use some other standard window closing method). In each case, as the sound plays, something visual happens on the screen to help keep the kid's attention and to show which button they pressed last. Be sure to tell your kids that some of the sounds will take awhile to start (because they are long files). It is also normal for the current sound to continue, even though you have closed the program. You may consider this a feature or a bug. PURPOSE AND SUMMARY (specific to PLAYWAV): When a button is pressed, a random icon appears on the button just pushed. (See SETUP) Also, the icon's name appears in the box at the lower right. You can tell which sounds have been played because there are icons in the boxes. PURPOSE AND SUMMARY (specific to MIDPLAY2): At the beginning, each box is a shade of grey. When each box is pressed, it turns a series of different random colors as the MID file is played. You can tell which boxes have been used because they are not shades of grey (for the most part). There are two buttons at the lower right in MIDPLAY2. The left one is a bank select and turns GREEN, BLUE, YELLOW or PINK as it is pressed, if you have more than 110 .MID files. This will select which bank is in use. The right one is for a kind of random juke-box mode. If it is RED, a new .MID file will automatically be selected after the current one finishes. (It is GREY when inactive.) SETUP (specific to PLAYWAV): You need VBRUN100.DLL since this is written in Visual Basic. If you don't have this, you can get it from the Microsoft Forums. You need to create a file called WAVS.DAT in the "current directory". This file should have one .WAV file per line. Here is an excerpt from mine: f:\midwav\CHORD.WAV f:\midwav\CHIMES.WAV f:\midwav\TADA.WAV f:\midwav\DING.WAV f:\midwav\BELLS.WAV f:\midwav\BUMMER.WAV f:\midwav\CLAP.WAV f:\midwav\CLOCK.WAV f:\midwav\BLOCKS.WAV f:\midwav\TITLE.WAV f:\midwav\ANNA.WAV f:\midwav\LATNGUIT.WAV f:\midwav\CBJAZZ.WAV f:\midwav\CBLATIN.WAV f:\midwav\CBROCK.WAV I happen to have them all in one directory, but this need not be the case. Be careful not to have blank lines at the beginning or end, or spaces in the file. If there are more than 114 entries in this file, only the first 114 will be used. If there are less, they will be repeated as necessary for the 114 sound buttons on the screen. You also need a file ICONS.DAT which is set up just like the preceeding one, but has the names of icons. Not more than the first 500 icons will be used from this file (see above). You need not have this many. YOU MAY FIND, AS I DID, THAT SOME ICONS WILL NOT WORK WITH THIS PROGRAM. I didn't take the time to figure out why, though I suspect it is either a bug in Visual Basic or depends on the display format of the .ICON file. The ICON's that came with Visual Basic worked fine for the purposes of this program. (So did most others.) If you seem to be having problems, put just a few names in the file and see if this helps. To test whether a particular ICON is a problem, you could put just that one ICON name in the ICONS.DAT file, and this program would try to use it every time, allowing you to quickly determine whether there is a problem with that particular icon. About 95% of my icons worked without problems. If someone figures out what is going on here, I'd appreciate a message. SETUP (specific to MIDPLAY2): Besides VBRUN100.DLL (see above), you needs to make a file called MIDS.DAT in the current directory. Follow the directions about WAVS.DAT above, except that this file will contain the names of your .MID files. Here's an excerpt from mine: f:\midwav\THOMAS.MID f:\midwav\SING.MID f:\midwav\MTNKING.MID As noted above, these .MID files need not all be from the same directory. No more than 440 .MID filenames will be used from this file. If you have more than 110 names in this file, they appear as multiple banks (see description above). Before attempting to get this program to play .MID files, make sure your system is set up correctly. One easy way (under Windows 3.1) is to double-click on the .MID file names while in File Manager and make sure that the media player plays them back correctly and without comment. If you don't hear them, or they seem voiced wrong, you might try playing with the "MIDI Mapper" in the Control Panel (see your Windows manual). You may also find some of your .MID files that pollute the waters for succeeding .MID files, resulting in wrong patches, etc. Probably there is some kind of reset I could add to the program to prevent this. If this is a problem for you, just remove the names of the offending files from the list of .MID files. TECHNICAL NOTES: The source is included so you can modify these as needed. If you do something nifty, my kids and I would sure like a copy. These programs also illustrate the simplest ways I know to play sounds in Visual Basic 1.00 . PLEASE NOTE THAT THE INSTRUCTIONS FOR PLAYING .WAV FILES THAT APPEAR IN THE MICROSOFT KNOWLEDGE BASE ON COMPUSERVE HAVE SOME SUBTLE ERRORS. (I learned this the hard way.) In particular, their example says "SND_ASYNC And SND_NODEFAULT" when it should say "SND_ASYNC Or SND_NODEFAULT". Without this correction, you won't be able to interrupt the sounds. (I know some programmers fell for this one. You'll see this mistake copied in many Visual Basic programs for .WAV files.) The other mistake in this item in the Microsoft Knowledge Base is that it says Declare Function sndPlaySound Lib "MMSTSTEM.DLL" etc. but it should say Declare Function sndPlaySound Lib "MMSYSTEM.DLL" etc. Small differences, but they can take awhile to track down, particularly if you are not very familiar with BASIC or the Multimedia operations. CONFIGURATION: Since these were originally written for my own kids using these on my own systems, I may have inadvertently introduced some system-specific stuff that you may have to change. On the other hand, since I write software for resale for a living, I mostly avoid these sort of problems instinctively. The smallest configuration we use is a 33 Mhz 386 with 12 MB running Windows 3.1 with a version 1.5 SoundBlaster. This software has also been tested on a system with a MPU-401/MT-32 for the MIDI and a Media Vision card for the .WAV stuff. Probably it will work for you, subject to the usual possible problems with .MID mapping. (Make sure you can play your .MID files OK through the usual Windows 3.1 facilities before expecting them to work with this program.) Only the "Enhanced" mode of Windows was tested. Both a standard VGA and a 1024x768 VGA have been used, each with 256 colors. The hatching in the grey and color patterns is normal. This is just the way Visual Basic does things, even if you have 256 colors. (Probably you could play with the color functions in Visual Basic and do better.) Because of how Visual Basic implements "control arrays", you will find that you can't run much in the way of other applications alongside of these, even if you have lots of RAM. (I suspect if you re-implemented the button/picture control arrays as a single control with multiple sensitive areas, you would avoid this limitation. I may eventually do this myself to support more buttons at a time.) OWNERSHIP, PLEA, ETC.: I wrote these myself, and they are public domain as far as I am concerned. My kids and I would appreciate a copy of any derivative works, as well as any comments, good or bad. Any kind of response is appreciated. Your feedback gives me ideas for new programs. Criticisms are interesting, too, and help me improve my skills as a commercial software developer. If, as a part of the ShareWare principle, you'd like to do something nice in return, do something special for your kids or someone else's to give them encouragement in their own special interests. For me, job leads are always welcome, particularly in the current economy. I do lots of work as an independent consultant in C or C++ under Windows, including some of the highly technical aspects. I have a resume available on request. Hello and enjoy! Bruce Cichowlas 135 Everett Street Natick, MA 01760 (508)-655-0103 Compuserve [71760,554]