Tutorial: Near zero latency MIDI output on Windows

Trouble with Synthesia, your keyboard, or adapter? Think you found a bug?
When describing problems, always mention your OS and game version (shown at the bottom of the title screen).

If your keyboard has USB or MIDI ports, there is a tremendously high chance (>99%) it will work with Synthesia. See what you'll need on the keyboards page.
Vages
Posts: 4

Post by Vages »

As many users know, one of the troublesome things with Synthesia on Windows is the software MIDI latency. I get really high latency when I use MS GS Wavetable Synth, no matter if I use the software keyboard or my hardware keyboard (a Behringer UMX49, but I recommend buying a UMX61 or UMX610 because of their less limiting size). When I was using XP, this wasn't as much of a pain in the butt, because I could reduce the latency, or lag, with an old Yamaha software midi synthesizer. I couldn't get the softsynth to work with Windows 7, so I was stuck with high latency, experimenting with the Timididy++ driver and getting marginal improvements.

I came up with this solution by chance. It's completely free and will require you to install two or three programs, but once you're done, you're left with a lot of freedom regarding sound - and hopefully near zero latency. My computer isn't excactly buff; it's an HP Compaq 6710b from 2007. It runs Windows 7, but I can't think of any reason why this won't be compatible with XP or Vista. In other words: This'll almost certainly work, with nearly no hassle.

Don't be scared by the lenght of the tutorial. I prefer explaining in detail to getting questions, and I guess you prefer reading one tutorial to skimming a forum thread.

THE PREMISE
We're going to make Synthesia send the MIDI signals to Nerds.de's LoopBe1. This program will send the signals on to a digital audio workstation of your choice, but I've chosen Image-Line's FL Studio Demo version in this case because it's free, simple and will work for an unlimited time. We will also install the latest version of ASIO4ALL, a low latency audio driver.

THE DOO-DOO GOES DOWN
  1. Download FL Studio. This demo version will last forever; the only limitation is not being able to save your projects. That won't get in our way. (The full version is cheap, user friendly, and once you purchase a licence, it lasts for the rest of your life.)
  2. Download LoopBe1.
  3. Download ASIO4ALL. This is bundled with FL Studio, but new versions are put out from time to time, so download if it's newer or if you want one in your own language.
  4. Install them all. As for FL Studio, there are plenty of instructions out there on how to go through that process - and it should be self-explanatory.
  5. LoopBe1 should be working out of the box.
  6. Open up FL Studio. You'll be treated with an introduction; I've never stayed for the entire performance.
  7. Make a new, blank project by clicking "File" > "New". Go to the step sequencer (there'll be an instrument labeled "Sampler" there).
  8. Right click the "Sampler" instrument, go to "Replace" and choose FL Keys, which is the piano instrument.
  9. The piano will appear as an instrument in the step sequencer, and the little green light to its right will be on. If the virtual keyboard pops up, you can try clicking the keys. The green light to left of the "Keys" label and its two knobs should also be active; this light tells you that the instrument isn't muted. The green light to the right tells you that the instrument is active, i.e. being visible and receiving all signals. If you're now getting sound, you could skip to step 11, but then you won't get maximum results.
  10. Here comes the part where we try to reduce the latency to its minimum. However, ASIO4ALL isn't compatible with a lot of sound cards; I have trouble getting it to work with certain computers. Without it, you may still achieve acceptable results with the primary sound driver. If the following steps don't work or give no result, just turn things back to the way they were, and continue with step 11.
    1. I have problems with ASIO when other programs on the PC output sound, so before you continue, turn off every program that might possibly output sound: Games, web browsers, music players - even the stuff in your system tray and that machine that goes "Ping".
    2. Click "Options" on the toolbar and click "Audio settings". Set the option for "Input/Output" to "ASIO4ALL v2".
    3. Try clicking the keys on the piano instrument in the main window. Does it produce good sound with low latency? If so, fine! Go on to step 11. If there's no sound or the sound's crummy, read on...
    4. You'll have to tinker with the ASIO settings to see if you can get things to work. Start by clicking the "Show ASIO control panel" below the setting you just used.
    5. This'll open up the control panel (as expected). If your sound is metallic and distorted, you should drag the "Buffer Size" slider to a the right. This'll give your computer more time from the signal is received until the audio comes out of the speaker. This'll increase latency a bit, but the effect is marginal - and tolerable. On the "Audio settings" screen, there'll be an "Underruns" counter right below the "Show ASIO panel" button; underruns are the pieces of information your soundcard haven't had time to process. The lower, the better.
    6. If you get no sound at all, press the wrench icon. This'll open the advanced controls. Press the "+"-button next to the audio device on the left (if it is detected - if it's not, just give up this part, turn things back and go to 11).
    7. The audio devices might be marked with green "play" icons. If so, go to the next step. If not, you might have some success with just clicking the power on/off-icon next to them and see if they turn green instead of red X-es or yellow Venus-emblems. If this doesn't work either: Are you completely certain that you have turned every other sound producing application off? This includes Synthesia itself, Spotify, iTunes, Wimp, IMs... Perhaps you'll even have to open the task manager and kill the processes completely. In the worst case, you can even try rebooting your computer. If you get two green lights, or at least a green light on the "Out"-device (the "In"-device is rarely the problem, and not necessary for now), you can continue.
    8. Press the piano keys to see if you're getting sound now; perhaps the tinkering worked? If this didn't work, it's time to go to use the last tricks: There are a few checkboxes on the right (when you've pressed the wrench-icon) which might give some results, and a slider. Try clicking these. I have the two bottom boxes checked and the "Buffer Offset" to 4 ms.
    9. If things don't work now, ASIO4ALL is probably not for you. There might be a specific driver for your sound card, but this is a bit rare. Don't lose hope, you can still use Synthesia with FL Studio. Just switch back to the "Primary Sound Driver" in the "Input/Output" setting on "Audio Settings" screen.
    10. If things did work, you can adjust the buffer size to get the best balance between underruns and latency, as described in step 10.5.
  11. Now we're going to set FL Studio to receive the signals from LoopBe1. Close the ASIO settings if you haven't already and click "Options" > "MIDI Settings", or just the MIDI panel in the left sidebar if you're in the audio settings.
  12. Under "Input", you'll see "LoopBe Internal MIDI". Left click it, and then click the "Enable"-button below the frame. It should turn yellow, and an "Active"-marker should appear to the right of the device. Done! (If you have a MIDI keyboard that you are supposed to use, now is the time to plug it in and turn it on. Click rescan in the bottom of the window, and if it appears, make sure it's not enabled, as this may clash with Synthesia getting signals from it). Close the settings window and the ASIO control panel .
  13. Click the Keys-instrument in the step sequencer window so that it's active. You can now open Synthesia.
  14. Click the Keyboard Settings, and choose LoopBe Internal MIDI as the output device. Test it, and if it gives sound output, you're done!
