Why are sometimes my sound files locked?

Hello,

I was wondering why sometimes the editor is locking my sound files.
I have a sound file (0.5 second, 8K😎 that, when played in the editor, is not locked when I try to delete it in the Windows Explorer.
If I copy/paste this file in Audacity to expand its length, then play it in the editor, I can no longer delete this file in the explorer unless I close the editor.

I've even tried with a sound file composed only of generated silence. Above the 2.756 seconds mark (more or less a few milliseconds) then the file becomes locked.

Questions time:
Why is the editor locking the files?
How can I prevent it?

It doesn't seem to be related to the file itself, since the same file saved with Audacity works under the 2.756 seconds mark.
I usually let another file play for a few seconds and it releases the original one.
I've tried waiting, to no avail. Now I have two sound files locked. I'm wondering if it's a bug or a feature... :distrust:
When that happens to me, I have to wait until I close the editor, then go in to the audio folder and delete it manually.
That's annoying, because I'm working on an alternate sound engine for encryption, but I'm stuck because of these locked sound files.

I can't figure why it happens, which makes it difficult to fix.
Basically, if windows can't delete a file, that is because it's in use. However, that is not something directly checked - the file is marked as such on opening and remains that way until closing.


Having two programs open similiar-named files can get to problems here, but it can very well be that it's another program accessing those files as well - you have to close programs and check the results until you know which one causes the problem.
It is related to the editor, no doubt here.

I used a program to get the handle of the locked file and which program is using it, and the only answer is the editor.

It allows deletion if the sound file is short (under 2.756 seconds in my testing) and locks the file above it.

I tried waiting for the sound to be played entirely, I also used the "stop" button. Nothing works. Once the editor locks the file, only quitting the editor can free the file again.

Or kill the handle with an external program, which seems overkill for my use.

Edit:

I couldn't prevent this lock, but I found an alternate way to access my sound files. Actually, I still have to test to be sure but it's even more effective than my previous attempt.
I've moved this thread to Tech Support - All Makers. Please be sure to post your threads in the correct forum next time. Thank you.
Back to square one, I can't make the system read a specific file name inside an encrypted archive. I can extract the data, but not the path of the file...

And since the se_play function only takes a path and not the sound data, it doesn't work.

I still have to extract the data to a temporary file, but it gets locked after it's played (for sounds longer that 2.756s)

I've tried many ways to read and write data, but this darn undocumented audio function is broken and I can't fix it.
What command are you using?
I play my sound with:

Audio.se_play('<path+filename>', @volume, @pitch)

Which seems to lock the file after play, just like the editor does. It's probably the same command so I asked about the editor command first instead of scaring people with ruby code :|

If I could find a way to send the path of the file inside the rgss3a archive that could work, but load_data retrieves only the data, not the path to it. And this se_play command only wants a path, not the data itself...

At the moment I see two solutions:

-remove/prevent the lock of played sound files so I can use a temp file.

-retrieve the path to a specific file inside a rgss3a archive to send directly to se_play.

But I can't do it, at least not with my limited ruby skill.

Original thread: https://forums.rpgmakerweb.com/threads/why-are-sometimes-my-sound-files-locked.44009/