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

This is a simple ADPCM (adapative delta pulse code modulation) codec. This is a general audio codec that compresses speech, music, or sound effects equally well, and works at any sampling rate (i.e., it contains no frequency-sensitive filters). It compresses 16-bit sample data down to 5, 4, 3, or 2 bits per sample, with lower fidelity and increased noise at the lowest bit rates. Although it does not deliver state-of-the-art compressions, the alorithm is small, simple, and extremely fast, since the encode/decode primitives have been translated into C primitives.

This codec will also encode and decode all Flash .swf file compressed sound formats, both mono and stereo. (Note: stereo Flash compression is not yet implemented, but stereo decompression works.)

instance methods
  as yet unclassified
  decode:bitsPerSample:
decode:sampleCount:bitsPerSample:frameSize:stereo:
decodeFlash:sampleCount:stereo:
encode:bitsPerSample:
encodeFlashLeft:right:bitsPerSample:
encodeLeft:right:bitsPerSample:frameSize:forFlash:
headerBitsForSampleCount:stereoFlag:
indexForDeltaFrom:to:
initializeForBitsPerSample:samplesPerFrame:
privateDecodeMono:
privateDecodeStereo:
privateEncodeMono:
privateEncodeStereo:

  bit streaming
  nextBits:
nextBits:put:

  codec stuff
  bytesPerEncodedFrame
compressAndDecompress:
decodeFrames:from:at:into:at:
encodeFrames:from:at:into:at:
resetForMono
resetForStereo
samplesPerFrame

class methods
  instance creation
  new
newBitsPerSample:

  primitive generation
  translatedPrimitives

instance methods
  as yet unclassified top  
 

decode:bitsPerSample:


 

decode:sampleCount:bitsPerSample:frameSize:stereo:


 

decodeFlash:sampleCount:stereo:


 

encode:bitsPerSample:


 

encodeFlashLeft:right:bitsPerSample:


 

encodeLeft:right:bitsPerSample:frameSize:forFlash:


 

headerBitsForSampleCount:stereoFlag:

Answer the number of extra header bits required for the given number of samples. This will be zero if I am not using frame headers.


 

indexForDeltaFrom:to:

Answer the best index to use for the difference between the given samples.


 

initializeForBitsPerSample:samplesPerFrame:


 

privateDecodeMono:


 

privateDecodeStereo:


 

privateEncodeMono:


 

privateEncodeStereo:


  bit streaming top  
 

nextBits:

Answer the next n bits of my bit stream as an unsigned integer.


 

nextBits:put:

Write the next n bits to my bit stream.


  codec stuff top  
 

bytesPerEncodedFrame

Answer the number of bytes required to hold one frame of compressed sound data.


 

compressAndDecompress:

Compress and decompress the given sound. Overridden to use same bits per sample for both compressing and decompressing.


 

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.


 

resetForMono

Reset my encoding and decoding state for mono.


 

resetForStereo

Reset my encoding and decoding state for stereo.


 

samplesPerFrame

Answer the number of sound samples per compression frame.


class methods
  instance creation top  
 

new

Answer a new instance of the receiver (which is a class) with no indexable variables. Fail if the class is indexable.


 

newBitsPerSample:


  primitive generation top  
 

translatedPrimitives

Answer a string containing the translated C code for my primitives.