![]() |
IL2 Sturmovik doesn't unlock files when done
When playing a radio station, IL2 locks the .wav file its playing but never unlocks it.
If it plays 5 songs, all five wav files remain locked. Is there someway of unlocking them without leaving the game? I think this is a bug because locked files should only remain locked while in use. |
You're running on Win7(or 8 ) I gather.
It's a known problem that win7 doesn't release the files when the application closes. I go to the Task-Manager (Ctl^Alt^Del) -- Processes .. and terminate the process with extreme prejudice :grin: |
Which process would that be?
|
Just returned from outer space... maybe you've already discovered this - The game exe file, is the process to terminate
|
Maybe I miss-understood...
The game has it's own OGG codec... The game exe process probably locks the audio functionality, so you won't be able to unlock the audio without shutting the game down. sorry! |
Would be nice if it would unlock files its done using. Audio files it hasn't yet used are unlock until used. I understand locking a file in use, but when done playing it (over the radio) it should be unlocked.
|
Can I ask what you're trying to achieve here? Are you looking to have some sort of dynamic radio station by swapping out files on-the-fly?
Personally I would like to see this particular bit of functionality expanded slightly, or even just fixed. The fact that the randomisation of music in IL2 is utterly broken(I.E. just plays in sequence) makes it much less usable than it could be. |
Yes. I have a routine to randomize the files but it requires the files to be unlocked. Right now it works only before the game. During the game only the files that haven't been used can be changed.
|
I have a workaround for you; IL2 plays files in alphabetical order, this enables you to use a prefix(aaa, 001, etc) to determine the order files are played in.
If you use a high id(zzz, 999, etc) for the first file you play, you can later add files with a lower ID which will be played first. IL2 refreshes the radio folder(I.E. starts from the first song) every time you tune to that station. This should enable you to add new files while in flight, even if it doesn't allow for fully automated randomisation. Keep in mind, using console(Shift-Tab) command "MUSIC PLAY STOP" skips to the next song in the alphabetical order, so you can't skip backwards or to new songs. You can however play the first song in the directory using "MUSIC PLAY PATH [path to radio station directory]". This has the same effect as switching from and to the station. |
I'll see what I can do with that knowledge.
But your comment about starting with say '999' as the title begs the question of how do you determine the first song? Or are you assuming only the one song in the folder and its called '999'... |
The method I would use is this:
Music in a subfolder of the station you're using has an underscore prefix(I.E. "_artist - song.wav"). When you're ready to change songs, you move the .wav file you need to the radio station directory and rename it with the prefix you're using by replacing everything in front of the underscore with the next ID(If 999 is playing, rename to "998_artist - song.wav") and refresh the station. This can be done using a keyboard macro to press the previous/next radio station buttons in sequence, or by having it open the console and using the proper command(This method has the issue of momentarily pausing the game while you're typing to the console, which needs some delay to properly register all keypresses). After the game exe stops and the files are unlocked, move them back to their subdirectory so you can repeat the cycle next time the game is started. This is why I propose the underscore(or other symbol) prefix, so you can easily rename the files without worrying about what they're currently called. Moving the files will also ensure no song is played twice within one session of play. You could also move recently played files to a seperate directory and move them back when they haven't been played for a while(applying a datestamp when you move them) if you're hearing the same music too often. Randomly picking a song to start with could be done by counting the .wav files in the folder you're looking to play, then generating a random number within the file count and playing the file corresponding with that number. Your program/script would be running along with the game keeping track of what number is next in the cue. Alternatively you could have it check which numbers are already in the radio station directory. The latter allows you to only run the program/script when you're actually switching song, but requires reading all file names each to you do run it as opposed to just getting a numeric value from a variable. Perhaps the biggest question surrounding this problem is when to actually switch songs. I don't know of a way to determine when a song has stopped playing within IL2. In theory you could have it trigger when the next file in the cue is read(I.E. when file "998_artist - song.wav" is done, IL2 should read "999_artist - song.wav", this does require an exception when only one file is currently present). Provided already played songs aren't read directly from memory, you could monitor the filesystem to see when the next file is read. A much easier method is to use a set interval, or a keypress(which would allow you to skip songs). I will say the theoretical part of the problem is solvable, but I personally lack the programming experience to tackle the practical side(especially the filesystem voodoo). |
I'm working on a method using Autohotkey and a vb script to randomize the songs and then copy and rename them into the original folder.
If I get things orginized enough I'll post the results. Time will tell. :-) Is there a way to get the current music directory from IL2? |
This is the autohotkey script I use to randomize music in IL2.
It uses a visual basic script program written by someone else. Its called "IL2_RadioRandomizer.vbs". It gives each .wav file a unique name that is randomly assigned (keeping the original portion of the name). I then prepend a three digit number before each name. YOU MUST CREATE A NEW FOLDER called "Radio_Source" in your IL2/samples/music folder. This new folder MUST contain all the sound files found in the IL2/samples/music/Radio folder, including the directory structure. IE, a duplicate of your Radio folder. Files in the Radio folder will be deleted when this routine runs, and their contents will be replaced with the renamed contents from the Radio_Source folders. GAMEPATH = C:\Ubisoft\IL2_Current prependCount := 999 ;for renaming radio wav files RandomizeMusic() { global GAMEPATH, prependCount RunWait, %GAMEPATH%\IL2_RadioRandomizer.vbs,%GAMEPATH%,Hide FileDelete, %GAMEPATH%\samples\Music\Radio\BBC\*.wav FileCopy, %GAMEPATH%\samples\Music\Radio_Source\BBC\*.wav, %GAMEPATH%\samples\Music\Radio\BBC\%prependCount%_ *.wav FileDelete, %GAMEPATH%\samples\Music\Radio\Grossdeutscher_Rund funk\*.wav FileCopy, %GAMEPATH%\samples\Music\Radio_Source\Grossdeutsch er_Rundfunk\*.wav, %GAMEPATH%\samples\Music\Radio\Grossdeutscher_Rund funk\%prependCount%_*.wav FileDelete, %GAMEPATH%\samples\Music\Radio\Magyar_Radio\*.wav FileCopy, %GAMEPATH%\samples\Music\Radio_Source\Magyar_Radio \*.wav, %GAMEPATH%\samples\Music\Radio\Magyar_Radio\%prepe ndCount%_*.wav FileDelete, %GAMEPATH%\samples\Music\Radio\Radio_Honolulu\*.wa v FileCopy, %GAMEPATH%\samples\Music\Radio_Source\Radio_Honolu lu\*.wav, %GAMEPATH%\samples\Music\Radio\Radio_Honolulu\%pre pendCount%_*.wav FileDelete, %GAMEPATH%\samples\Music\Radio\Radio_Moscow\*.wav FileCopy, %GAMEPATH%\samples\Music\Radio_Source\Radio_Moscow \*.wav, %GAMEPATH%\samples\Music\Radio\Radio_Moscow\%prepe ndCount%_*.wav FileDelete, %GAMEPATH%\samples\Music\Radio\Radio_Paris\*.wav FileCopy, %GAMEPATH%\samples\Music\Radio_Source\Radio_Paris\ *.wav, %GAMEPATH%\samples\Music\Radio\Radio_Paris\%prepen dCount%_*.wav FileDelete, %GAMEPATH%\samples\Music\Radio\Radio_Roma\*.wav FileCopy, %GAMEPATH%\samples\Music\Radio_Source\Radio_Roma\* .wav, %GAMEPATH%\samples\Music\Radio\Radio_Roma\%prepend Count%_*.wav FileDelete, %GAMEPATH%\samples\Music\Radio\Radio_Tokyo\*.wav FileCopy, %GAMEPATH%\samples\Music\Radio_Source\Radio_Tokyo\ *.wav, %GAMEPATH%\samples\Music\Radio\Radio_Tokyo\%prepen dCount%_*.wav FileDelete, %GAMEPATH%\samples\Music\Radio\Suomen_Yleisradio\* .wav FileCopy, %GAMEPATH%\samples\Music\Radio_Source\Suomen_Yleis radio\*.wav, %GAMEPATH%\samples\Music\Radio\Suomen_Yleisradio\% prependCount%_*.wav prependCount := prependCount - 1 Return } |
This script won't work, for a number of reasons(As you've probably found out for yourself).
Have a look here, this could at least help you with selecting random files to copy. At present, the script will copy all files from one directory to another and apply the default 999 prefix to each of them. I would recommend against copying files. It will consume more system resources and time than simply moving them(Copying reads and subsequently writes a new file to disk, moving simply appends the MFT). For the deletion you'd have a while loop or something similar to check if IL2 is running. When the loop ends you can move the file you used back to the Radio_Source dir. Moving does present the problem of filenames, as you'll end up with "999_999_999_artist - song.wav" after a while. You can either remove the first 3 characters from the filename(This assumes all files in the source directory already have a prefix) or count the characters before the first underscore and replace those. I'm also wondering about "RunWait,%GAMEPATH%\IL2_RadioRandomizer.vbs,%GAMEP ATH%,Hide". To me this looks like it would spawn an infinite(or however many fit in memory) number of scripts all waiting on each other to finish. As for detecting the currently playing station, that's another difficult proposal. The console doesn't log songs or directories, and the onscreen messages aren't logged either as far as I know. You can however use the console command "music" without any parameters to return the currently playing file. If you combine that with the log file you could rig something up. Writing to the console is cumbersome though. If I could I'd give you the code, but as I've stated before: While I get the logic behind it, putting it into practice is the hard part. |
I'll look into your suggestion, but this code works perfectly. Maybe its because I'm running an I7 processor, but it works fast and doesn't impact my game while its running. The runwait is used to be sure the process is finished before continuing.
You call this routine when you want the files randomized. The files that have been played can't be removed. This procedure randomizes the source files, removes the files from the destination (except those that are locked) to avoid a buildup of unneeded files, then copies the files from the source to the destination, prepending a 3 digit number that is less than the one used the last time this procedure was called. Since you can't do anything with the locked files until IL2 exits, its necessary to have a source that isn't locked. Otherwise you can't rename them. Hence the source folder which should never have its files removed as they are the master files. |
Here's a shorter version. It's self-contained, not relying on the vb script.
It still uses the RADIO_SOURCE folder to get the songs and COPIES them into their respective folders. GAMEPATH = C:\Ubisoft\IL2_Current prependCount := 999 ;for renaming radio wav files RandomizeMusic() { global GAMEPATH, prependCount Loop, %GAMEPATH%\samples\Music\Radio\*.*, 1, 0 ;non-recurse into subfolders { FileDelete, %A_LoopFileFullPath%\*.wav } Loop, %GAMEPATH%\samples\Music\Radio_Source\*.wav, , 1 ;recurse into subfolders { Filename = %A_LoopFileFullPath% Random, num, 100,999 StringReplace, Name, Filename, Radio_Source, Radio StringReplace, Filename, Name, %A_LoopFileName%, %prependCount%_%num%_%A_LoopFileName% FileCopy, %A_LoopFileFullPath%, %Filename% } prependCount := prependCount - 1 } |
All times are GMT. The time now is 06:07 AM. |
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2007 Fulqrum Publishing. All rights reserved.