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

I implement a streaming player for monophonic Sun (.au) and AIFF (.aif) audio files.
Example of use:
(StreamingMonoSound onFileNamed: 'song.aif') play.

instance methods
  accessing
  duration
repeat
repeat:
soundPosition
soundPosition:
streamSamplingRate
volume
volume:

  initialization
  initStream:headerStart:

  other
  closeFile
extractFrom:to:

  playing
  millisecondsSinceStart
playSampleCount:into:startingAt:
reset
samplesRemaining

  private
  createMixer
currentSampleIndex
loadBuffer:compressedSampleCount:
loadBuffer:uncompressedSampleCount:
loadBuffersForSampleCount:
loadFromLeftovers:sampleCount:
readAIFFHeader
readHeader
readSunAudioHeader
startOver

class methods
  instance creation
  onFileNamed:
onFileNamed:headerStart:

instance methods
  accessing top  
 

duration

Answer the duration of this sound in seconds.


 

repeat

Answer the repeat flag.


 

repeat:

Set the repeat flag. If true, this sound will loop back to the beginning when it gets to the end.


 

soundPosition

Answer the relative position of sound playback as a number between 0.0 and 1.0.


 

soundPosition:

Jump to the position the given fraction through the sound file. The argument is a number between 0.0 and 1.0.


 

streamSamplingRate

Answer the sampling rate of the MP3 stream.


 

volume

Answer my volume.


 

volume:

Set my volume to the given number between 0.0 and 1.0.


  initialization top  
 

initStream:headerStart:

Initialize for streaming from the given stream. The audio file header starts at the given stream position.


  other top  
 

closeFile

Close my stream, if it responds to close.


 

extractFrom:to:

Extract a portion of this sound between the given start and end times. The current implementation only works if the sound is uncompressed.


  playing top  
 

millisecondsSinceStart

Answer the number of milliseconds of this sound started playing.


 

playSampleCount:into:startingAt:

Mix the next n samples of this sound into the given buffer starting at the given index


 

reset

Reset my internal state for a replay. Methods that override this method should do super reset.


 

samplesRemaining

Answer the number of samples remaining to be played.


  private top  
 

createMixer

Create a mixed sound consisting of sampled sounds with one sound buffer's worth of samples.


 

currentSampleIndex

Answer the index of the current sample.


 

loadBuffer:compressedSampleCount:

Load the given sound buffer from the compressed sample stream.


 

loadBuffer:uncompressedSampleCount:

Load the given sound buffer from the uncompressed sample stream.


 

loadBuffersForSampleCount:

Load the sound buffers from the stream.


 

loadFromLeftovers:sampleCount:

Load the given sound buffer from the samples leftover from the last frame. Answer the number of samples loaded, which typically is less than sampleCount.


 

readAIFFHeader

Read an AIFF file header from stream.


 

readHeader

Read the sound file header from my stream.


 

readSunAudioHeader

Read a Sun audio file header from my stream.


 

startOver

Jump back to the first sample.


class methods
  instance creation top  
 

onFileNamed:

Answer an instance of me for playing the file with the given name.


 

onFileNamed:headerStart:

Answer an instance of me for playing audio data starting at the given position in the file with the given name.