
  Hubi's LoopBack device   Version 2.4                         September 8, 1996
    
 virtual MIDI driver for Windows3x/95 to connect multiple 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 
 Fuse mechanism to prevent MIDI-short curcuit (dumb safe!)
 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
  
  Overview
  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
  
_____________________________________________________________________________

Overview

 The package contains two programs:
 + A MIDI driver, "Hubi's LoopBack Device", which must be installed via control
    panel. The driver offers virtual MIDI Ports (up to 4), which act as Input
    and Output. All MIDI data sent to the output (from sequencer program)
    is delivered to all programs at the input side (eg. a MIDI monitor 
    program).
    
 + A MIDI-Thru application, "Hubi's MIDI Cable", which acts like a MIDI thru
    application. It is useful for quick connections between LoopBack-Nodes and
    Hardware Ports.

_____________________________________________________________________________

Installation

 Unzip to an empty directory

pkunzip a:mdlpbk24 -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. 
 or use WinZip, "Extract" command. 

 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.4", 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(3.1) cannot handle 
more than 10 midiports (+Midimapper). 
After Restart, the new MIDI In and Outputs will be available then. If you have
no CTL3DV2.DLL in your \windows or \windows\system directory (nearly impossible)
then you must install one manually.

Windows 95: 
 Start->Settings->ControlPanel->Hardware
  Continue-> [No] ->Continue -> [ Audio/Video/Game Controller ] ->Continue
   ->Diskette -> [ enter the unzipped directory ] ...



 In case of troubles, try copying the file CTL3DV2.DLL to your windows\system
directory.

______________________________________________________________________________

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.3 is no functional difference, only peripheral
smoothing. Version 2.4 adds a fusing mechanism.
______________________________________________________________________________

 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 merged and sent to all 
IN-clients. Multi-Client means, that each node can have up to 4 IN-clients 
and 10 OUT-clients (hard coded).
Hubi's LoopBack can serve up to 4 nodes, but changing the number of active
ports (=nodes) requires to restart Windows.


 Fuse Mechanism:

The main drawback of pre-2.4 versions was the possible system-hangup on MIDI
short-curcuit. Attaching the same Node as Input and Output of a MIDI 
application can cause circling MIDI messages (w/ MIDI thru). 

 The first invention was:
 +  Do not send the same message twice. 
But to let MIDICLOCK work, a time limit was added, and to allow the generation
of Flanger Effects (all notes played twice - i.e. with two "Hubi's MIDI cable" 
in parallel), a more general formula was used:

 ++ Do not send a Message more than N times within M milliseconds.

 N and M are adjustable in the Configuration Dialog as 
   Duplicates: 
    max    N       (default 1)
    in ms  M       (default 2)

To enable "Flanger effects", N must be setted to 2.
MIDICLOCK (F8 hex) appears 24 times per quarter note, that is every
10.4 ms at 240bpm. Setting M to 10 could eat up some MIDICLOCKs then.


But another "Crash" situation still exist: the Cubase "Reset Devices" command.
It sends Controller Reset Commands on all 16 channels (6 x 16 = 96 messages),
and the "thru" feature would cause a system hangup. This was solved with
following formula:

++ Do not send more than X messages per time period T.

 X and T are adjustable in the Configuration Dialog as 
  Fuse:
   max    X  (default 128)
   in ms  T  (default 100)

The default values seems lower than the MIDI rate of about 1500 per second 
(2 byte messages, i.e. Controller with running status at full use of 31250
baud), but only SysEx transmission uses such a high data rate, and SysEx-Input
in Windows is usually handled with blocks of several hundred bytes.


______________________________________________________________________________

How "Hubi's MIDI cable" works

It's a simple MIDI-thru program with following features: 
- All MIDI processing in realtime (at Interrupt time!)- no Windows/Message delays
- Full SysEx support
- unlimited SysEx Message size
- low resource requirements (I could start it 57 times! -V2.1 in Win3.1 with i/o none)
	  

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 once 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 <Ctrl> key while dragging
	with the mouse).


Filter Option: The filter can be setted only from the command line, there is
        no default setting from ini-settings because of the very
	confusing behaviour if not all MIDI messages go through by default.
	The format is
	hwmdcabl.exe FILT=Channs,ChanMsgs,SysMsgs
	where Chans,ChanMsgs and SysMsgs are a hexadecimal number each.
	
    Chans:
	8000 : Channel 16
	4000 : Channel 15
	2000
	....
	0002 : Channel 2
	0001 : Channel 1

	i.e. to filter out channels 12,11 and 1, use 0800+0400+0001 = 0C01
		FILT=C01,.....      (leading zeros are optional)

    ChanMsgs:
	0100 : Note Off
	0200 : Note Off
	0400 : Poly Key Pressure (key aftertouch)
	0800 : Control Change
	1000 : Program Change
	2000 : Channel Pressure (channel Aftertouch)
	4000 : Pitch Bend
	 
	i.e. to filter out channels 12,11 and 1, PitchBend and Polyphone Aftertouch
		FILT=C01,4400

    SysMsgs:
	0001 : System exclusive
	0002 : Midi Time code (MTC)
	0004 : Song Position Pointer
	0008 : Song Select
	0040 : Tune Request
	0080 : ( End of SysEx - will be received as SysEx or MM_MIM_ERROR)
      realtime messages:
	0100 : Midi Clock
	0400 : Start
	0800 : Continue
	1000 : Stop
	4000 : Active Sense
	8000 : System Reset
      When you hold down the <Ctrl> key while clicking the checkbox, you can 
	send the clicked system message to the MIDI output (have you ever tried
	what reset does ?).

	i.e. to filter out channels 12,11 and 1, PitchBend and Polyphone Aftertouch,
		Midi Clock, Active Sense and MTC
		FILT=C01,4400,4102
	
   All filtered is: FILT=FFFF,7F00,DDCF

   Note: use the "Cmd to Clipbrd" menu item to copy the current settings
        to clipboard (and insert it to the command line of the icon)



