Squeak Class Documentation category index | class index  
 
SoundCodec
  category: Sound-Synthesis
  superclass: Object
  subclasses: WaveletCodec MuLawCodec GSMCodec ADPCMCodec

I am an abstract class that describes the protocol for sound codecs. Each codec (the name stems from "COder/DECoder") describes a particular algorithm for compressing and decompressing sound data. Most sound codecs are called 'lossy' because they lose information; the decompressed sound data is not exactly the same as the original data.

instance methods
  compress/decompress
  compressAndDecompress:
compressSound:
compressSound:atRate:
decompressSound:

  private
  decodeCompressedData:
encodeSoundBuffer:
frameCount:

  subclass responsibilities
  bytesPerEncodedFrame
decodeFrames:from:at:into:at:
encodeFrames:from:at:into:at:
reset
samplesPerFrame

class methods
  no messages
 

instance methods
  compress/decompress top  
 

compressAndDecompress:

Compress and decompress the given sound. Useful for testing.


 

compressSound:

Compress the entirety of the given sound with this codec. Answer a CompressedSoundData.


 

compressSound:atRate:

Compress the entirety of the given sound with this codec. Answer a CompressedSoundData.


 

decompressSound:

Decompress the entirety of the given compressed sound with this codec and answer the resulting sound.


  private top  
 

decodeCompressedData:

Decode the entirety of the given encoded data buffer with this codec. Answer a monophonic SoundBuffer containing the uncompressed samples.


 

encodeSoundBuffer:

Encode the entirety of the given monophonic SoundBuffer with this codec. Answer a ByteArray containing the compressed sound data.


 

frameCount:

Compute the frame count for this byteArray. This default computation will have to be overridden by codecs with variable frame sizes.


  subclass responsibilities 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.


 

reset

Reset my encoding and decoding state. Optional. This default implementation does nothing.


 

samplesPerFrame

Answer the number of sound samples per compression frame.


class methods
  no messages top