Squeak Class Documentation category index | class index  
 
SampledSound
  category: Sound-Synthesis
  superclass: AbstractSound
  subclasses:

No comment. Sorry.

instance methods
  accessing
  compressWith:
compressWith:atRate:
duration
duration:
originalSamplingRate
samples

  initialization
  pitch:
setPitch:dur:loudness:
setSamples:samplingRate:

  playing
  endGracefully
mixSampleCount:into:startingAt:leftVol:rightVol:
playSilentlyUntil:
reset
samplesRemaining
setScaledIncrement:
stopAfterMSecs:

  sound tracks
  sonogramMorph:from:to:nPoints:
volumeForm:from:to:nSamplesPerPixel:

class methods
  WAV reading
  next16BitWord:from:
next32BitWord:from:
readWaveChunk:inRIFF:

  class initialization
  initialize

  coffee cup clink
  coffeeCupClink
initializeCoffeeCupClink

  default sound
  defaultSampleTable:
defaultSamples:repeated:
nominalSamplePitch:
useCoffeeCupClink

  instance creation
  fromAIFFStream:
fromAIFFfileNamed:
fromWaveFileNamed:
fromWaveStream:
samples:samplingRate:

  sound library
  addLibrarySoundNamed:fromAIFFfileNamed:
addLibrarySoundNamed:samples:samplingRate:
playSoundNamed:
putCoffeeCupClinkInSoundLibrary
removeSoundNamed:
soundLibrary
soundNamed:
soundNamed:ifAbsent:
soundNames
unusedSoundNameLike:

  utilities
  convert8bitSignedFrom:to16Bit:
convert8bitSignedTo16Bit:
convert8bitUnsignedTo16Bit:
convertBytesTo16BitSamples:mostSignificantByteFirst:
uLawDecode:
uLawDecodeTable
uLawEncode:
uLawEncodeSample:

instance methods
  accessing top  
 

compressWith:


 

compressWith:atRate:


 

duration


 

duration:

Scale my envelopes to the given duration. Subclasses overriding this method should include a resend to super.


 

originalSamplingRate


 

samples


  initialization top  
 

pitch:


 

setPitch:dur:loudness:

Used to play scores using the default sample table.


 

setSamples:samplingRate:

Set my samples array to the given array with the given nominal sampling rate. Altering the rate parameter allows the sampled sound to be played back at different pitches.


  playing top  
 

endGracefully

See stopGracefully, which affects initialCOunt, and I don't think it should (di).


 

mixSampleCount:into:startingAt:leftVol:rightVol:

Mix the given number of samples with the samples already in the given buffer starting at the given index. Assume that the buffer size is at least (index + count) - 1.


 

playSilentlyUntil:

Used to fast foward to a particular starting time.
Overridden to be instant for sampled sounds.


 

reset

Details: The sample index and increment are scaled to allow fractional increments without having to do floating point arithmetic in the inner loop.


 

samplesRemaining

Answer the number of samples remaining until the end of this sound. A sound with an indefinite ending time should answer some large integer such as 1000000.


 

setScaledIncrement:


 

stopAfterMSecs:

Terminate this sound this note after the given number of milliseconds.


  sound tracks top  
 

sonogramMorph:from:to:nPoints:

FYI: It is very cool that we can do this, but for sound tracks on a movie,
simple volume is easier to read, easier to scale, and way faster to compute.
Code preserved here just in case it makes a useful example.


 

volumeForm:from:to:nSamplesPerPixel:

Note: nPerPixel can be Integer or Float for pixel-perfect alignment.


class methods
  WAV reading top  
 

next16BitWord:from:

Read a 16-bit positive integer from the input stream.


 

next32BitWord:from:

Read a 32-bit positive integer from the input stream.


 

readWaveChunk:inRIFF:

Search the stream for a format chunk of the given type and return its contents.


  class initialization top  
 

initialize

SampledSound initialize


  coffee cup clink top  
 

coffeeCupClink

Return the samples array for the sound of a spoon being tapped against a coffee cup.


 

initializeCoffeeCupClink

Initialize the samples array for the sound of a spoon being tapped against a coffee cup.


  default sound top  
 

defaultSampleTable:

Set the sample table to be used as the default waveform for playing a score such as the Bach fugue. Array is assumed to contain monaural signed 16-bit sample values.


 

defaultSamples:repeated:


 

nominalSamplePitch:

Record an estimate of the normal pitch of the sampled sound.


 

useCoffeeCupClink

Set the sample table to be used as the default waveform to the sound of a coffee cup being tapped with a spoon.


  instance creation top  
 

fromAIFFStream:


 

fromAIFFfileNamed:

Read a SampledSound from the AIFF file of the given name, merging stereo to mono if necessary.


 

fromWaveFileNamed:

(SampledSound fromWaveFileNamed: 'c:\windows\media\chimes.wav') play


 

fromWaveStream:


 

samples:samplingRate:

Return a SampledSound with the given samples array and sampling rate.


  sound library top  
 

addLibrarySoundNamed:fromAIFFfileNamed:

Add a sound from the given AIFF file to the library.


 

addLibrarySoundNamed:samples:samplingRate:

Add the given sound to the sound library. The sample data may be either a ByteArray or a SoundBuffer. If the former, it is take to be 8-bit unsigned samples. If the latter, it is taken to be 16 bit signed samples.


 

playSoundNamed:

Play the sound with given name. Do nothing if there is no sound of that name in the library.


 

putCoffeeCupClinkInSoundLibrary

SampledSound putCoffeeCupClinkInSoundLibrary


 

removeSoundNamed:

Remove the sound with the given name from the sound library.


 

soundLibrary

Answer the sound library dictionary.


 

soundNamed:

Answer the sound of the given name, or, if there is no sound of that name, put up an informer so stating, and answer nil


 

soundNamed:ifAbsent:

Answer the sound of the given name, or if there is no sound of that name, answer the result of evaluating aBlock


 

soundNames

Answer a list of sound names for the sounds stored in the sound library.


 

unusedSoundNameLike:

Pick an unused sound name based on the given string. If necessary, append digits to avoid name conflicts with existing sounds.


  utilities top  
 

convert8bitSignedFrom:to16Bit:

Copy the contents of the given array of signed 8-bit samples into the given array of 16-bit signed samples.


 

convert8bitSignedTo16Bit:

Convert the given array of samples--assumed to be 8-bit signed, linear data--into 16-bit signed samples. Return an array containing the resulting samples. Typically used to read uncompressed AIFF sound data.


 

convert8bitUnsignedTo16Bit:

Convert the given array of samples--assumed to be 8-bit unsigned, linear data--into 16-bit signed samples. Return an array containing the resulting samples. Typically used to read uncompressed WAVE sound data.


 

convertBytesTo16BitSamples:mostSignificantByteFirst:

Convert the given ByteArray (with the given byte ordering) into 16-bit sample buffer.


 

uLawDecode:

Convert the given array of uLaw-encoded 8-bit samples into a SoundBuffer of 16-bit signed samples.


 

uLawDecodeTable

Return a 256 entry table to be used to decode 8-bit uLaw-encoded samples.


 

uLawEncode:

Convert the given array of 16-bit signed samples into a ByteArray of uLaw-encoded 8-bit samples.


 

uLawEncodeSample:

Encode the given 16-bit signed sample using the uLaw 8-bit encoding.