Transformation options: (experimental state)
	TRx=mask,trigger,value,func
	with x=1..4, mask, trigger, value and func are Hex numbers
           The hex bytes represent the MIDI bytes.
	
	Example: Transform Midi Controller #5 to Start/Stop messages

		mask=FFFF80	- only MSB of Data 2
		trigger=B00540
		value=FA    (Start)

		mask=FFFF80	- only MSB of Data 2
		trigger=B00500
		value=FC    (Stop)

	... TR1=FFFF80,B00540,FA,01 TR2=FFFF80,B00500,FC,01

	see transform.txt for more examples
	
______________________________________________________________________________

Simple Example Setup:

The symbol >>>> means a running HWMDCABL.EXE instance.

[SB MIDI In]--->>>>---[LB1]---<Cubase>---[LB2]--->>>>--[SB MIDI out]
                     / / \\_<SynthEditor>_// \
           MidiJoy_/  /   \<CakeWalk>____/    \<MidiMonitor>
   virtual Keyboard_/      \<MidiMonitor>

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

(there is a better alternative at 
 ftp://ftp.winsite.com/win3/sounds/multimid.zip  )

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 (V2.x )
  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       [<none>                                   ]   (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

  Midi short curcuit is no problem now - FUSE MECHANISM. 

----------- BEGIN OUTDATED DOCUMENTATION
-
- 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(up to 5.0), 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 and Samplitude Studio with
- Cubase, 
-I could record from Cakewalk to Cubase and vice versa.
-
-
----------- END of OUTDATED DOCUMENTATION

CTL3D.DLL 

midlpbk.dll uses ctl3dv2.dll for their dialogs if installed. If this file is missing,
   dialogs are black/white. If Win3.1 shows an error ignore this.
_____________________________________________________________________________

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.

priv. V 2.2a Nov 95 : Filter dialog with Midi Cable

priv. V 2.2b Jan 96 : Workaround for AWE32 driver bug on close, 

V 2.3 Apr 96 : Fixed a Win95 bug with 32bit Window-Callback

V 2.4 Aug/Sep 96 : Fuse mechanism, Reviewed transform and filter
------------------------------------------------------------------------------

Future enhancements:

 Configurable realtime transformations. 


 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 

 -------------

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. Fortunately I got a MS Multemedia Jumpstart CDROM in a 
      10 pack, which contained information for writing MIDI drivers.
       
      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]
LB1=..
.....
Use3D=1
DupeTime=2
MaxDupe=2
FusePeriod=100
FuseLimit=128

The last 4 match M,N,T and X in the documentation of Fuse Mechanism.

______________________________________________________________________________

The following programs should be available at the same where place you got 
this file. On the internet, look at
 ftp://ftp.cs.ruu.nl/pub/MIDI/PROGRAMS/MSWINDOWS
or 
 ftp://ftp.winsite.com/win3/sounds


  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. 
	        (send email for Joystick2 version)

  SIMSAM10.ZIP: Hubi's Simple Sampler. Load a .WAV file Into memory, play
             it as MIDI intrument (w. pitch transpose and volume control)

  MCICOM99.ZIP: Hubi's MCI Commander, Execute MCI commands by MIDI.
            (HD-recording, CD-Audio, Video, ...) 

______________________________________________________________________________

About the author:

Dipl. Ing. Hubert Winkler
Neunkirchner Str. 17
A - 2732 Willendorf 
 Austria

Email: winkler@cobra.gud.siemens.co.at        (office)
             (If this adress becomes invalid, try <Hubert.Winkler@siemens.at>)
		
My Equipment:

Hardware:
 486DX/2-66/256k/16MB, 540MB, SB-clone (CS4232 chip), 5X-CDROM
  
 Pentium 133 / 256kPB / 32MB , 2.5+1GB HD, ET6000 VGA (2MB), 17"64kHz,
 Toshiba 5602 CDROM (8x, digital output and read Audio CD) 
 AWE32 w/ 8MB, 
 Korg 05R/W at COM2, (sounds great)
 Yamaha PSR300 keyboard (old...). 
 2 Joysticks
 Sony MDR94 Headphones
 Philips Active Speakers (?= all I know is 2x12W, 55Hz...xxkHz)

Software:
 Cubase Score 3.01
 Samplitude Studio 2.5 (Many thanks to SEK'D)
 Band In A Box
 XEdit 3.1 (Shareware Editor for Korg Synthesizers)
 AWave 3.1 (Shareware Sample Converter)
 AWEVbank (Shareware AWE panel)


