Here is a simple example (also see Chris's answer from last year):
| samplesFilename samplesFile writeBuffer |
"Ask for the file name."
samplesFilename :=
HostDriverInterface
putFileWithPrompt: 'Save as samples file named:'
initially: 'untitled.aif' asFilename
fileTypes: (Array with: HostDriverInterface aiffFileType)
ifCancel: [^ self abortForKyma].
"Create a SamplesFile and set up its header."
samplesFile := SamplesFile fromNewFilename: samplesFilename.
samplesFile
format: #aiff;
isBigEndian: true;
channels: 1;
sampleRate: SignalProcessor sampleRate;
sampleSize: 24;
sampleFrames: 0;
writeHeader.
"Get a stream to write samples."
writeBuffer := samplesFile writeBuffer.
"Output the sample values."
0 to: 4095 do: [ :i | writeBuffer writeSample: i / 4095.0].
"Close the stream."
writeBuffer close.