I hope this worked for you. You can, of course, experiment with other instruments for the output, but I'll not go through the trouble of explaining that. Practically, you can get any virtual instrument you'd like to play the Synthesia output; TruePianos is an incredibly realistic virtual piano that you can add to FL Studio. If this worked, it'll be nice of you to leave a comment and/or Flattr me; this'll keep the tutorial bumped for others to see - and also give me a warm, fuzzy feeling inside.
Vages
Posts: 4

Post by Vages »

Yes, the second I posted this I went to the FAQ section and saw that it had been added since I last checked it. I was ready to be disappointed and have my lengthy tutorial ridiculed - and prepared to come up with some apology :D

I just tried it and (I'm sort of glad to say) I didn't get nearly as low latency with BASSmidi as with this method - and I was prepared to admit that the other method was better ;-) I'm still going to use this all the time.
kickininthefrontsea
Posts: 39

Post by kickininthefrontsea »

I'll try this, BASS midi wasn't good enough for me,
I output the sound through the keyboard for zero latency, but having more samples would be good
User avatar
RichNagel
Posts: 70

Post by RichNagel »

Vages wrote:I just tried it and (I'm sort of glad to say) I didn't get nearly as low latency with BASSmidi as with this method
Less than 0.052 seconds (scroll down to the pic "BASSMIDI Driver v1.06 Low Latency" on this page -> http://www.cmoo.com/snor/weeds/SoundFon ... XMPlay.htm)?

Note that measurement is using the older version 1.06 of the BASSMIDI Driver though... the newer versions of the driver suffer from a lot more latency (as can be seen in the pic below the afore-mentioned one).

The "0.052 seconds" measurement was performed on my current rig, a relative antique by today's standards (an Intel single-core P4 2.666Ghz, with 1GB RAM).
Vages
Posts: 4

Post by Vages »

RichNagel wrote:Less than 0.052 seconds (scroll down to the pic "BASSMIDI Driver v1.06 Low Latency" on this page -> http://www.cmoo.com/snor/weeds/SoundFon ... XMPlay.htm)?

Note that measurement is using the older version 1.06 of the BASSMIDI Driver though... the newer versions of the driver suffer from a lot more latency (as can be seen in the pic below the afore-mentioned one).

The "0.052 seconds" measurement was performed on my current rig, a relative antique by today's standards (an Intel single-core P4 2.666Ghz, with 1GB RAM).
I don't have an exact number for the latency, but this method gives me results that are more than satisfactory to my needs. In addition to that, I'm able to get much greater sound quality from FL Studio than I've ever been able to using drivers - though I don't doubt it might be achieved if you find the right soundfont. But when I think about it, FL Studio is designed with live playback in mind, and as a very successful commercial product, I doubt that the program yields anything but the best results; the latency is probably very low.

The problem with most of those drivers, for me, is that in order to achieve maximum results, you'll have to tweak, modify .cfg-files and change cryptic parameters in random files. If someone's fine with that (and I see that you have more experience with computers than me, and probably are) that's OK, but I - as, I guess, most of the other Synthesia users - am tired of that, and I'm a guy who likes computer stuff. Even though this method involves running two programs at once, I feel it's simpler and more sleek. However, I wish Microsoft would just solve this problem by shipping a better built in synth, like Apple does. No tweaking for Synthesia users on Mac!
Nicholas
Posts: 13135

Post by Nicholas »

Vages wrote:No tweaking for Synthesia users on Mac!
That is true. (And I'm jealous because I'm primarily a PC user...)

But, the iPad doesn't have any synth at all. And if I'm going to be making the iPad version soon -- and I am ;) -- I'm going to have to solve that problem. My hope is that whatever solution I come up with will be applicable to the desktop app too. At least the Windows version, anyway. The ultimate goal would be ultra-low-latency SoundFont support built directly into Synthesia with zero configuration. We'll see how close I get. That's still a few months away though.

EDIT: Oh yeah, this method looks pretty good. I didn't realize there was a permanent trial for FL Studio. One of the things I'd struggled with before was finding some app that was free that you could snap SF2 files into.
Vages
Posts: 4

Post by Vages »

However, now that I'm testing it again, BASSMIDI gives better results. And I've found one great annoyance with "my" method; the metronome feature sounds awful - because all signals are sent directly to the piano instrument, the wood block hits sound like piano notes. Try to imagine "Row, row, row your boat" in the style of "Phantom of the Opera".

I'm actually changing my mind; I recommend Bassmidi, and this method more as an experiment - unless you're not in need of a metronome ;-)
Nicholas wrote:But, the iPad doesn't have any synth at all. And if I'm going to be making the iPad version soon -- and I am ;) -- I'm going to have to solve that problem. My hope is that whatever solution I come up with will be applicable to the desktop app too. At least the Windows version, anyway. The ultimate goal would be ultra-low-latency SoundFont support built directly into Synthesia with zero configuration. We'll see how close I get. That's still a few months away though.
Nice! I'm using Garageband on the iPad, and it's possible to connect a hardware keyboard using the camera connection kit - I hope this'll be possible with Synthesia on the iPad.

