PlayMidiCE 0.3 A MIDI file player for the Roland SCP-55 Sound Canvas PCMCIA card in an HPC, such as an HP 360LX. This program will play MIDI files through the SCP-55. While the song is being played a display of 16 columns shows the current patch for each channel, and an animation of the notes being played. Notes are shown as horizontal bars. The vertical position of each bar is proportional to the pitch of the note. There is some support for playlists. This is a snapshot of a work in progress -- there are unimplemented features, and a few that are a bit rough around the edges. MIPS executables are included, but have not been tested. Use of the SCP-55 in your HPC may not be recommended by the manufacturer of your HPC. Please read this entire manual and refer to your HPC's documentation before you install your SCP-55 into your HPC. Do a full backup of your HPC before trying any of this. LEGALESE PlayMidi.exe, SoundCanvas.dll, and this manual are Copyright © 1998 Jonathan Engdahl This is a beta release for evaluation and feedback. This version (PlayMidiCE 0.3) may be distributed as freeware for personal use only. It may not be distributed or used commercially. This software and the procedures described in this manual are experimental in nature. The author does not warrant that the software will meet your requirements or that the software is error-free. The author makes no representation that using the software or following the procedures in this manual will not result in equipment damage or data loss. You assume all risks associated with using the software or procedures. The author will not be liable for any loss resulting from such use, or from the inability to use the software. By installing and using this software you indicate that you agree to these terms. ABOUT THE SCP-55 The SCP-55 is a Roland Sound Canvas wavetable MIDI synthesizer on a PCMCIA card. A description is here: http://www.edirol.com/scp55.html. It is compatible with the SC-55 mkII (28 voices, 354 sounds). If you shop around you should be able to find it for around $300. INSTALLATION Hardware requirements: SH3 or MIPS based HPC with PCMCIA slot. Roland SCP-55 PCMCIA Sound Canvas, with appropriate headphones or speakers. You will need to use the AC adapter -- the SCP-55 is a power hog. Software requirements: Windows CE 2.0 Host: Windows NT or Windows 95/98 PC and HPC download cable. The install procedure was tested on a 486 notebook running NT 4.0 -- I haven't tried the install using Windows 95/98. To install, run the self-extracting archive file, PlayMidiCE03.exe. The archive contents will be unpacked into a subdirectory named PlayMidiCE03. Connect your HPC to your PC, then run "setup.exe". Setup will put SoundCanvas.dll (the driver) and PlayMidi.exe (the player) into the \windows directory of the HPC. The following entries will be automatically placed into the HPC's registry: [HKEY_LOCAL_MACHINE\Drivers\PCMCIA\Roland-PCMCIA_Sound_Card-D11B] "FriendlyName"="Roland Sound Canvas" "Prefix"="SCP" "Dll"="soundcanvas.dll" [HKEY_CLASSES_ROOT\.mid] @="midifile" [HKEY_CLASSES_ROOT\midifile] @="MIDI song" [HKEY_CLASSES_ROOT\midifile\Shell\Open\Command] @="PlayMidi %1" [HKEY_CLASSES_ROOT\.abm] @="abmfile" [HKEY_CLASSES_ROOT\abmfile] @="MIDI album" [HKEY_CLASSES_ROOT\abmfile\Shell\Open\Command] @="PlayMidi %1" USING PLAYMIDI The HPC should be powered by the AC adapter. Insert the SCP-55, with headphones or speakers attached, into the PCMCIA slot. If the driver is properly installed there will be no messages when you insert the card. Download your favorite MIDI files to the HPC. Choose carefully: about 100 MIDI files takes up roughly 2.5 megabytes of the HPC's memory. A compact flash card is a good place to keep MIDI files. Double-clicking on a .mid file will start the player and begin playing the song. The up and down arrow keys on the keyboard will adjust the volume. The volume commands may not be executed right away due to giving the MIDI player the highest priority. Double clicking on an .abm file will start the player at the first song in the album. Each song in the list will be played. When the last song is finished the player will exit. An album is simply an ASCII list of absolute paths to .mid files, one per line (just like WinJammer player). You can create album files from the player. You can also create an album with Pocket Word, saving it as a .txt file then renaming it to .abm. At present, starting the program by clicking on the executable doesn't work; it requires an argument that is either an album or a midi file. The command bar buttons are: + -- bring up a file dialog to add a file to the current album. If you double click on a file or click "OK" the selected file will be added to the album, and the dialog will reopen so you can add more files. To stop adding files click "X". -- delete the currently selected file from the album. Use the combo box to select a file. ^ and V -- unimplemented, eventually these will move the currently selected files up and down in the album. folder icon -- open an album via a file dialog. floppy icon -- save the current album via a file dialog. >> -- jump to the beginning of the next song. > -- play. -- pause. << -- jump to the beginning of the previous song. I recommend ejecting the SCP-55 when you are not using it. QUIRKS AND EXCUSES I use the SCP-55 in "dumb UART" mode, meaning that timing must be generated by the player using the 25 millisecond Windows timer and timing loops that reference the PerformanceCounter. This means that multi-tasking may cause notes to be delayed. I bump the player's priority up a couple notches. You *can* run another program while a song is playing, but it may run slowly, or even get locked out during a rapid passage. (A certain classical piece with a long timpani roll shuts everything else down for a while). If you pop up a menu or dialog in the player the song stops, but the clock doesn't. When you close the menu or dialog the song sometimes plays very fast until it catches up with the clock. The program is written for a 640X240 B&W screen. The screen ought to scale to a narrower screen, but the patch names will most certainly get scrunched. It plays most midi files quite well. Screen drawing is done in real-time (not queued), in the gaps between notes. If a song loads a bunch of patches, then starts playing right away, the first couple notes might get delayed while the patch names are painted to the screen. The program sends a GS reset about a second before the start of a song. Some of the things that the player does with MIDI files, mostly due to quirks of old midi files, or perhaps my first synth module (a DS-330): a "note on" with a velocity of zero is sent as a "note off". if no patch is selected for channel 16, it gets rerouted to 10. This is to accommodate some very old midi files that assume the drums are on 16. unsupported drum sets are mapped to "standard" notes on the drum channel (10) are stretched by delaying the "note off" by 20 ticks. This is a hack to allow the drum notes to be visible on an LCD display. It doesn't seem to affect the sound. Let me know if this is a problem. POWER and HEAT The SCP-55 is a 5 volt PCMCIA card that can draw over a third of an amp. The HP 360LX with the AC adapter seems to have no problems powering the card, although the bottom surface of the HPC gets quite warm after a while. With freshly charged NiMH batteries I can run the card on batteries alone for maybe 15 minutes at reduced volume before the batteries are drained. If I do not reduce the volume the sound will be subject to distortion and volume fluctuations, presumably because the internal power converter is having a hard time generating enough power from two AA cells. I also get a little hum from the converter when running from batteries. The card did not work well on alkaline cells -- evidently the internal resistance of these batteries do not allow them to supply sufficient current. Running a power hungry PCMCIA card on batteries may result in a sudden shutdown of your HPC. I'm not sure what the possible consequences of this are. My HPC recovered the few times that it happened to me. Expect Windows CE to give you warnings about power consumption if you try running MIDI on batteries. I can't imagine that running the rechargeable batteries at high currents will do anything good for their lifespan. Please backup your HPC before trying this! While the SCP is being powered by the HPC both the power converter in the HPC and the SCP-55 itself generate significant amounts of heat. It would probably be best to keep the HPC open. Do not surround the HPC with insulating material (like setting it on a carpet or quilt) -- rather, try to enhance conduction of heat and air circulation. While debugging this software, I sometimes stand the HPC on its end to improve air circulation. It is probably true that running your SCP-55 in your HPC for long periods of time will shorten the life of your HPC, based on the principle that operation at higher temperatures shortens the life of any electronic device. Furthermore, Hewlett Packard's manual for the 360LX says: "It is recommended that you use only PC cards which have been tested with your model of HP Palmtop PC. Use of other cards is not recommended". The SCP-55 falls in the category of "other cards". Although I haven't fried my HPC yet, there is no guarantee that it won't fry. Therefore, you must decide whether you are willing to accept the unknown risks resulting from installing your SCP-55 in your HPC. THE DRIVER The driver is derived form the serial card driver included in the Windows CE SDK that can be downloaded from Microsoft's web site. The driver performs four functions: PCMCIA handshaking initialize the SCP-55 open/close -- single access only write MIDI data to the SCP-55 There doesn't seem to be any "write done" interrupt on the SCP, so a block of MIDI data sent to the driver is simply blasted to the output port using loop-onready synchronization. The use of the driver is quite simple, as illustrated by the following code. This is the MIDI equivalent of "hello, world!" -- it opens the SCP, plays three notes, and closes it. The source code and a Developer Studio project file for this program are included in the distribution file. #include <windows.h> // SCtst -- the Roland Sound Canvas equivalent of "hello, world!" // write a buffer to the Sound Canvas card BOOL sendCommand( HANDLE hDevice, // handle to open device unsigned char *cmd, // pointer to buffer int cmdLen) // number of bytes in buffer { DWORD count; // Write command. if(!WriteFile(hDevice, cmd, cmdLen, &count, NULL)) { MessageBox(0,L"WriteFile failed",L"Sound Canvas",0); return FALSE; } return TRUE; } int WINAPI WinMain( { HANDLE HINSTANCE hInstance, HINSTANCE hInstPrev, LPWSTR pszCmdLine, int nCmdShow) hDevice; // Open the SoundCanvas device. hDevice = CreateFile( TEXT("SCP1:"), GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); if(hDevice == INVALID_HANDLE_VALUE) { MessageBox(0,L"CreateFile failed",L"Sound Canvas",0); return FALSE; } // play a (very) simple tune // note that the notes are not turned off unsigned char buf1[]={0x90,0x40,0x40}; unsigned char buf2[]={0x90,0x42,0x40}; unsigned char buf3[]={0x90,0x44,0x40}; //this is a MIDI "note on" sendCommand(hDevice, buf1, 3); Sleep(1000); sendCommand(hDevice, buf2, 3); Sleep(1000); sendCommand(hDevice, buf3, 3); Sleep(1000); // Close device. if(!CloseHandle(hDevice)) { MessageBox(0,L"CloseFile failed",L"Sound Canvas",0); return FALSE; } return TRUE; } If you write any software that uses my driver, please send me a copy of it. BUGS, FEATURES, and PORTS Let me know of any bugs that you find, or of feature enhancements you would like to see. Things that I would like to do someday are: cleanup and complete the implementation of album management color the notes according to their velocity tilt the note bar to show pitch bend implement smart MPU-401 timing in the driver improve the volume control -- I'm currently using the Master Volume sysex. I have a hunch that there is a volume control built into the onboard amplifier, but I have no information on how to use it. I don't have any documentation on the SCP-55 or MPU-401 other than the manual that came with the SCP and the Linux MPU-401 driver source code. I found a magic string of initialization bytes in an HP 200 program from a web site in Japan. The program comments are in Japanese, so I don't know what the incantation means, but once you say the magic bytes, the first two registers of the SCP-55 behave like an MPU-401. If anyone can give me more info on the interface to the SCP-55 I would appreciate it. The color version of this program that runs on DOS uses color temperature to indicate the velocity of each note. It is especially interesting on songs that were captured by a good performer using a velocity sensitive keyboard. I will have little incentive to add color to the WCE version until I have access to a color HPC. Of course the old rule applies -- I will try to port my software to almost anything, if someone gives me the hardware. CHANGE LOG Version ------0.2 0.3 Date ----------Jun/18/1998 Jul/30/1998 Description ----------------------------------First public release. Got it to run when compiled for "release" (no more mfcce20d.dll). Fixed some memory leaks. ACKNOWLEGEMENTS I would like to acknowledge and thank the authors of the midifile parser that I used. I seem to have obtained this module many years ago as part of the MF2T/T2MF package, written by Piet van Oostrum, piet@cs.ruu.nl, who acknowledges the midifile library thus: "The programs use the midifile library written by Tim Thompson (tjt@blink.att.com) and updated by Michael Czeiszperger (mike@pan.com)." The SCP-55 initialization sequence was found in an 8086 assembly source code called SCP55_HP.ASM. The comments are in Japanese, except for this: "Programmed by Sour23" -- whoever you are, thanks for the magic bytes. The rest of the software was auto-generated by the Microsoft Visual C++ wizards, taken from the Windows CE DDK samples, or even written from scratch by myself. The real brain of the MIDI player was written by myself long ago in the days of DOS and direct screen writes to the VGA adapter, for the Boss DS-330 synth module and a parallel-port-to-MIDI adapter that I built from scratch using an AY-5-1013A. Jonathan Engdahl Electronic mail user jrengdahl at provider hotmail in the com domain July 30, 1998 Chardon, Ohio, USA