Squeak Class Documentation category index | class index  
 
SampledInstrument
  category: Sound-Synthesis
  superclass: Object
  subclasses:

I represent a collection of individual notes at different pitches, volumes, and articulations. On request, I can select the best note to use for a given pitch, duration, and volume. I currently only support two volumes, loud and soft, and two articulations, normal and staccato, but I can easily be extended to include more. The main barrier to keeping more variations is simply the memory space (assuming my component notes are sampled sounds).

instance methods
  accessing
  allSampleSets:
initialize
loudThreshold
loudThreshold:
staccatoLoudAndSoftSampleSet:
staccatoLoudSampleSet:
staccatoSoftSampleSet:
sustainedLoudSampleSet:
sustainedSoftSampleSet:
sustainedThreshold
sustainedThreshold:

  other
  allNotes
chooseSamplesForPitch:from:
memorySpace
midiKeyMapFor:
playChromaticRunFrom:to:
pruneNoteList:notesPerOctave:
pruneToNotesPerOctave:
pruneToSingleNote:
readSampleSetFrom:
readSampleSetInfoFrom:
testAtPitch:
trimAttackOf:threshold:
trimAttacks:

  playing
  soundForMidiKey:dur:loudness:
soundForPitch:dur:loudness:

class methods
  instance creation
  buildSmallOrchestra
new
readLoudAndStaccatoInstrument:fromDirectory:
readPizzInstrument:fromDirectory:
readSimpleInstrument:fromDirectory:

instance methods
  accessing top  
 

allSampleSets:


 

initialize


 

loudThreshold


 

loudThreshold:


 

staccatoLoudAndSoftSampleSet:


 

staccatoLoudSampleSet:


 

staccatoSoftSampleSet:


 

sustainedLoudSampleSet:


 

sustainedSoftSampleSet:


 

sustainedThreshold


 

sustainedThreshold:


  other top  
 

allNotes

Answer a collection containing of all the unique sampled sounds used by this instrument.


 

chooseSamplesForPitch:from:

From the given collection of LoopedSampledSounds, choose the best one to be pitch-shifted to produce the given pitch.


 

memorySpace

Answer the number of bytes required to store the samples for this instrument.


 

midiKeyMapFor:

Return a 128 element array that maps each MIDI key number to the sampled note from the given set with the closests pitch. A precise match isn't necessary because the selected note will be pitch shifted to play at the correct pitch.


 

playChromaticRunFrom:to:


 

pruneNoteList:notesPerOctave:

Return a pruned version of the given note list with only the given number of notes per octave. Assume the given notelist is in sorted order.


 

pruneToNotesPerOctave:

Prune all my keymaps to the given number of notes per octave.


 

pruneToSingleNote:

Fill all my keymaps with the given note.


 

readSampleSetFrom:

Answer a collection of sounds read from AIFF files in the given directory and sorted in ascending pitch order.


 

readSampleSetInfoFrom:

MessageTally spyOn: [SampledInstrument new readSampleSetFrom: 'Tosh:Desktop Folder:AAA Squeak2.0 Beta:Organ Samples:Flute8'] timeToRun


 

testAtPitch:

SampledInstrument testAtPitch: 'c4'


 

trimAttackOf:threshold:

Trim 'silence' off the initial attacks of the given sound buffer.


 

trimAttacks:

Trim 'silence' off the initial attacks all my samples.


  playing top  
 

soundForMidiKey:dur:loudness:

Answer an initialized sound object 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 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.


class methods
  instance creation top  
 

buildSmallOrchestra

Example of how to build a skeleton orchestra that uses less memory (about 14 MBytes).


 

new

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


 

readLoudAndStaccatoInstrument:fromDirectory:

SampledInstrument
readLoudAndStaccatoInstrument: 'oboe'
fromDirectory: 'Tosh:Sample Library:Orchestra'


 

readPizzInstrument:fromDirectory:

SampledInstrument
readPizzInstrument: 'violin'
fromDirectory: 'Tosh:Sample Library:Orchestra'


 

readSimpleInstrument:fromDirectory:

SampledInstrument
readSimpleInstrument: 'oboe'
fromDirectory: 'Tosh:Sample Library:Orchestra'