[comp.sys.sun] Description of SPARC soundfile format?

sandell@ferret.ils.nwu.edu (Greg Sandell) (11/12/89)

Does anybody know the file format for soundfiles on the SPARC?  I checked
all three of the following, and none of them had this information:

	SUN OS manual, chapt. 5, FILE FORMATS
	SUN OS manual, chapt. 4, DEVICES AND NETWORKING
	SPARCstation 1 SunOS 4.0.3 Sun 4-C RElease notes,
		section 5.18, "SPARCstation 1 Audio Demonstration
		Program"

They are clearly non-ascii files (as an examination of the sample file
'sample.au' reveals), but are the values long floats, or what?

Sorry if this has been discussed in this group previously.

Thanks in advance,
Greg Sandell

richard@aiai.edinburgh.ac.uk (Richard Tobin) (11/15/89)

> They are clearly non-ascii files (as an examination of the sample file
> 'sample.au' reveals), but are the values long floats, or what?

No, they're just bytes.  They're represented slightly strangely: a byte
with value n in the file means 384-n if n > 128, otherwise it means n.

-- Richard

gopstein@rutgers.edu (Rich Gopstein) (11/15/89)

In article <2967@brazos.Rice.edu>, sandell@ferret.ils.nwu.edu (Greg Sandell) writes:
> Does anybody know the file format for soundfiles on the SPARC?  I checked
> all three of the following, and none of them had this information:

A quick look through /usr/demo/sound/sound.c and the related .h files will
tell you that the format the files are in is called uLAW format.  (that's
actually Mu-LAW format).  It appears that the chip can handle aLAW and
straight binary formats also, but I'm not sure how.

The sampling speed is 8k samples/second.  Each waveform sample is stored
in one byte in uLAW format.  uLAW format is a simple data compression
format designed to store audio waveforms in one-byte samples.

I will post my sampled-binary to uLAW conversion program soon, there has
been enough interest in it.

Rich Gopstein
..!rutgers!soleil!gopstein

jef@well.sf.ca.us (Jef Poskanzer) (11/21/89)

}> They are clearly non-ascii files (as an examination of the sample file
}> 'sample.au' reveals), but are the values long floats, or what?
}
}No, they're just bytes.  They're represented slightly strangely: a byte
}with value n in the file means 384-n if n > 128, otherwise it means n.

Not really.  That's good enough to graph the general shape of the
waveform, which is what the sound demo uses it for.  But if you tried to
use that conversion to actually generate a waveform you would get garbage.
The actual format is a little more complicated -- it's an eight-bit
floating-point number.  One bit of sign, three bits of exponent, and four
bits of mantissa.

I have posted some simple SPARC sound tools to alt.sources, since it looks
like no one else has done so.  They include filters to convert between
this format, called u-law (pronounced "mu-law"), and linear.  Of course,
by the time this message appears in comp.sys.sun, the sound tools will
have expired on most systems (average expire time is 7 days).  Hopefully
most comp.sys.sun readers also read alt.sys.sun, where this announcement
appeared in a timely fashion.  --- Jef

[[Ed's Note: Just out of spite, I'm going to make sure this goes out 
today (11/22) :) That's pretty harsh commentary up there :( -bdg]]

  Jef Poskanzer  jef@well.sf.ca.us  {ucbvax, apple, hplabs}!well!jef
                    %SYS-F-ACCVIO, Access violation