Author Topic: Editing Metadata while playing audio file  (Read 441 times)

kafffee

  • Posts: 141
Editing Metadata while playing audio file
« on: 29 Sep '22 - 18:03 »
Hello there :-)

I want to edit metadata of audio files while they are playing.

So I ran into the problem that the changes were not applied because the file was still playing. Is there any way to avoid this or do I have to pause or even stop playing and free the stream to do this?

Greetings, kafffee :-)

jpf

  • Posts: 145
Re: Editing Metadata while playing audio file
« Reply #1 on: 30 Sep '22 - 04:07 »
For what I saw, if you're playing the file with BASS_StreamCreateFile then the 3DLite's Tags Library https://www.3delite.hu/Object%20Pascal%20Developer%20Resources/TagsLibrary.html will write the metadata if the necessary space in the file is already allocated. This is the case with ID3v1 tags, but with variable-lenght tags the space may not be enough and a complete re-write of the file may be necessary. In this case you must free the stream.

It may be possible to load the entire file into memory and play it from there, for instance using the BASS_ASYNCFILE flag and providing a big enough buffer. The file buffer is determined by the BASS_CONFIG_ASYNCFILE_BUFFER config option.

Another option is to copy the file and write the tags to the copy. Then after you're done playing the original, delete it and rename the copy.

Yet another option is the one you mention: delay the writing of the tags until the stream is freed. This seems to be the easiest.

I've tried all 4 options and none is fool-proof.

All 4 options may fail if the same file is locked by another process, for instance if it's being played by VLC or WMP (even if it's paused) and BASS_StreamCreateFile simultaneously.

With certain file types it's possible to play the file while it's being written (recorded). Some of them support mid-stream tags, and you can write them on the fly along with the audio. For instance, wma.

kafffee

  • Posts: 141
Re: Editing Metadata while playing audio file
« Reply #2 on: 30 Sep '22 - 14:35 »
OK thanks, so far so good  :D

I just discovered the StreamCreateFile overload:
http://www.bass.radio42.com/help/html/0b998163-5a56-a1c3-bf93-e0ad2204c8cc.htm

Is it possible with this to play audio files from main memory? So there is a copy of the file in memory and I will be able to edit the file on hard disk?

jpf

  • Posts: 145
Re: Editing Metadata while playing audio file
« Reply #3 on: 30 Sep '22 - 15:38 »
I was able to do it in the VB6 environment (it doesn't use radio42's wrapper) setting a big enough BASS_CONFIG_ASYNCFILE_BUFFER. I didn't try to do it in the dotnet environment.

kafffee

  • Posts: 141
Re: Editing Metadata while playing audio file
« Reply #4 on: 30 Sep '22 - 16:31 »
I was able to play it from memory, too, with the example given in the docs. However my drawn WaveForm gets messed up, see the pictures attached below:

kafffee

  • Posts: 141
Re: Editing Metadata while playing audio file
« Reply #5 on: 8 Nov '22 - 17:10 »
Okay I found the solution: bass_fx.dll is required  :)