new version of midibridge supports midi out

Deprecated, please Chris Wilson’s WebMIDIAPI Shim

The midi bridge has been updated and midi out has been added. This version works on all platforms.

Windows: No known issues

OSX: Only Safari is supported. If you are on 10.5 please install Java update 6, if you are on 10.6 install Java update 1. You don’t need Humatic mmj anymore. More info on humatic.de and on apple’s developer site, scroll down to Java Sound.

Linux: Konqueror is not supported

I made a sample app that you can see over here:

http://abumarkub.net/midibridge/v3/

Code is available in several versions:

Please report back to me if it doesn’t work on your system.

About midi out

Now that you can select a midi out device, the problem with latency arises. Unless you’re on a Mac. On a Mac you can just select a default midi synthesizer (Java Sound Synthesizer) and start playing with no noticeable latency.

If you’re on Windows or Linux, the latency of the Java Sound Synthesizer makes it almost impossible to play. On Windows you can also choose the Microsoft GS Wavetable Synth and with some soundcards you may get a decent latency (i was told the Realtek AC97 perfoms pretty well).

Latency is caused by both the drivers of your soundcard and the way your synthesizer works. Most modern softsynths hardly cause any latency, but even with the latest M-Audio pro cards you’ll experience latency when using the Java Sound Synthesizer or the Microsoft GS Wavetable Synth.

So we need to be able to connect to some real softsynths like Pianoteq or Lounge Lizard and for this we need a virtual midi driver.

If you’re on a Mac, you’re lucky again because such a thing is already installed on your machine. It is called IAC Driver and you’ll find it if you open the Audio MIDI Setup in your Applications folder.

If you are on Windows you can download LoopBe1 from nerds.de and Linux users can check VirMidi

Below i’ll give a brief explanation for every driver.

LoopBe1

Download it from nerds.de and run the installer. After the installation has finished LoopBe is up and running and will automatically start with Windows (if you don’t want this, run msconfig and remove the LoopBe startup service).

Now if you refresh or load my sample application you should see LoopBe Internal MIDI appearing in both the midi inputs drop-down box as well as the midi outputs drop-down box. Choose your favorite keyboard for input device and LoopBe Internal MIDI for output.

Now open your favorite softsynth and go to the midi settings and set your synth’s midi input to LoopBe Internal MIDI. Here is a screendump of what this looks like in Pianteq:

Pianoteq-LoopBe-Abumarkub-midibridge

You should now be able to play your softsynth while midi data is passing thru the midibridge, and dependent on your soundcard’s driver, with very low latency.

Please notice that LoopBe1 is only free for non-commercial use. For commercial use you need to acquire a license after a 30-day evolution period. But for only € 11,90 inc VAT it’s really a bargain. Check here.

IAC

Open your Finder, go to menu Go -> Applications and scroll down till you’ve found a folder named Utilities. Open the folder Utilities and double click on Audio MIDI Setup. If you only see a window with Audio Devices, go to Window -> Show MIDI Window.

In the window that subsequently opens, you should see an icon named IAC Driver. IAC stands for Inter-Application Communication, and that is exactly what it does.

If the icon is greyed out double click it and check the box “Device is online” in the popup that appears. Now you should have a window like:

IAC-Driver-Abumarkub-midibridge

Don’t worry if looks a little different on your machine. You should see at least 1 port in the “Ports” part of the screen. If not, simply click the plus sign to add a port. I recommend to add a least 2 ports to the IAC Driver.

Now close this popup and the Audio MIDI Setup and refresh or load my sample application. Now you should see LoopBe Internal MIDI appearing in both the midi inputs drop-down box and the midi outputs drop-down box.

Choose your favorite keyboard as input device and LoopBe Internal MIDI as output. Open your favorite softsynth and go to the midi settings and set your synth’s midi input to LoopBe Internal MIDI. Here is a screendump of what this looks like in Lounge Lizard:

Lounge Lizard IAC input Abumarkub midibridge

Now you can play your softsynth while midi data is passing thru the midibridge.

VirMidi

If you are using Ubuntu or Kubuntu, there is a thread about VirMidi on the Ubuntu forum

Because snd-virmidi is a kernel module, you can simply load this module by typing
sudo modprobe snd-virmidi
on the command line.

Now if you refresh or load my sample application at least 4 additional devices should have been added to the drop-down boxes.

Open the midiconfiguration of your app and choose your keyboard for input device and one of the virtual midi ports as output. Connect this output to the input of your favorite softsynth, for instance in Pianoteq this would look like:

VirMidi Kubuntu Pianoteq midibridge abumarkub

Now you can play your softsynth while midi data is passing thru the midibridge.

Pianoteq is available for both 32 and 64 bits Linux, so if you want to try it yourself you can download a demo version over here.

Onwards

Unfortunately the bridge won’t work on Konqueror until this browser supports Live Connect; communication between Java applets and Javascript and Flash applets and Javascript.

On OSX, browsers that rely on the Java Embedding Plugin such as Firefox, Camino and Seamonkey are not supported either. This is because of something really weird. In Firefox an applet gets loaded twice and therefor (or for some other reason) JSObject.getWindow(this); returns ‘null’ so the connection between Java and Javascript is cut off.

I am gonna look into this asap but should you have and suggestions please mail me!