There's a lot of apps using piano sounds from before; perhaps there's some toolkit?
Nicholas
Posts: 13135

Post by Nicholas »

Vages wrote:... it's possible to connect a hardware keyboard using the camera connection kit - I hope this'll be possible with Synthesia on the iPad.
It will be. I already have a camera connection kit to test against when I start my development.
Vages wrote:There's a lot of apps using piano sounds from before; perhaps there's some toolkit?
It's still sort of the wild west out there. Toolkits are few and far between... and when they do exist, they're thousands and thousands of dollars. ;)
Lemo
Posts: 313

Post by Lemo »

Lol that would have been a good idea to check the rest of the forum indeed, before presenting a method as revolutionary and linking to a Flattr account...

Creepy stuff

Anyway, concerning the soundfont support Nicholas, did you think about BASS directly?
Even I managed to run it, while I'm not a developer :p
They seem to have a cheap license (125€) for commercial stuff below 40€
Stuff & experiments for Synthesia: Gramp v0.2SkinboxFireSynthVideoWebradio
Nicholas
Posts: 13135

Post by Nicholas »

Lemo wrote:did you think about BASS directly? ... They seem to have a cheap license (125€) for commercial stuff below 40€
125€ per platform. I'll be using three platforms here pretty soon. (Regardless, that's still pretty low-cost for a good library like BASS.)

I'm not sure though, their BASSMIDI add-on doesn't seem to have an iOS version at the moment. And BASSMIDI itself is more about loading entire songs and playing them as a stream (the same way they do everything else) vs. sending individual notes the way Synthesia has to due to its nature.

I'm sure it might be a derailment for a while, but I've been thinking I want to learn more about soundfonts anyway. At least then I know I'm getting something that will be tailor-made to Synthesia's needs. Most-likely fast too because I'll have my very specific use-cases in mind the whole time.

I understand that the more I can rely on other people's code, the faster Synthesia will be finished, but I have a nasty tendency for reinventing the wheel. I mean, take a look at that abomination of a UI. ;)
Lemo
Posts: 313

