开发者

Is there anyway to tag a .wav file and write a time into it?

开发者 https://www.devze.com 2023-02-12 04:01 出处:网络
I would like to add into each one of my .wav files a time tag.This tag would say when the 开发者_如何学运维file has started in time and if possible an end time.The time could be relative to the unix e

I would like to add into each one of my .wav files a time tag. This tag would say when the 开发者_如何学运维file has started in time and if possible an end time. The time could be relative to the unix epoch. How would I go about doing this or can it even be done?

Thanks

-Josh


From http://www.wotsit.org/download.asp?f=wave&sc=351595652:

A WAVE file is a collection of a number of different types of chunks. ... Among the other optional chunks are ones which define cue points, list instrument parameters, store application-specific information, etc.

You could add your own chunk for your information, but only your tools would be able to read and write it. You may find interoperability problems with other software that doesn't properly ignore unknown chunks, or chooses the same ID as you did for your chunk. Chunk IDs are 4 bytes, so that should be enough room to avoid that problem in practice, even interpreting the above document ("4 ASCII bytes") in the most restrictive sense ("4 bytes of printable ASCII characters").

Instead, you could keep a separate file alongside the wave file with your information. There would be no interoperability problems, but users would be required to keep the files together.


WAV files support limited, text-based tagging, which probably works fine for you. You can specify user-defined fields in the INFO chunk ( http://en.wikipedia.org/wiki/Resource_Interchange_File_Format#Use_of_the_INFO_chunk), which is probably suitable for your needs, but there's no simpler way like you get with ID3 tags in MP3 or Vorbis comments in FLAC.

I don't know of any library that makes this easier to work with, since I don't work with WAV, but maybe libsndfile would work for you, or otherwise you could manipulate the header yourself by reading in the file into a byte stream, and then processing the header yourself using the information from the specifications: http://www.sonicspot.com/guide/wavefiles.html#wavefileheader

Otherwise, for a simpler time, you might want to transcode your WAV files to FLAC and then write fields to the FLAC tag: Full FLAC C and C++ API documentation here: http://flac.sourceforge.net/api/index.html


I am not sure if there is a common way to do that (like exif tags in jpeg), but if everything else fails you could try to use http://en.wikipedia.org/wiki/Steganography

Thats a method to code Messages into files, especially pictures and audiofiles, altering the content only sligthly. but i dont know how much efford it would be to code/decode that message into a file.


WAV files are RIFF files, which are designed to allow adding chunks of arbitrary data without breaking the file for other programs (so long as your chosen chunk tag doesn't clash with anybody else).

If you are on Windows, there are some functions to help you manipulate such files, e.g. mmioCreateChunk.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号