Tk Library Source Code

View Ticket
Login
Ticket UUID: 840568
Title: fileType: Detect audio
Type: RFE Version: None
Submitter: andreas_kupries Created on: 2003-11-12 08:31:17
Subsystem: fileutil Assigned To: andreas_kupries
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2005-10-01 02:08:21
Resolution: Closed By: andreas_kupries
    Closed on: 2005-09-30 19:08:21
Description:
Extend fileType to detect various audio file formats:
wav
ogg
mp3
ra (real audio)

....
From the sox(1) manpage, a list of other audio formats.

       .8svx     Amiga 8SVX musical instrument
description format.

       .aiff     AIFF files used on Apple IIc/IIgs and
SGI.  Note: the AIFF format supports only one SSND
chunk.  It does not  support  multiple
                 sound  chunks,  or  the  8SVX  musical
instrument description format.  AIFF files are
multimedia archives and can have multiple
                 audio and picture chunks.  You may
need a separate archiver to work with them.

       .au       SUN Microsystems AU files.  There are
apparently many types of .au files; DEC has invented
its own with a different magic  num­
                 ber  and  word  order.  The .au
handler can read these files but will not write them. 
Some .au files have valid AU headers and
                 some do not.  The latter are probably
original SUN u-law 8000 hz samples.  These can be dealt
with using the  .ul  format  (see
                 below).

       .avr      Audio Visual Research
                 The AVR format is produced by a number
of commercial packages on the Mac.

       .cdr      CD-R
                 CD-R  files  are  used in mastering
music on Compact Disks.  The audio data on a CD-R disk
is a raw audio file with a format of
                 stereo 16-bit signed samples at a
44khz sample rate.  There is a special blocking/padding
oddity at the end of the  audio  file
                 and is why it needs its own handler.

       .cvs      Continuously Variable Slope Delta
modulation
                 Used to compress speech audio for
applications such as voice mail.

       .dat      Text Data files
                 These  files  contain a textual
representation of the sample data.  There is one line
at the beginning that contains the sample
                 rate.  Subsequent lines contain two
numeric data items: the time since the beginning of the
first sample and the sample  value.
                 Values  are  normalized  so that the
maximum and minimum are 1.00 and -1.00.  This file
format can be used to create data files
                 for external programs such as FFT
analyzers or graph routines.  SoX can also convert a
file in this format back into one of the
                 other file formats.

       .gsm      GSM 06.10 Lossy Speech Compression
                 A  standard  for  compressing speech
which is used in the Global Standard for Mobil
telecommunications (GSM).  Its good for its
                 purpose, shrinking audio data size,
but it will introduce lots of noise when a given sound
sample is encoded and decoded multi­
                 ple times.  This format is used by
some voice mail applications.  It is rather CPU intensive.
                 GSM  in SoX is optional and requires
access to an external GSM library.  To see if there is
support for gsm run sox -h and look
                 for it under the list of supported
file formats.

       .hcom     Macintosh HCOM files.  These are
(apparently) Mac FSSD files with some variant of
Huffman compression.  The Macintosh has wacky
                 file  formats and this format handler
apparently doesn't handle all the ones it should.  Mac
users will need your usual arsenal
       .maud     An Amiga format
                 An IFF-conform sound file type,
registered by MS MacroSystem Computer GmbH, published
along with the  "Toccata"  sound-card  on
                 the Amiga.  Allows 8bit linear, 16bit
linear, A-Law, u-law in mono and stereo.

       .nul      Null  file  handler.  This is a fake
file hander that act as if its reading a stream of 0's
from a while or fake writing output
                 to a file.  This is not a very useful
file handler in most cases.  It might be useful in some
scripts were you do not  want  to
                 read or write from a real file but
would like to specify a filename for consistency.

       .ogg      Ogg Vorbis Compressed Audio.
                 Ogg  Vorbis  is  a open, patent-free
CODEC designed for compressing music and streaming
audio.  It is similar to MP3, VQF, AAC,
                 and other lossy formats.  SoX can
decode all types of Ogg Vorbis files, but can only
encode at 128 kbps.  Decoding is  somewhat
                 CPU intensive and encoding is very CPU
intensive.
                 Ogg  Vorbis in SoX is optional and
requires access to external Ogg Vorbis libraries.  To
see if there is support for Ogg Vorbis
                 run sox -h and look for it under the
list of supported file formats as "vorbis".

       ossdsp    OSS /dev/dsp device driver
                 This is a pseudo-file type and can be
