Cabbage Logo
Back to Cabbage Site

How to read metadata info from wav file

I need read metadata information contained in a wave file for show as text in a gui of an audio plugin.

any idea. thanks.

Hi @ozonic,

How about using python and some module like tinytag (https://github.com/devsnd/tinytag)? Then doing something like this:

<CsoundSynthesizer>
<CsInstruments>
pyinit
pyruni "from tinytag import TinyTag"

instr 1
   pyruni {{
tag = TinyTag.get('Saved_0.wav')
print('This track is by %s.' % tag.artist)
print('It is %f seconds long.' % tag.duration)
   }}
endin

</CsInstruments>

<CsScore>
f1 0 1024 10 1
i1 0 1
e
</CsScore>

</CsoundSynthesizer>

I can’t think of any way to do this apart from using an external tool as @gsenna suggested. If it was something that you really wanted to do natively, the best thing would be to write a simple opcode to read the data using libsndfile. It’s already a component of Csound, so I can’t imagine it would be much work.