Squeak Class Documentation category index | class index  
 
AbstractSound
  category: Sound-Synthesis
  superclass: Object
  subclasses: RepeatingSound ScorePlayer SequentialSound RestSound ReverbSound FMSound PluckedSound LoopedSampledSound SampledSound MixedSound QueueSound StreamingMonoSound StreamingMP3Sound

No comment. Sorry.

instance methods
  composition
  +
,
asSound
delayedBy:

  conversion
  asSampledSound

  copying
  copy
copyEnvelopes
sounds

  envelopes
  addEnvelope:
envelopes
removeAllEnvelopes
removeEnvelope:

  file i/o
  storeAIFFOnFileNamed:
storeAIFFSamples:samplingRate:on:
storeExtendedFloat:on:
storeWAVOnFileNamed:
storeWAVSamplesSamplingRate:on:

  initialization
  duration:
initialize
loudness:
nameOrNumberToPitch:
setPitch:dur:loudness:
soundForMidiKey:dur:loudness:
soundForPitch:dur:loudness:

  playing
  computeSamplesForSeconds:
isPlaying
millisecondsSinceStart
pause
play
playAndWaitUntilDone
playChromaticRunFrom:to:
playSampleCount:into:startingAt:
playSilently
playSilentlyUntil:
resumePlaying
viewSamples

  sampling rates
  controlRate
samplingRate

  sound generation
  doControl
internalizeModulationAndRatio
mixSampleCount:into:startingAt:leftVol:rightVol:
reset
samplesRemaining
stopAfterMSecs:
stopGracefully
storeSample:in:at:leftVol:rightVol:
updateVolume

  volume
  adjustVolumeTo:overMSecs:
initialVolume:
loudness
volumeEnvelopeScaledTo:

class methods
  class initialization
  initialize
scaleFactor

  examples
  chromaticPitchesFrom:
chromaticRunFrom:to:on:
chromaticScale
chromaticScaleOn:
hiMajorScale
hiMajorScaleOn:
lowMajorScale
lowMajorScaleOn:
majorChord
majorChordOn:from:
majorPitchesFrom:
majorScale
majorScaleOn:
majorScaleOn:from:
majorScaleOn:from:octaves:
scaleTest
testFMInteractively

  examples-bach fugue
  bachFugue
bachFugueOn:
bachFugueVoice1On:
bachFugueVoice2On:
bachFugueVoice3On:
bachFugueVoice4On:
stereoBachFugue

  instance creation
  default
dur:
new
noteSequenceOn:from:
pitch:dur:loudness:

  primitive generation
  translatedPrimitives

  sound library
  initSounds
soundNamed:
soundNamed:ifAbsent:
soundNamed:put:
soundNames
sounds
updateFMSounds

  sound library-file in/out
  fileInSoundLibrary
fileInSoundLibraryNamed:
fileOutSoundLibrary
fileOutSoundLibrary:
storeFiledInSound:named:
unloadSampledTimbres
unloadSoundNamed:
unloadedSound
updateScorePlayers

  utilities
  busySignal:
dial:
dialTone:
hangUpWarning:
indexOfBottomOctavePitch:
midiKeyForPitch:
pitchForMIDIKey:
pitchForName:
pitchTable

instance methods
  composition top  
 

+

Return the mix of the receiver and the argument sound.


 

,

Return the concatenation of the receiver and the argument sound.


 

asSound


 

delayedBy:

Return a composite sound consisting of a rest for the given amount of time followed by the receiver.


  conversion top  
 

asSampledSound


  copying top  
 

copy

A sound should copy all of the state needed to play itself, allowing two copies of a sound to play at the same time. These semantics require a recursive copy but only down to the level of immutable data. For example, a SampledSound need not copy its sample buffer. Subclasses overriding this method should include a resend to super.


 

copyEnvelopes

Private! Support for copying. Copy my envelopes.


 

sounds

Allows simple sounds to behave as, eg, sequential sounds


  envelopes top  
 

addEnvelope:

Add the given envelope to my envelopes list.


 

envelopes

Return my collection of envelopes.


 

removeAllEnvelopes

Remove all envelopes from my envelopes list.


 

removeEnvelope:

Remove the given envelope from my envelopes list.


  file i/o top  
 

storeAIFFOnFileNamed:


 

storeAIFFSamples:samplingRate:on:


 

storeExtendedFloat:on:

