Bug #4024

Poor music track distribution

Added by Dark Locq about 1 month ago. Updated 25 days ago.

Sound/Other Media
Target version:
Start date:
% Done:


Operating system:


I have 1,300+ MP3s in my Explore folder (to keep from being "earwormed", which was a serious issue with this game, like many others intended for long-term play).

I keep hearing the same few tracks over and over. It seems to pick the alphabetically first 50 or 100 or whatever, and stop there. I confirmed this by adding a bunch of files with names in the form "01 - Artist - Album - First Track.mp3", "02 - Artist - Album - Second Track.mp3", etc., instead of "Artist - Album - 01 - First Track.mp3", and all the new additions are played frequently. Songs I used to hear all the time with artist or title first (i.e., lower in the alphabetization now) are no longer heard. For example, I haven't heard "The Lord of the Rings - The Two Towers [OST] disc 3 - 01 - Aragorn's Return.mp3" in weeks, but hear "01-02 - Sigur Ros - Hijomalind.mp3" again and again.

It would be ideal if we could actually put scripts [MS Windows translation: batch files] in these Music subdirectories that would execute, instead of the game directly playing whatever's in there in MP3 form. I would rather have VLC or iTunes play higher-quality audio as a separate process. That should also improve frame rates; I have 12 cores, and there's no reason for the game app to be doing everything on one CPU if load can be balanced in any way. I guess this would require that a) all the music directories have the scripts, and b) that they all call the same playback app, otherwise the audio app would continue playing Explore music if the game triggered Battle music and the latter was just a local MP3 played directly by the game. If this suggestion is plausible, I can make a feature request for it.

In the interim, please fix the not-playing-all-the-MP3s problem.

crash.log View (21.4 KB) Andrei Kortunov, 08/20/2017 05:37 PM


#1 Updated by Andrei Kortunov about 1 month ago

I do not have too much time to test it properly, but for me a game can handle 1000+ Explore files.

Can you modify SoundManager::startRandomTitle() in soundmanagerimp.cpp to show a count of files in the playlist?
Something like:

std::cout << filelist.size() << std::endl;

int i = Misc::Rng::rollDice(filelist.size())

If the console output shows 1300+, track list is corrent. In this case Misc::Rng::rollDice() is not randomized well.

#2 Updated by Haoda Wang about 1 month ago

Could it be the result of gambler's fallacy? See

#3 Updated by Haoda Wang about 1 month ago

If we set up a Fisher-Yates shuffle for the music tracks to get rid of the possibility of endlessly repeating songs.

#4 Updated by Dark Locq about 1 month ago

Re: "Can you modify SoundManager::startRandomTitle() in soundmanagerimp.cpp" – I don't have the source version, and can't compile it or even its dependencies. I'm a MacPorts shop, and even your dependencies appear deeply tied to Apple's included Unix binaries and libraries (I would love to work around THAT, since I do want to compile my own version to get around some limitations (like 256 or whatever the exact number is) maximum mods.

I agree in retrospect that the music thing could be a human perception problem, that could be mitigated by a pseudo-randomizing algorithm. How that would work is hard to say, since we have no control over the filenames of what people put in there. Maybe it would just look for strings separated by spaces, hyphens, underscores, and ignore all-numeric strings?

#5 Updated by Haoda Wang about 1 month ago

We could just use the Fisher-Yates shuffle with the filelist in SoundManager::startRandomTitle() right?

#6 Updated by Alexei Dobrohotov about 1 month ago

  • Status changed from New to Feedback needed
  • Target version set to openmw-0.43

Random should be better on the latest code. Dark Locq, try to test the upcoming (?) macOS nightly and report back.

#7 Updated by Andrei Kortunov about 1 month ago

Look like shuffle causes crash on reload.
Just attack someone, wait until combat music stars, and reload to save before combat.

#8 Updated by Alexei Dobrohotov 27 days ago

The crashes were fixed, and feedback is still necessary.

#9 Updated by Dark Locq 25 days ago

Not sure what feedback you need. I played for several hours, day before yesterday, and did not hear any song more than twice that I recall. Before implementation of the F-Y shuffle, I heard the same (quite distinctive) track at least 5 times the same day despite having 1,300+ tracks in the Explore directory. So it at least anecdotally seems like an improvement.

#10 Updated by Alexei Dobrohotov 25 days ago

  • Subject changed from Not fully randomizing music to Poor music track distribution
  • Status changed from Feedback needed to Closed
  • Reproducibility changed from Have not tried to Always
  • Operating system changed from MacOS to Other

Well, that's the feedback I wanted to read.

Also available in: Atom PDF