Keypress-to-hitsound delay

VBR brings higher music quality compared to CBR. After encoding in CBR i have 37 ms of silence before music starts. VBR are matching source. Encoding was done by Sony Vegas 13.

Image

Image

Realtek R2.79 driver

Steelseries 6GV2 - USB (125 Hz)

Each 36

37

39

39

40

40

40

40

40

41

41

42

42

42

43

43

43

44

44

44

45

45

45

46

46

47

47

47

48

48

49

49

49

49

50

50

50

50

50

50

53

Steelseries 6GV2 + USB -> PS/2 Adapter

Each 35

35

36

36

36

36

36

37

37

37

37

37

38

38

39

39

39

39

39

40

40

40

40

40

41

41

42

42

42

42

43

43

44

44

44

45

45

45

46

Logitech G102 (1000 hz)

Each 36

37

37

37

37

37

37

37

38

38

38

38

38

39

39

39

39

39

39

40

40

40

40

41

41

41

41

41

42

42

42

42

43

43

44

44

44

44

44

44

45

46

46

Windows HD Audio driver ( without REAL )

Each 36

36

36

36

36

37

37

37

37

37

38

38

38

39

39

39

39

39

39

40

40

41

41

41

41

41

41

42

42

42

42

42

42

43

43

43

43

43

43

43

44

44

44

44

44

44

44

45

45

46

46

when

Image

Windows HD Audio driver ( with REAL )

Logitech G102 (1000 hz)

Each 21

21

22

22

22

22

22

22

22

23

23

23

23

23

24

24

24

24

24

25

25

25

25

26

26

26

26

27

27

27

27

27

27

27

28

28

28

28

28

29

29

29

29

29

29

29

29

30

30

30

31

31

Steelseries 6GV2 + USB -> PS/2 Adapter

Each 20

20

21

21

21

21

22

22

23

23

24

24

24

24

24

25

25

25

25

26

26

26

26

27

27

27

27

28

28

28

28

29

29

29

29

29

29

29

29

29

30

30

30

31

31

31

31

31

33

33

Auto

Summary

For players and mappers:

Universal global offset affects only music. For example -10 ms global offset will make music play 10 ms earlier relatively hitobjects (circles, sliders and spinners). +10 ms and music will be playing 10 ms later.

Local offset affects only hitobjects on current beatmap. For example +10 ms local offset will shift them to 10 ms later.

There are no offset settings for hitsounds.

What only you can do with hitsounds - delay them by editing skin hitsound files.

For players:

