mirror of
https://github.com/iluvcapra/wavinfo.git
synced 2025-12-31 08:50:41 +00:00
More wavinfo elaboration
This commit is contained in:
@@ -1,23 +1,23 @@
|
|||||||
.TH waveinfo 7 "2023-11-08" "Jamie Hardt" "Miscellaneous Information Manuals"
|
.TH waveinfo 7 "2023-11-08" "Jamie Hardt" "Miscellaneous Information Manuals"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
wavinfo \- everything you ever wanted to know about WAVE metadata but were
|
wavinfo \- WAVE file metadata
|
||||||
afraid to ask
|
.SH SYNOPSIS
|
||||||
.SH DESCRIPTION
|
Everything you ever wated to know about WAVE metadata but were afraid to ask.
|
||||||
|
.SH DESCRIPTION
|
||||||
.PP
|
.PP
|
||||||
The WAVE file format is forwards-compatible. Apart from audio data, it can
|
The WAVE file format is forwards-compatible. Apart from audio data, it can
|
||||||
hold arbitrary blocks of bytes which clients will automatically ignore
|
hold arbitrary blocks of bytes which clients will automatically ignore
|
||||||
unless they recognize them and know how to read them.
|
unless they recognize them and know how to read them.
|
||||||
.PP
|
.PP
|
||||||
Without saying too much about the structure and parsing of WAVE files
|
Without saying too much about the structure and parsing of WAVE files
|
||||||
themselves, a subject beyond the scope of this document, WAVE files are
|
themselves \- a subject beyond the scope of this document \- WAVE files are
|
||||||
divided into segments or
|
divided into segments or
|
||||||
.BR chunks ,
|
.BR chunks ,
|
||||||
which a client parser can either read or skip without reading. Chunks have
|
which a client parser can either read or skip without reading. Chunks have
|
||||||
an identifier, or signature: a four-character-code which informs a client
|
an identifier, or signature: a four-character-code that tells a client what
|
||||||
what kind of chunk it is, and a length. Based on this information, a client
|
kind of chunk it is, and a length. Based on this information, a client can look
|
||||||
can look at the identifier and decide if it knows how to read that chunk or
|
at the identifier and decide if it knows how to read that chunk and if it wants
|
||||||
if it wants to. If it doesn't, it can simply read the length and skip
|
to. If it doesn't, it can simply read the length and skip past it.
|
||||||
past it.
|
|
||||||
.PP
|
.PP
|
||||||
Some chunks are mandated by the Microsoft standard, specifically
|
Some chunks are mandated by the Microsoft standard, specifically
|
||||||
.I fmt
|
.I fmt
|
||||||
@@ -26,8 +26,8 @@ and
|
|||||||
in the case of PCM-encoded WAVE files. Other chunks, like
|
in the case of PCM-encoded WAVE files. Other chunks, like
|
||||||
.I cue
|
.I cue
|
||||||
or
|
or
|
||||||
.I bext
|
.IR bext ,
|
||||||
are optional, and hold metadata.
|
are optional, and optional chunks usually hold metadata.
|
||||||
.PP
|
.PP
|
||||||
Chunks can also nest inside other chunks, a special identifier
|
Chunks can also nest inside other chunks, a special identifier
|
||||||
.I LIST
|
.I LIST
|
||||||
@@ -51,16 +51,15 @@ WAVE file
|
|||||||
.BR in-place ,
|
.BR in-place ,
|
||||||
without having to re-write the file or audio data.
|
without having to re-write the file or audio data.
|
||||||
.IP 2)
|
.IP 2)
|
||||||
Older authorites recommend placing metadata before the audio data, so
|
Older authorites recommend placing metadata before the audio data, so clients
|
||||||
clients reading the file sequentially will hit it before having to seek through
|
reading the file sequentially will hit it before having to seek through the
|
||||||
the audio. This may have improve metadata read performance on certain
|
audio. This may improve metadata read performance on certain architecures.
|
||||||
architecures.
|
|
||||||
.IP 3)
|
.IP 3)
|
||||||
Older authorities also recommend inserting
|
Older authorities also recommend inserting
|
||||||
.I JUNK
|
.I JUNK
|
||||||
before the
|
before the
|
||||||
.I data
|
.I data
|
||||||
chunk, sized in such a way so that the first byte of the
|
chunk, sized so that the first byte of the
|
||||||
.I data
|
.I data
|
||||||
payload lands immediately at 0x1000 (4096), because this was a common
|
payload lands immediately at 0x1000 (4096), because this was a common
|
||||||
factor of the page boundaries of many operating systems and architectures. This
|
factor of the page boundaries of many operating systems and architectures. This
|
||||||
@@ -72,63 +71,96 @@ here) tend to place the Broadcast-WAVE
|
|||||||
.I bext
|
.I bext
|
||||||
metadata before the data, followed by the data itself, and then other data
|
metadata before the data, followed by the data itself, and then other data
|
||||||
after that.
|
after that.
|
||||||
.PP
|
.\" .PP
|
||||||
Clients reading WAVE files should be tolerant and accept any configuration of
|
.\" Clients reading WAVE files should be tolerant and accept any configuration of
|
||||||
chunks, and should accept any file as long as the obligatory
|
.\" chunks, and should accept any file as long as the obligatory
|
||||||
.I fmt
|
.\" .I fmt
|
||||||
and
|
.\" and
|
||||||
.I data
|
.\" .I data
|
||||||
chunks
|
.\" chunks
|
||||||
are present.
|
.\" are present.
|
||||||
.PP
|
.PP
|
||||||
It's not unheard-of to see a naive implementor expect
|
It's not unheard-of to see a naive implementor expect
|
||||||
.B only
|
.B only
|
||||||
these chunks, in this order, and to hard-code the offsets of the short
|
.I fmt
|
||||||
|
and
|
||||||
|
.I data
|
||||||
|
chunks, in this order, and to hard-code the offsets of the short
|
||||||
.I fmt
|
.I fmt
|
||||||
chunk and
|
chunk and
|
||||||
.I data
|
.I data
|
||||||
chunk into their program, and this is something that should always be checked
|
chunk into their program, and this is something that should always be checked
|
||||||
when evaluating a new tool, just to make sure the developer didn't do this.
|
when evaluating a new tool, just to make sure the developer didn't do this.
|
||||||
Many coding examples and WAVE file explainers from the 90s and early aughts
|
Many coding examples and WAVE file explainers from the 90s and early aughts
|
||||||
give the basic layout of a WAVE file and naive devs go along with it.
|
give the basic layout of a WAVE file, and naive devs go along with it.
|
||||||
.SS Encoding and Decoding Text Metadata
|
.SS Encoding and Decoding Text Metadata
|
||||||
.PP
|
.\" .PP
|
||||||
Modern metadata systems, anything developed since the late aughts, will defer
|
.\" Modern metadata systems, anything developed since the late aughts, will defer
|
||||||
encoding to an XML parser so when dealing with
|
.\" encoding to an XML parser, so when dealing with
|
||||||
.I ixml
|
.\" .I ixml
|
||||||
or
|
.\" or
|
||||||
.I axml
|
.\" .I axml
|
||||||
so a client can mostly ignore this problem.
|
.\" so a client can mostly ignore this problem.
|
||||||
.PP
|
.\" .PP
|
||||||
The most established metadata systems are older than this though, and so the
|
.\" The most established metadata systems are older than this though, and so the
|
||||||
entire weight of text encoding history falls upon the client.
|
.\" entire weight of text encoding history falls upon the client.
|
||||||
.PP
|
.\" .PP
|
||||||
The original WAVE specification, a part of the Microsoft/IBM Multimedia
|
.\" The original WAVE specification, a part of the Microsoft/IBM Multimedia
|
||||||
interface of 1991, was written at a time when Windows was an ascendant and
|
.\" interface of 1991, was written at a time when Windows was an ascendant and
|
||||||
soon-to-be dominant desktop environment. Audio files were almost
|
.\" soon-to-be dominant desktop environment. Audio files were almost
|
||||||
never shared via LANs or the Internet or any other way. When audio files were
|
.\" never shared via LANs or the Internet or any other way. When audio files were
|
||||||
shared, among the miniscule number of people who did this, it was via BBS or
|
.\" shared, among the miniscule number of people who did this, it was via BBS or
|
||||||
usenet. Users at this time may have ripped them from CDs, but the cost of hard
|
.\" Usenet. Users at this time may have ripped them from CDs, but the cost of hard
|
||||||
drives and low quality of compressed formats at the time made this little more
|
.\" drives and low quality of compressed formats at the time made this little more
|
||||||
than a curiosity. There was no
|
.\" than a curiosity. There was no CDBaby or CDDB to download and populate metadata
|
||||||
.I CDBaby or
|
.\" from at this time.
|
||||||
.I CDDB
|
.\" .PP
|
||||||
to download and populate metadata from at this time.
|
.\" So, the
|
||||||
.PP
|
.\" .I INFO
|
||||||
So, the
|
.\" and
|
||||||
.I INFO
|
.\" .I cue
|
||||||
and
|
.\" metadata systems, which are by far the most prevalent and supported, were
|
||||||
.I cue
|
.\" published two years before the so-called "Endless September" of 1993 when the
|
||||||
metadata systems, which are by far the most prevalent and supported, were
|
.\" Internet became mainstream, when Unicode was still a twinkle in the eye, and
|
||||||
published two years before the so-called "Endless September" of 1993 when the
|
.\" two years before Ariana Grande was born.
|
||||||
Internet became mainstream, when Unicode was still a twinkle in the eye, and
|
|
||||||
two years before Ariana Grande was born.
|
|
||||||
.PP
|
.PP
|
||||||
The safest assumption, and the mandate of the Microsoft, is that all text
|
The safest assumption, and the mandate of the Microsoft, is that all text
|
||||||
metadata, by default, be encoded in Windows codepage 819, a.k.a. ISO Latin
|
metadata, by default, be encoded in Windows codepage 819, a.k.a. ISO Latin
|
||||||
alphabet 1, or ISO 8859-1. This covers most Western European scripts but
|
alphabet 1, or ISO 8859-1. This covers most Western European scripts but
|
||||||
excludes all of Asia, Russia and most of the European Near East, the Middle
|
excludes all of Asia, Russia, most of the European Near East, the Middle
|
||||||
East.
|
East.
|
||||||
|
.PP
|
||||||
|
To account for this, Microsoft proposed a few conventions, none of which have
|
||||||
|
been adopted with any consistency among clients of the WAVE file standard.
|
||||||
|
.IP 1)
|
||||||
|
The RIFF standard defines a
|
||||||
|
.I cset
|
||||||
|
chunk which declares a Windows codepage for character encoding, along with a
|
||||||
|
native country code, language and dialect, which clients should use for
|
||||||
|
determining text information. We have never seen a WAVE
|
||||||
|
file with a
|
||||||
|
.I cest
|
||||||
|
chunk.
|
||||||
|
.IP 2)
|
||||||
|
Certain RIFF chunks allow the writing client to override the default encoding.
|
||||||
|
Relevant to audio files are the
|
||||||
|
.I ltxt
|
||||||
|
chunk, which encodes a country, language, dialect and codepage along with a
|
||||||
|
time range text note. We have never seen the text field on one of these
|
||||||
|
filled-out either.
|
||||||
|
.PP
|
||||||
|
Some clients in our experience simply write UTF-8 into
|
||||||
|
.IR cue ,
|
||||||
|
.IR labl ,
|
||||||
|
and
|
||||||
|
.I note
|
||||||
|
fields without any kind of framing.
|
||||||
|
.PP
|
||||||
|
The practical solution at this time is to assume either ISO Latin 1, Windows
|
||||||
|
CP 859 or Windows CP 1252, and allow the client or user to override this based
|
||||||
|
on its own inferences. The
|
||||||
|
.I chardet
|
||||||
|
python package may provide useable guesses for text encoding, YMMV.
|
||||||
.SH CHUNK MENAGERIE
|
.SH CHUNK MENAGERIE
|
||||||
A list of chunks that you may find in a wave file from our experience.
|
A list of chunks that you may find in a wave file from our experience.
|
||||||
.SS Essential WAV Chunks
|
.SS Essential WAV Chunks
|
||||||
|
|||||||
Reference in New Issue
Block a user