I recently made a small project in Unity with NO meshes or lighting, just an empty game object, a few drum sounds and a script with which I am using a PS2 Rock Band drum kit to trigger the sounds. The trouble is, there is a delay from when I strike a drum pad and when the actual sound is triggered. This makes it TOTALLY pointless and literally impossible to try to play a drum beat in any kind of consistent timing.
I know it is not the pads that have the latency because when I look at the game controller config in windows the lights for each button light up with no delay upon hitting them. I have also tested triggering the sounds from the space bar on my keyboard and also my dual shock 3 controller all with the same delay.
Also I HAVE used a small drum program some one made, along with a gamepad to midi utility and I was able to play with no delay at all and even had some successful jam sessions with other musicians so I know for a fact it can be done
I have tried changing the timing in my project to where the frame rate is in the 3,000+ fps range and it still has the same delay.
It seems like immediate response of input would be an essential part of a game engine especially if one was to incorporate fighting systems with combos and counter attacks, or for any kind of musical synchronous game or application. I really hope there is a fix for this otherwise it kind of puts a damper on the overall usefulness of unity.
If any one knows a fix for this I would appreciate it very much.
People make games with Unity all the time, so clearly its overall usefulness isn’t limited. However, it may be more or less suitable for certain types of games, depending.
In any case, I don’t know whether the latency you’re seeing is in the ‘normal’ range, or whether there’s something specifically wrong with your project or your system setup. But, the impression I’ve gotten thus far is that Unity might not necessarily be suitable for music- or rhythm-oriented games. (Note that I don’t know that for sure - it’s just the impression I’ve gotten.)
If you haven’t done so already, one thing you might try would be to test it out in a standalone rather than in the editor (I imagine the timing characteristics are a bit different in the editor than in a standalone application).
What kind of latency are we talking about exactly? Something pathological, like a quarter of a second? Or just enough to be noticeable in a musical context?
Try enabling “Decompress on load”, or a different file format/bitrate for the audio to eliminate this being the source of your problems. Try plain old PCM, like .wav, and turn off any compression or 3d effects. You want the sound file to be sitting in memory uncompressed and ready to play.
This isn’t an input issue, IMO, it’s a delay on playing the sound.
There is no input latency; results happen instantly. You can see this by using input to do something non-audio related, such as turning off an object’s renderer. Probably best not to leap to conclusions.
Just to clarify my previous post, I wasn’t suggesting there’s any input latency in the sense that input events are not processed in the same update in which they occur (or at least the next one). But, I think it’s a given that there will be a delay (no matter how small) between when the drum controller is struck and when the sound begins to play back. This is pretty much always the case with electronic devices, of course - even with a MIDI controller connected to a sound module there’s a delay as the data is transmitted from one device to another. So the question is not whether there will be a delay, but whether the delay will be noticeable. (Just to give a pathological example, say for some reason your application is only running at 10 FPS; in that context, the delay is likely to be noticeable.)
There have been at least a few threads in the past where people have reported difficulties trying to develop music- or rhythm-oriented games in Unity due to limited timing precision. I can’t attest to it directly, as I haven’t tried it myself, but it seems plausible. If nothing else, you’re most likely going to be limited in the precision you can achieve by the update rate, and when it comes to percussion or other rhythmic instruments, even small inaccuracies in timing can be noticeable.
But we don’t know what’s going on in the OP’s case, or course - it could be nothing more than a poorly edited sample (as suggested previously).
Well, you are correct, when I added a light and a plane in the mix, which basically light up when a pad is struck/key is pressed it IS indeed lighting up immediately which means it is not an input delay.
This a huge relief regarding my concerns that fighting and other timing related gameplay would be hindered.
however I’m still getting the delay with the sound…
I originally used .wav(PCM) files but I also tried a copy of the kick drum in ogg format. this brought the file size of the kick to 10k from 83k(wav) but the latency is still the same. the light lights up but the sound plays a split second after it lights up.
I have tried enabling decompress on load and have tried different levels of compression on the wav as well as the ogg just to see if it would change anything but it stays the same with the delayed response
I have also looked into weather there was silence in the beginning of the sound files and even tried cutting the first split second of one of the sounds just in case my eyes and judgment had deceived me but this also did not fix the delay problem.
Any other ideas?
Also, should I post a different topic now that I think it is audio playback related and not an input issue?
For keyboard and certain inputs there is a deadzone artificial delay. I came across this doing controls for my character. You can change how much delay before (for example left becomes right) in unity control options as the keyboard controls tend to try emulating analogue. This might be what you’re experiencing.
Well, he already said that he’s getting an immediate visual response, and that it’s just the sound playback that seems to be delayed. So, it seems unlikely that that’s the problem.
The OP already stated that he’s getting an immediate visual response, which would seem to suggest that the problem is not with the device or with how Unity is communicating with the device.