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

I implement a streaming player for MPEG or MP3 files.
Example of use:
(StreamingMP3Sound onFileNamed: 'song.mp3') play.

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

  converting
  storeSunAudioOn:compressionType:

  file ops
  closeFile
mpegFileIsOpen

  initialization
  initMPEGFile:streamIndex:

  playing
  millisecondsSinceStart
playSampleCount:into:startingAt:
reset
samplesRemaining

  private
  createMixer
loadBuffersForSampleCount:

class methods
  instance creation
  onFileNamed:

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.


  converting top  
 

storeSunAudioOn:compressionType:

Store myself on the given stream as a monophonic sound compressed with the given type of compression. The sampling rate is reduced to 22050 samples/second if it is higher.


  file ops top  
 

closeFile

Close the MP3 or MPEG file.


 

mpegFileIsOpen

Answer true if I have an open, valid MPEG file handle. If the handle is not valid, try to re-open the file.


  initialization top  
 

initMPEGFile:streamIndex:

Initialize for playing the given stream of the given MPEG or MP3 file.


  playing top  
 

millisecondsSinceStart

Answer the number of milliseconds since 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 until the end of this sound. A sound with an indefinite ending time should answer some large integer such as 1000000.


  private top  
 

createMixer

Create a mixed sound consisting of sampled sounds with one sound buffer's worth of samples. The sound has the same sampling rate and number of channels as the MPEG or MP3 file.


 

loadBuffersForSampleCount:

Load the sound buffers for all tracks with the next count samples from the MPEG file sound track.


class methods
  instance creation top  
 

onFileNamed:

Answer an instance of me for playing the sound track of the MPEG or MP3 file with the given name. Answer nil the file is not a valid MPEG or MP3 file.