Class: SoundFile

Environment: Siren
Superclass: Siren.AbstractEvent
Category: MusicIO-Sound
Instance variables: name mode fileFormat sampleFormat rate channels size
index position sound
Indexed variables: objects
Class variables: FileFormats Interface SampleFormats

Instances of SoundFile are used for reading and writing sound objects to/from files using the libSndFile API.
They handle formatting, headers and I/O.

Instance variables:
sound the sound's samples
rate the sound's sampling rate
channels the number of channels
fileName the file's name
file the file's stream
position the current position
headerSize the size of the soundfile header
properties the property list dictionary of the receiver
format the format--currently only #linear16Bit is handled
size the size in samples

accessing

channels
Answer the instance variable 'channels'.

channels: theChannels
Accept the argument, 'theChannels', as the new instance variable 'channels'.

fileFormat

fileFormat: aValue

format

mode: theMode
Set the receiver's mode to #read or #write

name
Answer the instance variable 'name'.

name: theFileName
Accept the argument, 'theFileName', as the new instance variable 'name'.

rate
Return the instance variable 'rate'.

rate: aRate
Set the instance variable 'rate'.

sampleFormat

sampleFormat: aValue

samples
Return the instance variable 'samples'.

size
Answer the number of sample frames in the file.

size: aNumber
Set the number of sample frames in the file.

sizeInSamples
Answer the number of sample frames in the file.

sound
Answer the instance variable 'sound'.

sound: theSound
Accept the argument, 'theSound', as the new instance variable 'sound'.

read/write

readSamples
Read samples from the file into the sample buffer.

readSamples: sndClass
Read samples from the file into the sample buffer.

saveSound: snd
Write samples from the given sound to the receiver file.

printing

printOn: aStream
Format and print the receiver on the argument.

initialize-release

close
Close the receiver's file.

initialize
Set up the instance variables of a default sound file.

open
Open the named file and read the header

openForReading
Open the named file and read the header

MetaClass: SoundFile class

instance creation

named: nameString
Open the given file (EBICSF, SPARC, or NeXT soundfile format)

openFileNamed: nameString
Open the given file (EBICSF, SPARC, AIFF, or NeXT soundfile format)

readFileNamed: nameString
Open the given file (EBICSF, SPARC, or NeXT soundfile format)

readFileNamed: nameString answer: theClass
Open the given file (EBICSF, SPARC, or NeXT soundfile format)

releaseFileIndex: index
Free the given sound file index

class initialization

initialize
Set up the file format and sample format dictionaries to interface with libsndfile.