17 Responses to “new version of midibridge supports midi out”


  • Great Job!
    I have tried it with Firefox 3.6.2 and it works good.

    If you want to reduces latencies in Windows XP, specially if you use Pianoteq, install ASIO4ALL (http://www.asio4all.org). It’s an ASIO driver that works with any WDM sound card (any cheap onboard sound card), it works amazing. Thanks for the code, I will modify it to show the notes on a score. My 7 years son is having piano lessons.

    Claudio J. Pérez from Argentina

    • Hi Claudio,

      Thanks for the tip; ASIO4ALL is really great!!

      I can play Pianoteq now thru my cheap onboard soundcard with only 5.8 ms latency.

      Sad enough the latency of the Microsoft GS wavetable synth doesn’t improve with ASIO4ALL.

  • Really cool stuff man.

    I wish i could get it to publish properly.
    In Flash Professional CS4 it sais it has a migration issue because the Button Event Handlers weren’t declared properly.

    But I would really like to get it to work in Flash Builder 4. I get an error that it can’t load the ComboBox.swc

    I’d appreciate any tips to get it to work. Or a Flex Project if you have it.

    • The code is done in Eclipse with FDT. ComboBox.swc contains the CS4 version of the ComboBox component and is added to the classpath of the project. You can easily replace this with the FB4 ComboBox element and then it should work.

      However i have also uploaded a FB4 version that you can download over here:

      http://abumarkub.net/bridge-fb4/srcview/index.html

      BTW: If the CS4 compiler comes across a method with the same name as a former AS2 clip handler it automatically assumes that you’ve used outdated AS2 programming techniques and thus shows a ‘migration issue’ warning. If you for instance register an event to a method like so:

      addEventListener(MouseEvent.ROLL_OUT, onRollOut);

      the CS4 compiler gives this warning when it parses the declaration of the onRollOut() method, although this code is perfectly AS3.

  • How are you guys doing with latency issues on input MIDI Hardware devices?

    I’m getting like a half second delay.

    • Are you sure it is an input issue? Usually the latency is caused by the softsynth, hence the output part of the bridge.

      What softsynth are you using?

      Both the Microsoft GS Wavetable Synth and the Java Sound Synthesizer have quite large latencies; this is due to the software it self and cannot be solved by soundcard drivers.

      If you use another softsynth (like pianoteq) in combination with LoopBe and if necessary the ASIO4ALL drivers, you should be able to reduce the latency to 5 ms and less.

  • My apologies, i turned off the output and the animations are reacting right away with hardware input.

    I used Virtual MIDI Keyboard with your app and there is almost no latency even with Microsoft GS Wavetable Synth as output.

    But with hardware it takes about a half second with the output attached to Microsoft GS Wavetable Synth.

    • Most probably this is just the default latency of the Microsoft GS Wavetable Synth on your system.

      You can’t really determine the latency with a virtual MIDI keyboard because a mouseclick is far less sensitive to latency than a hardware MIDI keyboard keypress because a mouse has a lower action than a MIDI keyboard key.

      So probably it seems like the virtual MIDI keyboard has no latency, but in fact it has exactly the same latency as the hardware MIDI keyboard.

      You can check this by connecting your hardware MIDI keyboard directly to the Microsoft GS Wavetable Synth in a sequencer (for instance in Cubase) and then trigger a sound with your mouse and your keyboard alternately.

      Check this site for sequencers: http://www.synthzone.com/midiseq.htm

  • I saw the animation and herd the sound so my mind put together that they were happening at the same time but they weren’t.

  • Hi.

    Congratulations for the project.

    I was very surprised and as happy as Larry when I found this stunning and amazong project.

    I’m gonna try this weekend but for a different reason than music. I’m working in a Flex3 tool for editing online realtime video streams with a Red5Server and it would be very nice to control the streams and the effects with my NOVATION REMOTE ZERO controller (http://www.zzounds.com/item–NOVSLZERO).

    Thanks for your work and for share with others. I’m thinking about to share too my flex app in some opensource stuff.

    • Sounds like a very interesting project!

      Should you have any questions about the midibridge, please don’t hesitate to ask me.

  • Sorry about the link. The Midi controller is this one

    http://www.woodbrass.com/images/woodbrass/NOVATION+REM+SLZERO.JPG

    ThankU

  • Hi!

    I have a question regarding output. Does the signal travel trought java to flash and then back? Or does java just dispatches midi signal to flash, and you can’t control/send midi messages from flash?

    Regards
    Miha

    • Yes, the latter. Currently you can not send midi messages from flash to java. However, this functionality has been prepared and i will implement it in the coming weeks. So stay tuned 😉

  • Thank you for the great work!
    I have been testing the sample and it works perfectly online, but when I doanload the Flash cs4 version (I am running it on Flash CS5) the swf is not able to work, no devices are found!

    Any help

    Thank you
    Tamer

    • That is because the midibridge is a Java applet that has to run in a browser. So if you are working on your flash file you have to test the movie in a browser.

      Another solution would be to point your browser to my online sample and then not connect to any input or output device and keep this browser instance running in the background during development. The movie in your Flash IDE (CS4 or CS5) should now be able to connect to the midibridge that is running in your browser.

  • > However, this functionality [from flash to midi device] has been prepared and i will implement it in the coming weeks.

    Great, great!

    Currently I am using RED5 server, but its MIDI support is not complete (no SysEx messages, no Meta messages)*. If you are going to support it do it fully, please 🙂

    * only ShortMessage is used of three java methods “MetaMessage, ShortMessage, SysexMessage”

    Miha

Leave a Reply