Lag/Delay in LMMS when trying to play with a keyboard (MIDI)

Having trouble with LMMS? Ask about it here.
Bad quality cables and connectors are always a problem. The comment on length was just the physics of it all.
As long as the connectors used are made to meet the standard they should not be an issue. Having said that going out an buy a $100 USB cable is really just throwing money away. I use some kind of $5 cable to run two external monitors on USB-3.

Bad cables causing latency makes sense. If the electrical connection is bad and the connector is out of spec it can cause reflections and lost data.

No idea as to why there is latency with MIDI on Win. Read somewhere that it had to do with which clock is used to synch communication . Also saw a note that Steinberg had its own drivers for MIDI that wasn't compatible with WIndows default drivers causing Windows to emulate the driver.... or something. This was with Cubase.
I'm also currently fighting with this on a Win7 laptop. In fact LMMS isn't too bad with the buffer size anywhere below 256K the latency is something I can only just detect and can more or less live with. But I've also tried recording MIDI with other programs like Anvil Studio and the lag in there is terrible (I estimate over half a second). Same keyboard, same cables, everything else the same. Since the onboard sound is RealTek with no ASIO support I'm about to try ASIO4ALL to see if that helps.

There's an interesting article about sorting out sound on Win7 on the Native Instruments website ... rocessing/ that I'll work my way though if ASIO4ALL doesn't do it.

The Windows 8 equivalent (looks almost identical) is ... rocessing/ May be worth a read.

C_H wrote:From an electrical engineering standpoint I can't really see why a long USB cable in itself would or should add to the delay. The electromagnetic wave in a copper wire travels at about 95% of the speed of light so a few feet is not going to add 1.5ms delay.

This must be a driver issue of some sort.

Just a reflection.
Why should there even be problems with MIDI latency? MIDI is a very slow interface from the beginning of the 80's running at a meager 31.5kbaud. A 9MHz Atari ST could handle that with ease but the 64-bit multi GHz monster machines of today cant... something went wrong somewhere.
Back in those days, some one told me they had lag issues (atarist)
The solution as far as I remember was not to use too much midi trough, but some midi hub.
mikobuntu wrote:...Another thing I'm unsure of the actual USB Midi cable the OP is talking about, but I know from experience that those cheap MIDI 5 pin to USB connectors def have a latency issue no matter what the settings are on the software, but direct USB to USB midi should be fine I guess.
I think I got it a few years ago, haven't used it much at all. It's about 15 feet long and has two different types of USB connections. One side's USB type A, the other is type B ( ... fd23b1.jpg )

I think this is it: ... +usb+16+ft

So from what you guys are saying, perhaps I should hold back on buying another cable right now?
I am in no way and expert on MIDI and sound equipment in general so leave it at that.
The comment was purely from an engineering and physics background. As long as the cable and connectors are not damaged and built to spec the length should have minimal effect. The difference in signal delay between a 2-3 ft cable and 15 ft cable is in the ns (nano second) range which is a millionth of a ms (milliseconds).

Now if the cable and/or connector is damaged it can cause an electrical mismatch in impedance and this in turn leads to reflections which in turn leads to loss of data. Just look at data transmission over RS-232. It is possible to use very long cables but the data rate will have to be dropped.
Even USB-1 is about 1000x times faster than MIDI. It just speculation on my part but it just has to do with the way the OS works. Windows is not a Real-Time OS in any way and music production kind of is a real-time activity.

How is the latency on Linux and Mac? There must be a reason the Mac is a common and maybe even a preferred platform.
You may want to try
I'm afraid if you are stuck as the Realtek chipset doesn't have a dedicated ASIO driver.

This will give you the ASIO interface but not necessarily the low latency that comes from using a dedicated ASIO driver. This is because Asio4all is more a interface "wrapper" than an optimized driver - it fools the system into thinking there is an actual asio driver for your card there (but it works).

However, minor tweaking is possible with it such as buffer sizes and adjustment of internal latency to get most out of your ordinary drivers which is use in the end. I recommend to test different settings here, playback and adjust again to find the optimal settings for your setup.

What this means is that it (Asio4All) can help with the problem, a little, hopefully enough to make playing the keyboard less annoying.

The greyed-out box just indicate that Sibelius is looking for an ASIO option but doesn't find it. This will change with Asio4all installed.

Another Thought:
With the Windows operating system, there are too many variables that can cause latency. From drivers, or even the incorrect drivers installed. To malware, and incorrect registry entries.
The list can keep going.
I think that's one of the reason's I gave up windows, and went with Linux.
Along with Microsoft's planned obsolescence. That keeps you buying new software, and hardware every few years.
Windows aren't made for performing live audio as some linux kernels, but if FL studio and other DAWs manages to decrease the audio on the OS then it is possible.
This thread might have died and moved on but..... anyway, here is an article from Sound On Sound about MIDI latency. It's +10 years old but still valid. ... an1002.asp
Hi Guys,

The lag/delay between the time when you press a key and you hear a sound is called LATENCY.

Latency has *nothing* to do with MIDI, and nothing to do with the length of your cables.

Latency is given by the buffer size your audio program uses to talk to your soundcard, in order to produce sound.

Simply put:
latency [miliseconds] = buffer size [samples] / sampling frequency [kHz]

For example:
If buffer size is 256 samples, and sample frequency is 44.1 kHz then latency = 5.8ms = 256 / 44.1

Less than 10ms latency is good enough for realtime audio for keyboards. Drum players will notice a latency in the 3ms-5ms range.

In order to decrease latency, the only thing you can do is to lower your audio buffer size.
Now this is where the audio software, audio drivers and hardware comes in:

Your system has to be able to fill up the buffer fast enough, or you'll notice cracks and artifacts in the sound (caused by playback discontinuities).
This means the software application needs to be able to talk to the soundcard as fast as possible.
On Windows, the only platform specifically designed to provide real-time audio is ASIO!
That's why you should use software capable to talk to ASIO drivers, and have hardware with dedicated ASIO drivers.

For hardware which is not designed for music making / realtime audio, there is a hack driver called ASIO4ALL. This can have better or worse performance depending on your actual hardware.

As far as I know, LMMS for windows doesn't have native ASIO support!
However, the latest builds of portaudio do have ASIO support in them.
The solution to make LMMS to support ASIO is to replace a dll file from the location where LMMS was installed to a newer one.

Old dll, which has to be replaced is called (located probably in C:\Program Files\LMMS or equivalent):

New dll, can be downloaded here, depending if you're running in 32-bit or 64bit:
Here you can download either:

You have to download the dll corresponding to your LMMS version (32 or 64bit) and overwrite this to the original libportaudio-2.dll

Now if you choose portaudio as Audio Interface in LMMS, you should have access to the ASIO drivers installed to your system.

From there, if you have a hardware dedicated ASIO driver (like for a USB interface) use that.
If you have a generic Realtek soundchip, then install ASIO4ALL, the latest version, and use that.

Lower your buffer size to the minimum so that you don't hear audio artefacts, and then you can be sure you have the lowest possible latency.