Siren sound objects can be read from and written to sound files using an external interface to Eric DeCastro's libSndFile library. This supports all popular (and many very obscure) sound file formats.
Store a swept sine to a file
[(SampledSound sweepDur: 2.0 rate: 44100 from: 30 to: 300 chans: 1)
storeOnFileNamed: 'sweep.aiff']
Look at the file using your favorite sound file editor, or do
[(SampledSound fromFile: 'sweep.aiff') edit]
Read various file formats
[(SampledSound fromFile: 'unbelichtet.aiff') edit]
[(SampledSound fromFile: 'kombination1a.snd') edit]
To support real-time streaming sound recording and playback, an external interface is provided to the cross-platform PortAudio library. The singleton instance of PortAudioPort communicates with the external driver. As with the MIDI port, the sound port object loads and maintains a device table. For my system, this is,
Sound Device Table
1: Built-in Microphone 2 in 0 out 44100 Hz
2: Built-in Line Input 2 in 0 out 44100 Hz
3: Built-in Output 0 in 2 out 44100 Hz
4: TASCAM FW-1804 8 in 8 out 96000 Hz
To play a sound file using the default external utility , use
[Sound playFile: 'unbelichtet.aiff']
(see the method SirenUtility playSoundFile: to change the actual command line,)
This example plays a 3-second sine wave sweep
[PortAudioPort playSweep]
Same only 20 seconds long
[PortAudioPort playSweepLong]
The class SoundPort is abstract and has two subclasses: PortAudioPort and SmartAudioPort. SmartAudioPort uses call-backs from the C callback into Smalltalk. It works for recording and playback, but is still buggy (clicks a lot); see the class examples.