Hubi's LoopBack device Version 2.2 October 10, 1995 virtual MIDI driver for Windows3.1 to connect multiple Windows-MIDI-programs. _____________________________________________________________________________ This package may be of use for You, if you * work simultaneous with multiple MIDI programs in Windows (or want to do it). * hate the Message "the MIDI device is currently in use by another ...". * simply want to hear the OPL2-FM chips of your SoundBlaster when you play your Waldorf Wave keyboard (can't get that noiz out). do you? :-) * Use your favorite Synth-Editor together with your favourite MIDI-Sequencer, Combine the best of all MIDI programs. * Don't want to wait for OMS. This package is NOT for You, if you * ask now "What is MIDI ?" * laugh with pleasure about Microsofts error messages and their funny translations. (is there a BestOf anywhere on the Net ?) * won't hear a PC ventilator fan near your Waldorf Wave. * your only MIDI application is a MIDI Jukebox player. _____________________________________________________________________________ Highlights up to 4 new MIDI In/Outputs Multi client feature allows mixing and duplication of MIDI messages full SysEx support Very low memory requirements (about 5K fixed / 4k discardable Windows memory) No hardware required (except your Windows-PC) Port names can be edited CAN EXTEND YOUR MIDI-DRIVER TO MULTI-CLIENT FASCILITY ! comes with hwmdcabl.exe - the realtime SysEx-thru icon. program source is available IT'S FREEWARE _____________________________________________________________________________ Table of Contents Installation Updating from a Previous Version How "Hubi's LoopBack works" How "Hubi's MidiCable works" Simple Example Setup Making a MIDI port Multi Client able Hints and Warnings : Midi-Thru, Cubase, CTL3D.DLL History Future Enhancements - What YOU can do About the Author _____________________________________________________________________________ Installation Unzip into an empty directory pkunzip a:mdlpbk22 -d c:\tmp Copy the files HWMDCABL.EXE and HWMDCB.DLL to another directory. If you use Windows FileManager, use the Drag&Drop feature to install a ProgramManager icon. Start Windows, select "Control Panel" from the "Main" group, select Drivers, select Add button, select "unlisted driver", OK, enter your directory (eg. C:\TMP). Now you should see "Hubis Loopback V2.2", and press OK. Now the configuration dialog comes up and you must select the number of ports to use. 2 should be a good starting point, but WARNING: Windows cannot handle more than 10 midiports (+Midimapper). After Restart, the new MIDI In and Outputs will be available then. If you have no CTL3D.DLL in your \windows or \windows\system directory (nearly impossible) then you must install one manually. ______________________________________________________________________________ Updating from a previous version The main difference to the previous versions 1.0 and 1.1 is, that midlpbk.dll now can deal with multiple clients. Each port can be opened by up to 4 MIDI-In clients and up to 10 MIDI-Out clients. This feature makes the old matrix configuration now unnecessary, and allows a more powerful and flexible configuration that is also easier to maintain. Removed features are: - IN- and OUT ports now have the same name - Matrix-setup removed - No more a Control Panel Applet This means you have to remove your ProgMan-Icons for "control midlpbk.dll", remove from control.ini, Section [MMCPL] the line Hubis LoopBack=c:\windows\system\midlpbk.dll Please remove the old driver before installing the new one. This saves some space in system.ini. The new features are + Multi Client + Port Name Dialog The setup dialog is now only available from SytemControl->Drivers->Configure. Between the versions 2.0 to 2.2 is no functional difference, only peripheral smoothing. ______________________________________________________________________________ How "Hubi's LoopBack" works: There is a MIDI output port and a MIDI input port. All data sent to the output will be available at the input port, that is the MIDI output from one program is the input of another program. Prog1 >--[ LB1 ]--> Prog2 You should think about a MIDI node, which can be opened as output from several programs and input of others. Each of this programs is named "a client". The output of all OUT-clients is mixed down and sent to all IN-clients. Multi-Client means, that each node can have up to 4 IN-clients and 10 OUT-clients. Hubi's LoopBack can serve up to 4 nodes, but changing the number of active ports (=nodes) requires to restart Windows. ______________________________________________________________________________ How "Hubi's MIDI cable" works It's a simple MIDI-thru program with following features: - All MIDI processing in realtime - no Windows delays - Full SysEx support - unlimited SysEx Message size - low resource requirements (I could start it 57 times!) Unique Feature: === skip this paragraph if you're not a programmer === The design of Windows MMSYSTEM extensions would not allow to use the function midiInAddBuffer during interrupt time, so it must be done later by a Window-Message response. But Windows is a preemptive multitasking system and sometimes applications have no chance to process the queued Window messages. If much MIDI System Exclusive messages are sent in a short time (like editing Synth parameters), and Window messages cannot be processed (e.g. the user holds down the mouse button over a slider), then the MIDI buffers cannot be re-added to the input driver before the next buffer is filled and delivered... the data chain is broken. So I decided to use a better solution. I programmed the midiInAddBuffer functionality myself, so I can use it at interrupt time. I simply remember the last added buffer and set its lpNext member to the new buffer, and the new buffer will become the last added buffer (that's what all MIDI driver do). The result looks perfect for me. I use three 1kB buffers (only one global handle). A buffer overflow can only occur when receiving from a a 38400 baud (serial "To Host" device) and sending to 31250 baud (MPU401) MIDI port (that is, receive from a fast hardware port and send to a slower hardware port). The COM port gets ~ 715 bytes per second more than the MPU can transmit and so data will be lost after 3-4 seconds ( ~ 10-15k System Exclusive Message Size). No lost data is possible when one port of the connection is a Windows MIDI application, connected via a virtual MIDI driver. Usage: - Start - Search icon, then select MIDI-in port and MIDI-out port. - .... play your attached MIDI keyboard - Close - the settings are remembered for the next start (in win.ini). Usage for advanced users: The pro's need more than one instance running (I tried 57!), so I gave the program the option to pass the ports on the command line. e.g. HWMDCABL.EXE IN=1 OUT=1 Create an own program manager icon for each needed MIDI-connection and edit the appropriate command line. The numbers are the same as in the icon menu. If it should start at startup, copy the program manager icons into the Autostart program group (hold down the key while dragging with the mouse). ______________________________________________________________________________ Simple Example Setup: The symbol >>>> means a running HWMDCABL.EXE instance. [SB MIDI In]--->>>>---[LB1]------[LB2]--->>>>--[SB MIDI out] / / \\__// \ MidiJoy_/ / \____/ \ virtual Keyboard_/ \ Note what's possible with only 2 nodes activated, and now imagine how complicated your setup could be with all 4 nodes activated... But if Creative Labs makes their SB16 MIDI Driver with multi client support, most would work without midlpbk.dll _____________________________________________________________________________ MAKING A MIDI PORT MULTI-CLIENT-ABLE You can use a loopback-port together with HWMDCABL.EXE to make a Hardware MIDI port (eg. SoundBlaster) able to handle with multiple clients. There exist already several MIDI drivers which are able to deal with more than one client. I know of following: Twelve Tone Systems MPU401 driver (comes with Cakewalk) Voyetra Super SAPI FM synth (comes with SB16) KORG PC I/F V1.11 (for KORG X5/05RW/X5DR) Jamie O'Conell's FMSynth driver for OPL2/3 (V1.04? ) All Turtle Beach drivers A test if your driver supports multi-client access is simple: - start 2 instances of HWMDCABL.EXE - try to open one port (in or output) simultaneous by both midicable-icons. If this works without an error message box, the port supports multi-client access. If an error message box comes with "the midi port is already in use..", multi client access is not supported. - IN and OUT - ports are independent of each other, so you must check both. To make a single access port multi client able, you must combine a LoopBack node with a MIDI thru application: HWMDCABL.EXE I'll demonstrate how to make the SB-MIDI port Multi-Client: If you install midlpbk.dll and configure it with 2 active ports, then you'll have 4 available MIDI inputs: 1 [SB16 MIDI In] 2 [Voyetra Super SAPI FM Synth] 3 [LB1] 4 [LB2] The MIDI outputs should look like: 1 [Microsoft MidiMapper] 2 [SB16 MIDI Out] 3 [Voyetra Super SAPI FM Synth] 4 [LB1] 5 [LB2] We use LB2 for the extension. For easier maintenance of the resulting setup, we rename LB2 to "Multi SB MIDI In" (This is done by double-clicking at the port name in the configuration dialog in Windows-Sytem-Control, Drivers). Now we must start hwmdcabl.exe. The most user friendly way would be to start it automatic on Windows startup. The installation is easy: - Open ProgramManager and FileManager so that both are visible (Why do most users use them in full screen mode ? ). - Select the hwmdcabl.exe directory in FileManager - Open the AutoStart group in ProgramManager - Move the mouse (only the cursor) to FileManager, click over "hwmdcabl.exe" and hold the mouse button down and move this icon into ProgramManagers Autostart group and release the mouse button. Installed. - Now we must tell hwmdcabl.exe which ports it should use. Start hwmdcabl.exe and open the system menu of the appearing icon. You'll see a large menu with all MIDI-IN ports in the middle and all MIDI-OUT ports at the right side. Look at the numbers before the ports and remember the wanted IN and OUT port number. Now switch to ProgramManager and hilight the Hwmdcabl icon in the Autostart group. Press Alt-Enter to edit its properties. - Append " IN=x OUT=y" (without quotes but with leading blank) to the CommandLine field. x and y must be replaced with the appropriate port numbers from the menu. - Edit the Description field to "Multi SB MIDI In" or whatever you want - press OK In the above example, this could look like this dialog snapshot: Description [Multi SB MIDI In ] ( OK ) CommandLine [C:\WINUTILS\MIDI\HWMDCABL.EXE IN=1 OUT=5 ] (Cancel) Directory [C:\WINUTILS\MIDI ] (Search) Hotkey [ ] (Symbol) The next step is to change the setup of your MIDI programs to use the new "Multi SB MIDI In port", which can be opened by 4 programs simultaneous now. The menu of the running HWMDCABL.EXE program should look like: 0 None | 0 None | --------------------------------|---------------------------------| 1 X SB16 MIDI In | 1 Microsoft MidiMapper | 2 Voyetra Super SAPI FM Driver| 2 SB16 MIDI Out | 3 LB1 | 3 Voyetra Super SAPI FM Driver| 4 Multi SB MIDI In port | 4 LB1 | | 5 X Multi SB MIDI In port | an the icon title should be "SB 16 MIDI In to Multi SB MIDI In port". To make an output Multi-Client, read this chapter again with words IN and OUT swapped. _____________________________________________________________________________ Integrating MIDIMAPPER in setup Example: a Yamaha PSS790 + Cakewalk Homestudio - PSS790 sends all MIDI IN unchanged to MIDI OUT (merged with Keys) - Cakewalk Homestudio has no Input Channel Filter. - If you want to sequence a song using the PSS790 Synth during record, you'll get all MIDI data back at the MIDI-In and will record all 16 MIDI channels (echoed from PSS790 out) at the current track. [PSS790]-[MPU]-->>>--[MidiMapper]--[LB1]--[Sequencer]--[MPU]--[PSS790] * enable one virtual Node LB1 * Setup MidiMapper: Only channel 1 is enabled and sent to LB1, rest off. * MidiCable with IN=MPU and OUT=MidiMapper * Only LB1 as Input in Sequencer Now the Sequencer receives only channel 1 ! And you can record track by track now. _____________________________________________________________________________ HINTS & WARNINGS: MIDI THRU When using the MIDI-thru option in your Sequencer application, be sure it doesn't record it's own output when it sends to a virtual MIDI port. The system will slow down or hang if a Midi-message circles around. ! A SEQUENCER PROGRAM MUST NOT HAVE THE SAME MIDI-NODE AS INPUT AND OUTPUT ! If it has, then be sure that any Midi-thru option is disabled. CUBASE Using with Cubase for Windows, MusicStation and Cubasis: Since Cubase allocates all MIDI-Inputs and Outputs by default, you must download the MROS-MME setup-utitlity from ftp://mcc.ac.uk/pub/cubase/updates/Windows/set_mme.exe (upl. Feb 95) This utility comes from Steinberg, but I don't know if it's included in the current releases of Cubase/Cubasis/MusicStation. It can de/activate, sort and even rename (inside Cubase) the available MIDI ports. To avoid midi-thru problems, enable only LB1 for input and only LB2 for output. Cubase will hang on startup if it one Node is activated as In- and Output. I have tested following Sequencers: Cubasis Demo, MusicStation Demo 1.1, CubaseScore1.1 : Require all SET_MME ! Cubase 1.0 (the unstable, but not-copy protected version) requires SET_MME+newest MROS.DLL and drivers, but the ports can only be seen as numbers then. I had no problems with: Cakewalk 3.0 Demo, WinJammer 2.3, Passport Trax, MidiSoft Recording Session, WinSysEx 3.0, TTS Virtual Piono, MidiKeyb, ....... I was able to synchronize demos of SoundForge 3.0, SAW and Samplitude Studio with Cubase, I could record from Cakewalk to Cubase and vice versa. I couldn't get any sound out of a MicroLogic demo (seems to be fixed to first MIDI port). CTL3D.DLL midlpbk.dll uses ctl3dv2.dll for their dialogs if installed. _____________________________________________________________________________ History: V 0.x Jan 94 : 1st working version, but nearly unused due to Cubase problems. V 1.0 Feb 95 : first upload (Steinberg released set_mme-utility) V 1.1 Code segment made fixed. MidiOutShortMsg can be reentered 4 times now (should be enough) Device Names can be edited in system.ini V 2.0 Jun 95 : Multi-Client version. Remove all beautiful features (no more necessary). Source splitted in fixed- and discardable code. Packaged with HWMDCABL.EXE V 2.1 Aug 95 : Fix for SB16 with TB-Rio, IN- and OUT- names can be different (required for TB-WavePatch - see wfpatch.wri ) V 2.2 Oct 95 : dynamic load of Ctl3dV2.dll, only if installed. ------------------------------------------------------------------------------ Future enhancements: If no-one finds a bug, it's the FINAL RELEASE (see end of document for email address) WHAT OTHER PROGRAMMERS CAN DO : I think it should now be easy for musical programmers to enhance their system with small MIDI utilities, like random note generators, midi message translation applications, problem specific input dialogs (VB is a good language for this). What do you think of something like an MCI-Sequencer? It could play Sounds, Videos and Animations synchronous to your MIDI files (something like the MCI commands in Cakewalk). Or a MIDI-triggered WAV-player ? I've tried one using Microsoft's WAVEMIX.DLL, but I'm not happy with timing and quality. It should be possible to MIX up to 16 Channels with volume and pitch control at 44kHz 16Bit Stereo (most MOD-Players can do this!). Or a MicroPhone to MIDI converter ? ------------- Win95 : I have neither a compiler nor a SDK for Win95 nor Win95á nor any MIDI app that strictly requires Win95. My money would be better invested in a good MIDI-Keyboard with Aftertouch (polyphonic??). Note: In the documentation of version 1.1, I said that the MMSYSTEM design of Microsoft would not allow full featured multi-client drivers. I was wrong. It was indeed very simple to implement it. As a hobby programmer, I can't afford MSDN Level 1 or 2, so I'm always behind in getting information (I had to do some disassembling). But I don't know why Microsoft has not impelemented this very useful feature in their own drivers and their DDK SoundBlaster example. BTW, I've bought a Microsoft Home Mouse. It contains some funny programs for modifying the Windows-cursor. After installation of the 2 floppies, one of the directories contains 457 cursor files with 326 bytes length each. But if you install this onto a harddisk partition with more than 1 GB, 15 MB of your C: drive is occupied (a 32 kB cluster per file). What I want to say is, only Microsoft is able to copy 15 MB uncompressed to a floppy. ______________________________________________________________________________ Undocemented features: WIN.INI: [Hubi's MIDI cable] SysExSize=1024 Use3D=1 SYSTEM.INI: [midlpbk.drv] Use3D=1 ______________________________________________________________________________ The following programs should be available at the same where place you got this file. I've uploaded them to ftp.cs.ruu.nl/pub/MIDI/PROGRAMS/MSWINDOWS Simtel and CICA will follow MDUTLS10.ZIP : MIDI_MON: "MIDI MONITOR" - show received MIDI messages, (with SysEx!) MIDICONN: "MIDI CABLE" - simple MIDI Thru application (with SysEx!) SYX_OUT: an Iconized-Application for sending .SYX dumps to Synthesizers, with File Manager Drag and Drop Interface. ==> The file hwmdcb.dll in mdutls10.zip is an older version of the one included in mdlpbk20.zip. Please replace the old with the new one to avoid problems. Also MIDICONN.EXE is superseeded by HWMDCABL.EXE. MDJSTK10.ZIP: MIDI-Joystick. Use a PC-Joystick as MIDI controller. X,Y and 2 Buttons configurable. HWSIMSAM.ZIP: Hubi's Simple Sampler. Load a .WAV file Into memory, play it as MIDI intrument (w. pitch transpose and volume control) HWMCICOM.ZIP: Hubi's MCI Commander, Execute MCI commands by MIDI. ______________________________________________________________________________ About the author: Dipl. Ing. Hubert Winkler Neunkirchner Str. 17 A - 2732 Willendorf Austria Email: winkler@cobra.gud.siemens.co.at (office)