Be careful with USB audio, it can have additional latency (but usually it's 8 ms).

Sound effects can add audio latency.

According to this video (https://youtu.be/eEswl6kZq5k) 1000 Hz keyboards are most fastest. But keep in mind that keyboards are different .

If you have 125 Hz keyboard then USB->PS/2 adapter will be useful to decrease hit latency.

High chance that wireless = +lag.

Linux brings very low latencies (like 10 ms) https://blog.thepoon.fr/osuLinuxAudioLatency

Keyboards have debounce time - delay to make sure that key was actually pressed. Usually it's not over 10 ms. Shoutouts to Razer for a good picture: https://d4kkpd69xt9l7.cloudfront.net/sys-master/images/h90/hb5/9018448609310/razer-opto-mechanical-performance2-usp-desktop-v2.jpg

Wiki: https://en.wikipedia.org/wiki/Keyboard_technology#Debouncing

Mice clicks are debounced too.

For mappers:

Ranking criteria for bitrate: https://osu.ppy.sh/help/wiki/Ranking_Criteria#rules.4

Use VBR, it brings higher quality. VBR quality setting 70-75 will give near 192 kbit/s result.

Reencode only if source file have higher than 192 kbit/s bitrate, else do nothing.

Test your beatmap on few real players.

Don't use 25%, 50%, 75% speeds in editor to find right offset, it screw ups the music: https://i.imgur.com/0pZVxMs.jpg

If you need to put objects to first ~0.2s (200 ms) of map then you'll better add silence to mp3 to avoid some problems. For example if you have a hitobject at 50 ms of audio and user will set global offset, for example, to -100 ms then it will be impossible to hit it.

If you did same tests (for auto) as I and got same result, then you can adjust global offset and play map with auto to hear roughly same what i will hear when i will play this map without auto.

If you want to do the tests

Post your results here

Audacity - free and open source audioeditor https://www.audacityteam.org/download

For Sony Vegas users:

- Vegas can't open my aac lol. Converter your aac/m4a from phone to wav https://audio.online-convert.com/convert-to-wav

- File → Properties → Ruler → Ruler time format → Time. And you'll see everything in ms instead of frames.

- Options → Disable Quantize to frames (Alt+F8). And you will not be tied to frames.

Script to count average, etc. Can run here http://sandbox.onlinephpfunctions.com

Script <?php

function calculate_median($arr) {

$count = count($arr); //total numbers in array

$middleval = floor(($count-1)/2); // find the middle value, or the lowest middle value

if($count % 2) { // odd number, middle is the median

$median = $arr[$middleval];

} else { // even number, calculate avg of 2 medians

$low = $arr[$middleval];

$high = $arr[$middleval+1];

$median = (($low+$high)/2);

}

return $median;

}



function calculate_average($arr) {

$total = 0;

$count = count($arr); //total numbers in array

foreach ($arr as $value) {

$total = $total + $value; // total value of array numbers

}

$average = ($total/$count); // get average value

return $average;

}



$t = '

40

41 put your results here

42

43

';



$ar = explode("

", trim($t));



sort($ar);



$new = [];

foreach ($ar as $v) {

$new[] = trim($v);

echo trim($v)."

";

}



echo "Median: ".calculate_median($new)." ms

".

"Average: ".round(calculate_average($new),3)." ms

".

"Dispersion: ms

".

"Number of tests: ".count($new)."

";



Where do latency came from?

How to reduce latency?

I don't know how but i want to.

Update 1

I just need a place to post itOS: Windows 10 64-bit 1803Audio driver: Realtek R2.79 and Windows HD AudioSound card: Realtek ALC892 (built-in in mainboard)Sample rate: 24 bit, 192kHzFPS in osu!: <1ms (1000+ fps)Map:- Download: https://yadi.sk/d/CgFWzldP3aWjnS 2 difficulties:- CBR 192kbit-s - audio for this difficulty was encoded with using Constant Bitrate mode (192 kbit/s)- VBR50 - audio for this difficulty was encoded with using Variable Bitrate mode (50% quality)Skin:- Download: https://yadi.sk/d/ttOftk-H3aWk5L In this skin "drum-hitnormal.wav" looks like thisWhen you hit a circle this hitsound will be played.Recording this process we can measure keypress-to-hitsound delay. Let's begin.Set volume on your headphones to max, change music volume to 0, set fps lock to unlimited (because many of things in osu! tied to fps), enable NoFail, turn on audio recording on your smartphone (i guess you can record using your PC but to decrease potential delays i use independent device), put everything near, start beatmap (CBR difficulty) and hit the circles. Example: https://youtu.be/cJ0EQf5s3Zk After opening recording in sound editor you'll see:in this case it is 39 ms.I haveLogitech G102 Prodigy 1000 hz mouse with ~5ms lag (for movement) (according to: https://www.overclock.net/forum/375-mice/1607990-click-latencies-compiled.html 125 hz USB mechanical keyboard (Steelseries 6GV2) and USB->PS/2 adapter.I did repeat tests multiple times times. CBR difficulty by default. Results:Median: 45 msAverage: 44.707 msDispersion: 40-50 msNumber of tests: 41---------------------Median: 40 msAverage: 39.872 msDispersion: 36-45 msNumber of tests: 39---------------------Median: 40 msAverage: 40.442 msDispersion: 37-44 msNumber of tests: 43---------------------If you didn't install audio drivers on your system then you have standard Windows HDAudio drivers, i didn't test them much but seems to be there the same delay.Logitech G102 (1000hz)Median: 41 msAverage: 40.824 msDispersion: 36-46 msNumber of tests: 51---------------------AutoHere's we need precisingly mapped beatmap because lag will be measured compared to music. In this case osu! knowsthe hitsound should be played.For auto (CBR difficulty) lag is 33 ms. For auto (VBR difficulty) lag is 30 ms. Same for editor at 100% speed.There are a nice program called REAL (https://osu.ppy.sh/forum/t/790157) which works with Windows HD Audio driver. It doesn't work with Realtek audio drivers (i tested).Median: 26 msAverage: 25.923 msDispersion: 21-31 msNumber of tests: 52---------------------Median: 27 msAverage: 26.6 msDispersion: 21-31 msNumber of tests: 50---------------------For auto (CBR difficulty) lag is 33 ms. For auto (VBR difficulty) lag is 30 ms.I don't know, ask experts.Uncertain information because i'm not expert: https://docs.microsoft.com/en-us/windows-hardware/drivers/audio/low-latency-audio#span-idwindowsaudiostackspanspan-idwindowsaudiostackspanspan-idwindowsaudiostackspanwindows-audio-stack I think best and easiest solution is custom audio driver.From 0 to 10 ms of delay comes from BASS library (audio engine in osu!), it's possible(?) to reduce this value to 0-5 ms.Roughly 5 ms in average comes from debouncing algorithms from your keyboard (or mice). This value can be up to 10 ms, depends of keyboard.- Use REAL (https://osu.ppy.sh/forum/t/790157) with Windows HD Audio driver (https://i.imgur.com/wQhxTUa.jpg)- Avoid listening to sound through USB, because it's always passes through your device-specific audiocard, which can have decent latency. But casual values for USB audio devices is 8 ms.- Avoid using any sound effects.- peppy need(?) to change BASS update period in osu! source code to minimal 5 ms instead of current 10 ms (https://www.un4seen.com/doc/#bass/BASS_CONFIG_UPDATEPERIOD.html)For programmers:Maybe it will help in decreasing audio latency--------ALC1150 - Realtek drivers - delay is 60-70 msIf you have problems with too low sound volume even at 100% after switching to Microsoft HDA drivers then run Realtek R2.82 audio drivers installer, it will suggest to you to delete old Realtek drivers, reboot and install new. After reboot kill installer process and deleting installer folder from "Program files" or "Program files (x86)".Windows 10 also have automatic installation of drivers, so you might need to temporary disable it - google "automatic drivers install disable".