Store an Apple extended-precision 80-bit floating point number on the given stream.


 

storeWAVOnFileNamed:


 

storeWAVSamplesSamplingRate:on:

Write WAV sound file. Stereo, 16 bit. At the appropiate sampling rate.


  initialization top  
 

duration:

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


 

initialize


 

loudness:

Initialize my volume envelopes and initial volume. Subclasses overriding this method should include a resend to super.


 

nameOrNumberToPitch:

Answer the pitch in cycles/second for the given pitch specification. The specification can be either a numeric pitch or pitch name such as 'c4'.


 

setPitch:dur:loudness:

Initialize my envelopes for the given parameters. Subclasses overriding this method should include a resend to super.


 

soundForMidiKey:dur:loudness:

Answer an initialized sound object (a copy of the receiver) that generates a note for the given MIDI key (in the range 0..127), duration (in seconds), and loudness (in the range 0.0 to 1.0).


 

soundForPitch:dur:loudness:

Answer an initialized sound object (a copy of the receiver) that generates a note of the given pitch, duration, and loudness. Pitch may be a numeric pitch or a string pitch name such as 'c4'. Duration is in seconds and loudness is in the range 0.0 to 1.0.


  playing top  
 

computeSamplesForSeconds:

Compute the samples of this sound without outputting them, and return the resulting buffer of samples.


 

isPlaying

Return true if the receiver is currently playing


 

millisecondsSinceStart


 

pause

Pause this sound. It can be resumed from this point, or reset and resumed to start from the beginning.


 

play

Play this sound to the sound ouput port in real time.


 

playAndWaitUntilDone

Play this sound to the sound ouput port and wait until it has finished playing before returning.


 

playChromaticRunFrom:to:

Play a fast chromatic run between the given pitches. Useful for auditioning a sound.


 

playSampleCount:into:startingAt:

Mix the next n samples of this sound into the given buffer starting at the given index. Update the receiver's control parameters periodically.


 

playSilently

Compute the samples of this sound without outputting them. Used for performance analysis.


 

playSilentlyUntil:

Compute the samples of this sound without outputting them. Used to fast foward to a particular starting time. The start time is given in seconds.


 

resumePlaying

Resume playing this sound from where it last stopped.


 

viewSamples


  sampling rates top  
 

controlRate

Answer the number of control changes per second.


 

samplingRate

Answer the sampling rate in samples per second.


  sound generation top  
 

doControl

Update the control parameters of this sound using its envelopes, if any.


 

internalizeModulationAndRatio

Overridden by FMSound. This default implementation does nothing.


 

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. The leftVol and rightVol parameters determine the volume of the sound in each channel, where 0 is silence and ScaleFactor is full volume.


 

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.


 

stopAfterMSecs:

Terminate this sound this note after the given number of milliseconds. This default implementation does nothing.


 

stopGracefully

End this note with a graceful decay. If the note has envelopes, determine the decay time from its envelopes.


 

storeSample:in:at:leftVol:rightVol:

This method is provided for documentation. To gain 10% more speed when running sound generation in Smalltalk, this method is hand-inlined into all sound generation methods that use it.


 

updateVolume

Increment the volume envelope of this sound. To avoid clicks, the volume envelope must be interpolated at the sampling rate, rather than just at the control rate like other envelopes. At the control rate, the volume envelope computes the slope and next target volume volume for the current segment of the envelope (i.e., it sets the rate of change for the volume parameter). When that target volume is reached, incrementing is stopped until a new increment is set.


  volume top  
 

adjustVolumeTo:overMSecs:

Adjust the volume of this sound to the given volume, a number in the range [0.0..1.0], over the given number of milliseconds. The volume will be changed a little bit on each sample until the desired volume is reached.


 

initialVolume:

Set the initial volume of this sound to the given volume, a number in the range [0.0..1.0].


 

loudness

Answer the current volume setting for this sound.


 

volumeEnvelopeScaledTo:

Return a collection of values representing my volume envelope scaled by the given point. The scale point's x component is pixels/second and its y component is the number of pixels for full volume.


class methods
  class initialization top  
 

initialize

AbstractSound initialize


 

scaleFactor


  examples top  
 

chromaticPitchesFrom:


 

chromaticRunFrom:to:on:

Answer a composite sound consisting of a rapid chromatic run between the given pitches on the given sound.


 

chromaticScale

