mdias / rs_asio

ASIO for Rocksmith 2014
MIT License
992 stars 95 forks source link

Latency problem #253

Open zotyo86 opened 2 years ago

zotyo86 commented 2 years ago

I found a fairly accurate way to measure the overall latency of the signal processing of Rocksmith (or any guitar effect processor software). I found that I get roughly double latency with Rocksmith than using NI Guitar Rig 4 for processing the analogue signal of my guitar/bass, while my ASIO driver settings, audio interface and overall configuration is the same.

The results: latency with RS: 35 ms latency with GR4: 18 ms

Details: For both measurements I used the same setup:

How do I measure latency? I first make a preset on my HX Stomp that includes just a sole Amp+Cabinet model, with a clean sound. I route the output of this preset to the Send jack of the Stomp. This will be used as reference signal, since the Stomp has negligible latency (I assume 2..3 ms max.) The Stomp is also connected to my computer via USB as audio interface. The processed signal from RS or GR4 is routed to its main output jacks (left and right) as the signal to be evaluated against the reference signal. To be able to analyse the delay between the signal of the two paths offline, one just has to make a recording of both signals simultanously with a simple digital stereo recorder. In my case the recorder is my stereo looper (Boss RC3). I connect the Send output from the Stomp into input A on the looper and connect the main output left channel into input B on the looper. This way the reference output from the Stomp is recorded in the left channel, and the RS (or GR4) output is recorded in the right channel of the same recording. My instrument (guitar or bass) is plugged into the instrument input of the Stomp, and RS is getting the input signal from Stomp via USB channel 5 (dry input w/o processing). I set up a very pure amp+cab rig in RS. For the actual measurement I launch Rocksmith, start recording on my looper and pluck some firm, discrete and short notes on my bass, preferably on the G string. Then I save the recording on the looper as .wav. Once I import the file into a wave editor, I can measure the delay between the left and right signals based on the timestamps of where the notes are started (one has to zoom in really). I usually take the delay between at least 5..6 samples (sample means the same note in the left and the right channels) and take an average for the latency. I found the deviation is quite low among the samples (0 or 1 ms). I think this method gives a realistic picture about the real latency at the output, especally for comparison between RS and GR4, since both sources are evaluated against the same reference source. (GR4 states in the audio settings that the calculated latency with the set buffer size is 21 ms which is really close to my measured 18 ms considering the extra 2..3 ms of the Stomp that is excluded from my measurement due to the method, but shoud be added to get the total latency.)

Conclusion I get significantly higher latency with Rocksmith, although my hardware looks capable for lower, proven with Guitar Rig, as I get perfect quality sound from it without cracking etc, with less latency.

In general I use the Stomp for processing my guitar/bass, and I mute the guitar/bass signal coming from RS. This way I hear my instrument without latency. I (as guitarists in general) play aligned with the song I hear, not with the notes visibly coming on the note highway. If I hear the song with a delay, I will play the notes with the same delay and consequently RS will detect my notes as late (or at least I get only 'Good' instead of 'Perfect' in score attack mode). Therefore I want to reduce this latency as much as possible.

I tried

Questions: What could be the reason for RS with your ASIO layer ending up at significantly higher latency than another program utilising the same hardware, driver and configuration? What else can I try to improve the latency in RS using RS_ASIO?

Rocksmith.ini

[Audio]
EnableMicrophone=0
ExclusiveMode=1
LatencyBuffer=2
ForceDefaultPlaybackDevice=0
ForceWDM=0
ForceDirectXSink=0
DumpAudioLog=0
MaxOutputBufferSize=0
RealToneCableOnly=0
Win32UltraLowLatencyMode=1

RS_ASIO.ini

[Asio]
; available buffer size modes:
;    driver - respect buffer size setting set in the driver
;    host   - use a buffer size as close as possible as that requested by the host application
;    custom - use the buffer size specified in CustomBufferSize field
BufferSizeMode=custom
CustomBufferSize=128

[Asio.Output]
Driver=ASIO HX Stomp
BaseChannel=0
    ; 0 - output on Phones/Main only
    ; 1 - output on Phones/Main & Send
    ; 2 - output on Send only
AltBaseChannel=
EnableSoftwareEndpointVolumeControl=1
EnableSoftwareMasterVolumeControl=1
SoftwareMasterVolumePercent=40

[Asio.Input.0]
Driver=ASIO HX Stomp
Channel=4
    ; 0 means feeding RS with wet signal from HX Stomp Path A for note detection (USB1)
    ; 4 means feeding RS with dry DI signal from HX Stomp for note detection (USB5)
EnableSoftwareEndpointVolumeControl=1
EnableSoftwareMasterVolumeControl=1
SoftwareMasterVolumePercent=700
    ; HX Stomp sends USB signal with unity gain, which is too low for RS to calibrate properly.
    ; 700% gain is defined to compensate for this.

[Asio.Input.1]
;shall be kept empty, otherwise RS will detect two conflicting cables.
Driver=
Channel=1
EnableSoftwareEndpointVolumeControl=1
EnableSoftwareMasterVolumeControl=1
SoftwareMasterVolumePercent=100

[Asio.Input.Mic]
; microphone is not used.
Driver=
Channel=
EnableSoftwareEndpointVolumeControl=1
EnableSoftwareMasterVolumeControl=1
SoftwareMasterVolumePercent=100
theSG commented 2 years ago

I guess it's just the way rocksmith handles the audio. I also measured my latency some time ago and with realtone cable through wasapi (no rs_asio) the best result I got was 29ms, while I could easily get 14 ms (again with realtone cable through wasapi) in any other program. so while you can get some latency improvements (I'm getting lower results with rs_asio by my measurements) overall rocksmith latency will never be as low as in other apps.

mdias commented 2 years ago

You might be interested in checking issue #172

FYI I made the tests by dumping both the input and output buffer data flowing through ASIO callbacks from the driver and checking how many samples there are between the moment we feed Rocksmith some guitar sound and the moment it's amp starts outputting audio in the main menu.

This should allow to measure the latency from Rocksmith processing alone and altough it fluctuated a bit, it was around ~16ms which actually seems to pretty much align perfectly with your tests (your "hw" latency being 18ms, plus the 16ms from Rocksmith from my tests being 34ms).

As for the reason for this extra latency it's something I can't accurately tell since I don't have access to Rocksmith's source code. But I would guess this is related to several things, like: