Squeak Class Documentation category index | class index  
 
MuLawCodec
  category: Sound-Synthesis
  superclass: SoundCodec
  subclasses:

I represent a mu-law (u-law) codec. I compress sound data by a factor of 2:1 by encoding the most significant 12 bits of each 16-bit sample as a signed, exponentially encoded byte. The idea is to use more resolution for smaller lower sample values. This encoding was developed for the North American phone system and a variant of it, a-law, is a European phone standard. It is a popular sound encoding on Unix platforms (.au files).

instance methods
  external access
  uLawDecodeSample:
uLawEncodeSample:

  private
  uLawEncode12Bits:

  subclass responsibility
  bytesPerEncodedFrame
decodeFrames:from:at:into:at:
encodeFrames:from:at:into:at:
samplesPerFrame

class methods
  class initialization
  initialize

instance methods
  external access top  
 

uLawDecodeSample:

Decode a 16-bit signed sample from 8 bits using uLaw decoding


 

uLawEncodeSample:

Encode a 16-bit signed sample into 8 bits using uLaw encoding


  private top  
 

uLawEncode12Bits:

Encode a 12-bit unsigned sample (0-4095) into 7 bits using uLaw encoding.
This gets called by a method that scales 16-bit signed integers down to a
12-bit magnitude, and then ORs in 16r80 if they were negative.
Detail: May get called with s >= 4096, and this works fine.


  subclass responsibility top  
 

bytesPerEncodedFrame

Answer the number of bytes required to hold one frame of compressed sound data. Answer zero if this codec produces encoded frames of variable size.


 

decodeFrames:from:at:into:at:

Decode the given number of monophonic frames starting at the given index in the given ByteArray of compressed sound data and storing the decoded samples into the given SoundBuffer starting at the given destination index. Answer a pair containing the number of bytes of compressed data consumed and the number of decompressed samples produced.


 

encodeFrames:from:at:into:at:

Encode the given number of frames starting at the given index in the given monophonic SoundBuffer and storing the encoded sound data into the given ByteArray starting at the given destination index. Encode only as many complete frames as will fit into the destination. Answer a pair containing the number of samples consumed and the number of bytes of compressed data produced.


 

samplesPerFrame

Answer the number of sound samples per compression frame.


class methods
  class initialization top  
 

initialize

Build the 256 entry table to be used to decode 8-bit uLaw-encoded samples.