Skip to content

AudioStreamImportSettingsDialog: loop offset field only allows values with up to three decimals, causing a loop point imprecision that sometimes leads to an audible pop when looping #87427

@RustyRoboticsBV

Description

@RustyRoboticsBV

Tested versions

Reproducable in: v4.1.1.stable.mono.official [bd6af8e], v4.3.dev2.official [3524346]

System information

Godot v4.3.dev2 - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1650 (NVIDIA; 30.0.14.7219) - AMD Ryzen 7 4800H with Radeon Graphics (16 Threads)

Issue description

Some of my ogg music files that use the loop offset variable have audible pops whenever they loop. I've done some testing, and the issue appears to be the following: the ogg importer only lets you set loop time offsets in up to three decimals of precision. With the default sample rate of 44,100 Hz, this creates a potential imprecision of 0.0009999999 * 44,100 ≈ 44 samples during a loop.

For example, I have an ogg file where the loop point needs to be at sample 651,323 for a seamless loop. With a sample rate of 44,100 Hz, that gets me a time offset value of 14.7692307692 seconds.
Unfortunately, the import window only allows a time offset of either 14.769s (sample 651,312) or 14.770s (sample 651,357), missing the mark by either 11 or 34 samples respectively.

The result is an audible pop in some songs, which I've confirmed by comparing a recording of the loop to the original file in Audacity. If I manually set the loop point at runtime through AudioStream.Set("loop_offset", <higher_precision_value>), higher-precision values are allowed and the issue disappears. All songs that I've tested seem to loop perfectly after doing this.

Editing the "default float step" editor setting did not fix the problem. Manually editing the .import file in notepad doesn't work either: the value still gets imported with the loop offset rounded to three decimals.

This problem was already mentioned by @strellydev in #80452 and #64775, but I felt it was worth creating a more targeted thread for this issue, as I suspect it's more a resource loading problem than a problem in the ogg implementation itself.

I'm going to investigate the issue and post my findings. If the problem is what I think it is, I propose increasing the precision of the loop offset field to at least five decimals.

Steps to reproduce

  1. Add an ogg file to project.
  2. Enable looping.
  3. Enter a value in loop offset field. The value gets rounded to three decimals.
  4. Depending on the music file, audio pops may occur on loop.

Minimal reproduction project (MRP)

N/A

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions