Copyright ©1995 by NeXT Computer, Inc.  All Rights Reserved.




Sound Functions



Accessing Sound Devices and Hardware



Access sound devices

int SNDAcquire(int soundResource, int priority, int preempt, int timeout,  SNDNegotiationFun negFun, void *arg, port_t *devicePort, port_t *ownerPort)
int SNDReset(int soundResource, port_t devicePort, port_t ownerPort)
int SNDRelease(int soundResource, port_t *devicePort, port_t *ownerPort)


Reserve sound devices for recording or playback

int SNDReserve(int soundResource, int priority)
int SNDUnreserve(int soundResource)


Set the host computer for subsequent playback or recording

int SNDSetHost(char *newHostname)


Sound playback utilities

int SNDSetVolume(int left, int right)
int SNDGetVolume(int *left, int *right)
int SNDSetMute(int speakerOn)
int SNDGetMute(int *speakerOn)
int SNDSetFilter(int filterOn)
int SNDGetFilter(int *filterOn)



Recording and Playing



Play a soundfile

int SNDPlaySoundfile(char *path, int priority)


Recording and playing a sound

int SNDStartPlaying(SNDSoundStruct *sound, int tag, int priority, int preempt, SNDNotificationFun beginFun, SNDNotificationFun endFun)
int SNDVerifyPlayable(SNDSoundStruct *sound)
int SNDStartRecording(SNDSoundStruct *sound, int tag, int priority, int preempt, SNDNotificationFun beginFun, SNDNotificationFun endFun)
int SNDStartRecordingFile(char *fileName, SNDSoundStruct *sound, int tag, int priority, int preempt, SNDNotificationFun beginFun, SNDNotificationFun endFun)
int SNDStop(int tag)
int SNDWait(int tag)
int SNDSamplesProcessed(int tag)
int SNDModifyPriority(int tag, int newPriority)



Reading and Writing Soundfiles



Read a sound from a file

int SNDReadSoundfile(char *path, SNDSoundStruct **sound)
int SNDRead(int fd, SNDSoundStruct **sound)
int SNDReadHeader(int fd, SNDSoundStruct **sound)
int SNDReadDSPfile(char *path, SNDSoundStruct **sound, char *info)


Write a sound to a file

int SNDWriteSoundfile(char *path, SNDSoundStruct *sound)
int SNDWrite(int fd, SNDSoundStruct *sound)
int SNDWriteHeader(int fd, SNDSoundStruct *sound)



Accessing Sound Data



Create and free a sound structure

int SNDAlloc(SNDSoundStruct **sound, int dataSize, int dataFormat, int samplingRate, int channelCount, int infoSize)
int SNDFree(SNDSoundStruct *sound)


Gain access to sampled sound data

int SNDGetDataPointer(SNDSoundStruct *sound, char **ptr, int *size, int *width)


Measure samples in a sound

int SNDSampleCount(SNDSoundStruct *sound)
int SNDBytesToSamples(int byteCount, int channelCount, int dataFormat)
int SNDSamplesToBytes(int sampleCount, int channelCount, int dataFormat)



Accessing the DSP



Boot the DSP

int SNDBootDSP(port_t *devicePort, port_t *ownerPort, SNDSoundStruct *dspCore)


Run the DSP

int SNDRunDSP(SNDSoundStruct *dspCore, char *toDSP, int toCount, int toWidth, int toBufferSize, char **fromDSP, int *fromCount, int fromWidth, int negotiationTimeout, int flushTimeout, int conversionTimeout)



Compressing Sound Data



Compress or decompress a sound

int SNDCompressSound(SNDSoundStruct *fromSound, SNDSoundStruct **toSound, BOOL bitFaithful, int compressionAmount)


Query for frequency bands used by Audio Transform Compression

int SNDGetNumberOfATCBands(int *numBands)
int SNDGetATCBandFrequencies(int numBands, float *centerFreqs)
int SNDGetATCBandwidths(int numBands, float *bandwidths)


Speed up or slow down playback of ATC sound

int SNDDropATCSamples(int numSamples, int bySamples)
int SNDInsertATCSamples(int numSamples, int bySamples)


Modify volume or equalization for ATC playback

int SNDSetATCGain(float level)
int SNDGetATCGain(float *level)
int SNDSetATCEqualizerGains(int numBands, float *gains)
int SNDGetATCEqualizerGains(int numBands, float *gains)
int SNDScaleATCEqualizerGains(int numBands, float *gainScalars)


Set or get ATC parameters

int SNDSetATCSquelchThresholds(int numBands, float *thresholds)
int SNDGetATCSquelchThresholds(int numBands, float *thresholds)
int SNDUseDefaultATCSquelchThresholds(void)


Set and get compression attributes used in recording

int SNDSetCompressionOptions(SNDSoundStruct *sound, int bitFaithful, int compressionAmount)
int SNDGetCompressionOptions(SNDSoundStruct *sound, int *bitFaithful, int *compressionAmount)



Converting Sound Data



Convert between logarithmic and linear units

float SNDConvertDecibelsToLinear(float dB)
float SNDConvertLinearToDecibels(float linear)


Convert a sound's attributes

int SNDConvertSound(SNDSoundStruct *fromSound, SNDSoundStruct **toSound)
unsigned char SNDMulaw(short linearValue)
short SNDiMulaw(unsigned char mulawValue)



Editing Sound Data



Copy all or part of a sound

int SNDCopySound(SNDSoundStruct **toSound, SNDSoundStruct *fromSound)
int SNDCopySamples(SNDSoundStruct **toSound, SNDSoundStruct *fromSound, int startSample, int sampleCount)


Edit a sampled sound

int SNDInsertSamples(SNDSoundStruct *toSound, SNDSoundStruct *fromSound, int startSample)
int SNDDeleteSamples(SNDSoundStruct *sound, int startSample, int sampleCount)
int SNDCompactSamples(SNDSoundStruct **toSound, SNDSoundStruct *fromSound)



Sound Errors



Describe a sound error

char *SNDSoundError(int err)