PluckedSound chromaticScale play


 

chromaticScaleOn:

PluckedSound chromaticScale play


 

hiMajorScale

FMSound hiMajorScale play


 

hiMajorScaleOn:

FMSound hiMajorScale play


 

lowMajorScale

PluckedSound lowMajorScale play


 

lowMajorScaleOn:

PluckedSound lowMajorScale play


 

majorChord

FMSound majorChord play


 

majorChordOn:from:

FMSound majorChord play


 

majorPitchesFrom:


 

majorScale

FMSound majorScale play


 

majorScaleOn:

FMSound majorScale play


 

majorScaleOn:from:

FMSound majorScale play


 

majorScaleOn:from:octaves:

(AbstractSound majorScaleOn: FMSound oboe1 from: #c2 octaves: 5) play


 

scaleTest

AbstractSound scaleTest play


 

testFMInteractively

Experiment with different settings of the FM modulation and multiplier settings interactively by moving the mouse. The top-left corner of the screen is 0 for both parameters. Stop when the mouse is pressed.


  examples-bach fugue top  
 

bachFugue

Play a fugue by J. S. Bach using and instance of me as the sound for all four voices.


 

bachFugueOn:

Play a fugue by J. S. Bach using the given sound as the sound for all four voices.


 

bachFugueVoice1On:

Voice one of a fugue by J. S. Bach.


 

bachFugueVoice2On:

Voice two of a fugue by J. S. Bach.


 

bachFugueVoice3On:

Voice three of a fugue by J. S. Bach.


 

bachFugueVoice4On:

Voice four of a fugue by J. S. Bach.


 

stereoBachFugue

Play fugue by J. S. Bach in stereo using different timbres.


  instance creation top  
 

default

Return a default sound prototype for this class, with envelopes if appropriate. (This is in contrast to new, which returns a raw instance without envelopes.)


 

dur:

Return a rest of the given duration.


 

new

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


 

noteSequenceOn:from:

Build a note sequence (i.e., a SequentialSound) from the given array using the given sound as the instrument. Elements are either (pitch, duration, loudness) triples or (#rest duration) pairs. Pitches can be given as names or as numbers.


 

pitch:dur:loudness:

Return a new sound object for a note with the given parameters.


  primitive generation top  
 

translatedPrimitives


  sound library top  
 

initSounds

AbstractSound initSounds


 

soundNamed:


 

soundNamed:ifAbsent:


 

soundNamed:put:


 

soundNames


 

sounds


 

updateFMSounds

AbstractSound updateFMSounds


  sound library-file in/out top  
 

fileInSoundLibrary

Prompt the user for a file name and the file in the sound library with that name.


 

fileInSoundLibraryNamed:

File in the sound library with the given file name, and add its contents to the current sound library.


 

fileOutSoundLibrary

File out the current sound library.


 

fileOutSoundLibrary:

File out the given dictionary, which is assumed to contain sound and instrument objects keyed by their names.


 

storeFiledInSound:named:

Store the given sound in the sound library. Use the given name if it isn't in use, otherwise ask the user what to do.


 

unloadSampledTimbres

This can be done to unload those bulky sampled timbres to shrink the image. The unloaded sounds are replaced by a well-known 'unloaded sound' object to enable the unloaded sounds to be detected when the process is reversed.


 

unloadSoundNamed:


 

unloadedSound

Answer a sound to be used as the place-holder for sounds that have been unloaded.


 

updateScorePlayers

Force all ScorePlayers to update their instrument list from the sound library. This may done after loading, unloading, or replacing a sound to make all ScorePlayers feel the change.


  utilities top  
 

busySignal:

AbstractSound busySignal: 3


 

dial:

AbstractSound dial: '867-5309'


 

dialTone:

AbstractSound dialTone: 2


 

hangUpWarning:

AbstractSound hangUpWarning: 20


 

indexOfBottomOctavePitch:

Answer the index of the first pitch in the bottom octave equal to or higher than the given pitch. Assume that the given pitch is below the top pitch of the bottom octave.


 

midiKeyForPitch:

Answer the midiKey closest to the given pitch. Pitch may be a numeric pitch or a pitch name string such as 'c4'.


 

pitchForMIDIKey:

Answer the pitch for the given MIDI key.


 

pitchForName:

AbstractSound pitchForName: 'c2'


 

pitchTable

AbstractSound pitchTable