optionally compiled into SoX.  Run sox -h to see if you
have support for this file  type.
                 When  this driver is used it allows
you to open up the OSS /dev/dsp file and configure it
to use the same data format as passed
                 in to SoX.  It works for both playing
and recording sound samples.  When playing sound files
it attempts  to  set  up  the  OSS
                 driver to use the same format as the
input file.  It is suggested to always override the
output values to use the highest qual­
                 ity samples your sound card can
handle.  Example: -t ossdsp -w -s /dev/dsp

       .sf       IRCAM Sound Files.
                 Sound Files are used by academic music
software such as the CSound package, and the MixView
sound sample editor.

       .sph
                 SPHERE (SPeech HEader Resources) is a
file format defined by NIST (National Institute of
Standards and Technology) and is  used
                 with  speech audio.  SoX can read
these files when they contain u-law and PCM data.  It
will ignore any header information that
                 says the data is compressed using
shorten compression and will treat the data as either
u-law or PCM.  This will allow SoX  and
                 the command line shorten program to be
ran together using pipes to uncompress the data and
then pass the result to SoX for pro­
                 cessing.

       .smp      Turtle Beach SampleVision files.
                 SMP files are for use with the PC-DOS
package SampleVision by Turtle Beach Softworks. This
package is for communication to sev­
                 eral  MIDI  samplers. All sample rates
are supported by the package, although not all are
supported by the samplers themselves.
                 Currently loop points are ignored.

       .snd
                 Under DOS this file format is the same
as the .sndt format.  Under all other platforms it is
the same as the .au format.

       .sndt     SoundTool files.
                 This is an older DOS file format.

       sunau     Sun /dev/audio device driver
                 This is a pseudo-file type and can be
optionally compiled into SoX.  Run sox -h to see if you
have support for this file  type.
                 When this driver is used it allows you
to open up a Sun /dev/audio file and configure it to
use the same data type as passed in
                 to SoX.  It works for both playing and
recording sound samples.  When playing sound files it 
attempts  to  set  up  the  audio
                 driver to use the same format as the
input file.  It is suggested to always override the
output values to use the highest qual­
                 ity samples your hardware can handle.
 Example: -t sunau -w -s /dev/audio or -t sunau -U -c 1
/dev/audio for older  sun  equip­
                 ment.

       .txw      Yamaha TX-16W sampler.
                 A  file  format from a Yamaha sampling
keyboard which wrote IBM-PC format 3.5" floppies. 
Handles reading of files which do not
                 have the sample rate field set to one
of the expected by looking at some other bytes in  the
 attack/loop  length  fields,  and
                 defaulting to 33kHz if the sample rate
is still unknown.

       .vms      More info to come.
                 Used to compress speech audio for
applications such as voice mail.

       .voc      Sound Blaster VOC files.
                 VOC  files  are  multi-part and
contain silence parts, looping, and different sample
rates for different chunks.  On input, the
                 silence parts are filled out, loops
are rejected, and sample data with a new sample rate is
rejected.  Silence with a different
                 sample  rate is generated
appropriately.  On output, silence is not detected, nor
are impossible sample rates.  Note, this ver­
                 sion now supports playing VOC files
with multiple blocks and supports playing files
containing u-law and A-law samples.

       vorbis    See .ogg format.

       .wav      Microsoft .WAV RIFF files.
                 These appear to be very similar to IFF
files, but not the same.  They are the native sound
file format of Windows.  (Obviously,
                 Windows  was  of such incredible
importance to the computer industry that it just had to
have its own sound file format.)  Nor­
                 mally .wav files have all formatting
information in their headers, and so do not need any
format options specified for an input
                 file.  If any are, they will override
the file header, and you will be warned to this effect.
 You had better know what you are
                 doing! Output format options will
cause a format conversion, and the .wav will written
appropriately.  SoX currently  can  read
                 PCM, ULAW, ALAW, MS ADPCM, and IMA (or
DVI) ADPCM.  It can write all of these formats
including (NEW!)  the ADPCM encoding.

       .wve      Psion 8-bit A-law
                 These are 8-bit A-law 8khz sound files
used on the Psion palmtop portable computer.
User Comments: andreas_kupries added on 2005-10-01 02:08:21:
Logged In: YES 
user_id=75003

This is IMHO now done with the fumagic aka fileutil::magic
package and its commands.

afaupell added on 2004-05-31 03:32:35:
Logged In: YES 
user_id=812825

added tests for mpeg audio and wave