Post by Lemo »

Yeah I don't see any specific bassmidi download for ios, but apparently it works
Also when the stream is loaded, they have a function to retrieve individual events info in sync (not sure if that helps in your case though)
But of course if you can craft everything as you like, I guess it's better indeed :]
Stuff & experiments for Synthesia: Gramp v0.2SkinboxFireSynthVideoWebradio
User avatar
RichNagel
Posts: 70

Post by RichNagel »

Vages wrote:I'm actually changing my mind; I recommend Bassmidi, and this method more as an experiment
Hehe, 'you will be assimilated... resistance is futile' <grin> :)

Anyhow, the BASSMIDI Driver seems to be a lot easier to install and set up, and doesn't require any virtual MIDI patch cables as well.

Like you said though, as with any SoundFont compatible softsynth, your sound quality is limited by the choice of SoundFont that you're using. Although, folks like myself would re-word that to say 'unlimited by the choice of SoundFont :) There are a lot of nice sounding freeware SoundFonts available out there (as listed on this page -> http://www.cmoo.com/snor/weeds/SoundFon ... ration.htm ).

BTW, I'm sure that you prolly discovered that with the BASSMIDI Driver, there aren't any config files (other other tweaks) that need to be twiddled with... simply install, select SoundFont, and go :)


(edit) @All, BTW, something that y'all (Yamaha XG softsynth fans that are running Vista/7) might find interesting/of use -> http://www.vgmusic.com/phpBB3/viewtopic ... 16&t=14162 :)
User avatar
DC64
Posts: 830

Post by DC64 »

The VST driver is pretty good, (I use it) the downside is you need to find the correct dll. extention to play sound.
When you do find the right one it works.
"And now for something completely different."
MrGKB
Posts: 1

Post by MrGKB »

Thankyou so much! I was searching all day for an answer to the latency problem, the level of detail in your tutorial was so helpful! Thanks again :D
Lemo
Posts: 313

Post by Lemo »

Maybe you want to read the rest of the topic for a better setup... ;)
Stuff & experiments for Synthesia: Gramp v0.2SkinboxFireSynthVideoWebradio
AH15AH
Posts: 1

Post by AH15AH »

After many searches i saw this:

AudioLink Series MIDI-to-USB Cable ALESIS --> http://www.alesis.com/print/print.php/217379

obviously as per the reviews better than the M-AUDIO....anyone had the chance to try it?

thanks,
xefil
Posts: 1

Post by xefil »

hello!

I'm trying to learn playing a little the piano and would like to test Synthesia software. I've noticed the delay between pressing the key and the audio, also I've followed your great tutorial.
Here my setup:
- Synthesia software
- USB2MIDI adapter
- Casio CDP-100 (both midi-in and midi-out connected to adapter)
I've had some initial issues because I've worked always with the USB2MIDI adapter already connected. As written in your tut, it must be connected only at step 12. So, now it's working.
In Synthesia software I've the this setup:
INPUT Device: MIDI2USB
OUTPUT Device: LoopBe Internal MIDI
I've only some questions/doubts:

1. it's normal the sound choosen in FL Studio is different from the one comes from the Casio? I explain: In FL Studio I choose a piano type (Rhodes FL) from the PC speakers I can hear the right sound. From the CASIO I obtain the default sound. It's not a problem. I can mute the piano and then listen the sound only from the PC speakers. Only to know if it's normal

2. A little off-question. You've suggested to use TruePianos or other instruments for the output. I've tested the demo version and sounds incredible! What does it mean I can add it to FL Studio? In case do I need to have open FL Studio and TruePianos to play with Truepiano sound and play/learn with Synthesia?

Sorry for maybe simple/stupid questions, but I'm really new to this world (as well as on piano) :)

Thank's a lot!

Simon
chills
Posts: 1

Post by chills »

I believe I followed all of your instructions to a "T" but still have bad latency. It is frustrating because when I first downloaded the program and used it with the coolsoft midi everything was working great. No latency at all! Then after a few uses the latency hit and, so far, I have not discovered a way to reduce it all. :x Thinking of deleting everything and starting over since I know it all worked once. However, since I it stopped and I ended up here, I thought maybe you could help me fix it so I don't just end up back here and even more frustrated.

Thanks!!!
User avatar
jimhenry
Posts: 1899

Post by jimhenry »

If you started with low latency and then it increased without you changing anything in the sound synthesis, then I'd suspect some background program sneaking in and stealing cycles.
Jim Henry
Author of the Miditzer, a free virtual theatre pipe organ
http://www.Miditzer.org/
Post Reply