MusicKit  0.0.0
Public Member Functions | Static Public Member Functions | Protected Attributes
SndAudioBuffer Class Reference

An in-memory audio buffer. More...

#import <SndAudioBuffer.h>

List of all members.

Public Member Functions

(id) - initWithFormat:data:
 Initialization method from a SndFormat and the data it describes.
(id) - initWithBuffer:
 Initialize a buffer with a matching format to the supplied buffer.
(id) - initWithBuffer:range:
 Initialize a buffer with a matching format to the supplied buffer, for a subset range of that audio buffer.
(id) - initWithDataFormat:channelCount:samplingRate:frameCount:
 Initializes the instance to the given format.
(id) - initWithDataFormat:channelCount:samplingRate:duration:
 Initializes this audio buffer with sound data of the given format, channels, sample rate and duration.
(long) - mixWithBuffer:fromStart:toEnd:canExpand:
 Mixes supplied SndAudioBuffer instance with the receiving instance, modifying it.
(long) - mixWithBuffer:
 Mixes supplied SndAudioBuffer instance with the receiving instance, modifying it.
(id) - copyWithZone:
 SndAudioBuffer object copying.
(id) - copyDataFromBuffer:
 Copies the audio buffer NSData instance from the given buffer to the receiver.
(id) - copyBytes:count:format:
 Copies bytes from the void * array given.
(id) - copyBytes:intoRange:format:
 Copies bytes from the void * array given into a sub region of the buffer.
(id) - copyFromBuffer:intoRange:
 Copies from the start of the given buffer into a sub region of the receiving buffer.
(long) - copyFromBuffer:intoFrameRange:fromFrameRange:
 Copies from the given region of the given buffer into a sub region of the receiving buffer.
(void) - fillSNDStreamBuffer:
 Fills the given stream buffer from the receiving audio buffer.
(SndAudioBuffer *) - audioBufferOfChannel:
 Returns a mono SndAudioBuffer instance extracting out the given audio channel of the receiving buffer.
(unsigned long) - lengthInSampleFrames
 Returns the number of sample frames in the audio buffer.
(id) - setLengthInSampleFrames:
 Changes the length of the buffer to newSampleFrameCount sample frames.
(long) - lengthInBytes
 Returns the length of the buffer's sample data in bytes.
(double) - duration
 Returns the length of the audio buffer in seconds.
(double) - samplingRate
 Returns the sampling rate of the audio buffer in Hertz.
(int) - channelCount
 Returns the number of channels in the audio buffer.
(SndSampleFormat) - dataFormat
 Returns the format of the sample data as a SndSampleFormat enumerated type.
(SndFormat- format
 Returns the format (number of frames, channels, dataFormat) of the audio buffer as a SndFormat structure.
(void *) - bytes
 Returns a C pointer to the sample data.
(BOOL) - hasSameFormatAsBuffer:
 compares the data format and length of this buffer to a second buffer.
(id) - zero
 Sets buffer data to zero. Silence.
(id) - zeroFrameRange:
 Zeros (silences) a given range of frames.
(int) - frameSizeInBytes
 Returns the size of a sample frame in bytes.
(NSString *) - description
 Returns a description of the instance as an NSString.
(void) - findMin:max:
 Finds the maximum and minimum sample values in the audio buffer and returns them as floats.
(void) - findMin:at:max:at:
 Finds the maximum and minimum sample values in the audio buffer and returns them as floats along with their locations.
(float) - findMaximumMagnitudeAt:
 Finds the maximum absolute value amplitude sample in the audio buffer and returns it's index.
(float) - findMaximumMagnitudeAt:channel:
 Finds the maximum absolute value amplitude sample in the audio buffer and returns it's index.
(void) - amplitudeRMSOfChannels:
 Returns the root mean squared amplitude of each channel in the audio buffer.
(double) - maximumAmplitude
 Returns the maximum amplitude of the format, that is, the maximum positive value of a sample.
(void) - normalise
 Scale signal to maximum dynamic range of data format.
(void) - scaleBy:
 Scale signal by a given factor.
(float) - sampleAtFrameIndex:channel:
 Retrieves a normalised sample given the frame number (time position) and channel number.
(BOOL) - setSample:atFrameIndex:channel:
 Allows assignment of a normalised sample in the buffer, given the frame number (time position) and channel number.
(void) - stereoChannels:
 Retrieve the channels used for stereo presentation (left and right).
(id) - initWithFormat:data:
 Initialization method from a SndFormat and the data it describes.
(id) - initWithBuffer:
 Initialize a buffer with a matching format to the supplied buffer.
(id) - initWithBuffer:range:
 Initialize a buffer with a matching format to the supplied buffer, for a subset range of that audio buffer.
(id) - initWithDataFormat:channelCount:samplingRate:frameCount:
 Initializes the instance to the given format.
(id) - initWithDataFormat:channelCount:samplingRate:duration:
 Initializes this audio buffer with sound data of the given format, channels, sample rate and duration.
(long) - mixWithBuffer:fromStart:toEnd:canExpand:
 Mixes supplied SndAudioBuffer instance with the receiving instance, modifying it.
(long) - mixWithBuffer:
 Mixes supplied SndAudioBuffer instance with the receiving instance, modifying it.
(id) - copyWithZone:
 SndAudioBuffer object copying.
(id) - copyDataFromBuffer:
 Copies the audio buffer NSData instance from the given buffer to the receiver.
(id) - copyBytes:count:format:
 Copies bytes from the void * array given.
(id) - copyBytes:intoRange:format:
 Copies bytes from the void * array given into a sub region of the buffer.
(id) - copyFromBuffer:intoRange:
 Copies from the start of the given buffer into a sub region of the receiving buffer.
(long) - copyFromBuffer:intoFrameRange:fromFrameRange:
 Copies from the given region of the given buffer into a sub region of the receiving buffer.
(void) - fillSNDStreamBuffer:
 Fills the given stream buffer from the receiving audio buffer.
(SndAudioBuffer *) - audioBufferOfChannel:
 Returns a mono SndAudioBuffer instance extracting out the given audio channel of the receiving buffer.
(unsigned long) - lengthInSampleFrames
 Returns the number of sample frames in the audio buffer.
(id) - setLengthInSampleFrames:
 Changes the length of the buffer to newSampleFrameCount sample frames.
(long) - lengthInBytes
 Returns the length of the buffer's sample data in bytes.
(double) - duration
 Returns the length of the audio buffer in seconds.
(double) - samplingRate
 Returns the sampling rate of the audio buffer in Hertz.
(int) - channelCount
 Returns the number of channels in the audio buffer.
(SndSampleFormat) - dataFormat
 Returns the format of the sample data as a SndSampleFormat enumerated type.
(SndFormat- format
 Returns the format (number of frames, channels, dataFormat) of the audio buffer as a SndFormat structure.
(void *) - bytes
 Returns a C pointer to the sample data.
(BOOL) - hasSameFormatAsBuffer:
 compares the data format and length of this buffer to a second buffer.
(id) - zero
 Sets buffer data to zero. Silence.
(id) - zeroFrameRange:
 Zeros (silences) a given range of frames.
(int) - frameSizeInBytes
 Returns the size of a sample frame in bytes.
(NSString *) - description
 Returns a description of the instance as an NSString.
(void) - findMin:max:
 Finds the maximum and minimum sample values in the audio buffer and returns them as floats.
(void) - findMin:at:max:at:
 Finds the maximum and minimum sample values in the audio buffer and returns them as floats along with their locations.
(float) - findMaximumMagnitudeAt:
 Finds the maximum absolute value amplitude sample in the audio buffer and returns it's index.
(float) - findMaximumMagnitudeAt:channel:
 Finds the maximum absolute value amplitude sample in the audio buffer and returns it's index.
(void) - amplitudeRMSOfChannels:
 Returns the root mean squared amplitude of each channel in the audio buffer.
(double) - maximumAmplitude
 Returns the maximum amplitude of the format, that is, the maximum positive value of a sample.
(void) - normalise
 Scale signal to maximum dynamic range of data format.
(void) - scaleBy:
 Scale signal by a given factor.
(float) - sampleAtFrameIndex:channel:
 Retrieves a normalised sample given the frame number (time position) and channel number.
(BOOL) - setSample:atFrameIndex:channel:
 Allows assignment of a normalised sample in the buffer, given the frame number (time position) and channel number.
(void) - stereoChannels:
 Retrieve the channels used for stereo presentation (left and right).
(SndAudioBuffer *) - audioBufferConvertedToFormat:channelCount:samplingRate:
 Creates a new autoreleased buffer of the same number of samples as the receiver converted to the new format, sampling rate and channel count.
(SndAudioBuffer *) - audioBufferConvertedToFormat:channelCount:samplingRate:
 Creates a new autoreleased buffer of the same number of samples as the receiver converted to the new format, sampling rate and channel count.
(id) - convertToFormat:
 Converts the buffer to the sample format, sample rate and channel count described by SndFormat.
(id) - convertToFormat:
 Converts the buffer to the sample format, sample rate and channel count described by SndFormat.
(id) - convertToSampleFormat:
 Converts the sample data to the given format.
(id) - convertToSampleFormat:
 Converts the sample data to the given format.
(long) - convertBytes:intoFrameRange:fromFormat:channelCount:samplingRate:
 Converts from a data pointer described by the given data format, channel count and sampling rate to the current buffer format.
(long) - convertBytes:intoFrameRange:fromFormat:channelCount:samplingRate:
 Converts from a data pointer described by the given data format, channel count and sampling rate to the current buffer format.
(id) - convertToSampleFormat:channelCount:
 Converts the sample data to the given format and channel count.
(id) - convertToSampleFormat:channelCount:
 Converts the sample data to the given format and channel count.
(id) - convertToSampleFormat:channelCount:samplingRate:useLargeFilter:interpolateFilter:useLinearInterpolation:
 Converts the sample data to the given format, channel count and sampling rate.
(id) - convertToSampleFormat:channelCount:samplingRate:useLargeFilter:interpolateFilter:useLinearInterpolation:
 Converts the sample data to the given format, channel count and sampling rate.
(SNDKIT_API int) - SndChangeSampleType
 Does a conversion from one sample type to another.
(SNDKIT_API int) - SndChangeSampleType
 Does a conversion from one sample type to another.
(SNDKIT_API void) - SndChangeSampleRate
 Resamples an input buffer into an output buffer, effectively changing the sampling rate.
(SNDKIT_API void) - SndChangeSampleRate
 Resamples an input buffer into an output buffer, effectively changing the sampling rate.
(SNDKIT_API void) - SndChannelMap
 Maps old channels to the new number of channels in the buffer, in place.
(SNDKIT_API void) - SndChannelMap
 Maps old channels to the new number of channels in the buffer, in place.
(SNDKIT_API void) - SndChannelDecrease
 Decreases the number of channels in the buffer, in place.
(SNDKIT_API void) - SndChannelDecrease
 Decreases the number of channels in the buffer, in place.

Static Public Member Functions

(id) + audioBufferWithDataFormat:channelCount:samplingRate:duration:
 Factory method creating an instance from a set of parameters individually specified.
(id) + audioBufferWithDataFormat:channelCount:samplingRate:frameCount:
 Factory method creating an instance from a set of parameters individually specified.
(id) + audioBufferWithFormat:
 Factory method creating a zeroed buffer of the given format and length.
(id) + audioBufferWithFormat:data:
 Factory method creating an audio buffer in the given format with the audio data.
(id) + audioBufferWithSNDStreamBuffer:
 Factory method creating an SndAudioBuffer instance from a SNDStreamBuffer.
(id) + audioBufferWithSnd:inRange:
 Factory method creating audioBuffers from a region of the given Snd.
(id) + audioBufferWithDataFormat:channelCount:samplingRate:duration:
 Factory method creating an instance from a set of parameters individually specified.
(id) + audioBufferWithDataFormat:channelCount:samplingRate:frameCount:
 Factory method creating an instance from a set of parameters individually specified.
(id) + audioBufferWithFormat:
 Factory method creating a zeroed buffer of the given format and length.
(id) + audioBufferWithFormat:data:
 Factory method creating an audio buffer in the given format with the audio data.
(id) + audioBufferWithSNDStreamBuffer:
 Factory method creating an SndAudioBuffer instance from a SNDStreamBuffer.
(id) + audioBufferWithSnd:inRange:
 Factory method creating audioBuffers from a region of the given Snd.

Protected Attributes

SndFormat format
NSMutableData * data
signed char * speakerConfiguration

Detailed Description

An in-memory audio buffer.

A SndAudioBuffer represents sound data in contiguous memory. As distinct from a Snd class, it holds typically small chunks of sound data ready for signal processing or performance. Using classes such as SndAudioBufferQueue enables a fragmented arrangement of buffers across memory, typically for processing constraints. SndAudioBuffers are the closest SndKit match to the underlying audio hardware buffer. In addition to holding the sample data, SndAudioBuffer encapsulates sampling rate, number of channels, number of frames and the format of the sample data. A SndAudioBuffer is guaranteed to be uncompressed, therefore it can be processed as a linear buffer of memory.


Member Function Documentation

- (void) amplitudeRMSOfChannels: (float *)  rmsAmpPerChannel

Returns the root mean squared amplitude of each channel in the audio buffer.

Parameters:
rmsAmpPerChannelPoints to an array of floats to receive each channels RMS amplitude value.

Note that rmsAmpPerChannel must point to a sufficient number of floats to match the number of channels in the buffer.

- (void) amplitudeRMSOfChannels: (float *)  rmsAmpPerChannel

Returns the root mean squared amplitude of each channel in the audio buffer.

Parameters:
rmsAmpPerChannelPoints to an array of floats to receive each channels RMS amplitude value.

Note that rmsAmpPerChannel must point to a sufficient number of floats to match the number of channels in the buffer.

- (SndAudioBuffer *) audioBufferConvertedToFormat: (SndSampleFormat)  toDataFormat
channelCount: (int)  toChannelCount
samplingRate: (double)  toSamplingRate 

Creates a new autoreleased buffer of the same number of samples as the receiver converted to the new format, sampling rate and channel count.

Parameters:
toDataFormatA SndSampleFormat representing different sample data formats.
toChannelCountThe new number of channels in the raw sample data.
toSamplingRate
Returns:
returns the new buffer instance.
- (SndAudioBuffer *) audioBufferConvertedToFormat: (SndSampleFormat)  toDataFormat
channelCount: (int)  toChannelCount
samplingRate: (double)  toSamplingRate 

Creates a new autoreleased buffer of the same number of samples as the receiver converted to the new format, sampling rate and channel count.

Parameters:
toDataFormatA SndSampleFormat representing different sample data formats.
toChannelCountThe new number of channels in the raw sample data.
toSamplingRate
Returns:
returns the new buffer instance.
- (SndAudioBuffer *) audioBufferOfChannel: (int)  channel

Returns a mono SndAudioBuffer instance extracting out the given audio channel of the receiving buffer.

Use this to retrieve a single buffer from a multichannel buffer. Sending this to a mono buffer returns the buffer verbatim.

Parameters:
channelThe channel to extract. Must be in the range {0..[self channelCount] - 1}.
Returns:
Returns an autoreleased SndAudioBuffer instance.
- (SndAudioBuffer *) audioBufferOfChannel: (int)  channel

Returns a mono SndAudioBuffer instance extracting out the given audio channel of the receiving buffer.

Use this to retrieve a single buffer from a multichannel buffer. Sending this to a mono buffer returns the buffer verbatim.

Parameters:
channelThe channel to extract. Must be in the range {0..[self channelCount] - 1}.
Returns:
Returns an autoreleased SndAudioBuffer instance.
+ (id) audioBufferWithDataFormat: (SndSampleFormat)  dataFormat
channelCount: (int)  channelCount
samplingRate: (double)  sampleRate
duration: (double)  timeInSeconds 

Factory method creating an instance from a set of parameters individually specified.

Parameters:
dataFormatA SndSampleFormat.
channelCountThe number of sound channels per frame.
sampleRateThe sampling rate specified in Hertz (Hz).
timeInSecondsDuration is specified in seconds.
Returns:
Returns an autoreleased SndAudioBuffer instance.
+ (id) audioBufferWithDataFormat: (SndSampleFormat)  dataFormat
channelCount: (int)  channelCount
samplingRate: (double)  sampleRate
duration: (double)  timeInSeconds 

Factory method creating an instance from a set of parameters individually specified.

Parameters:
dataFormatA SndSampleFormat.
channelCountThe number of sound channels per frame.
sampleRateThe sampling rate specified in Hertz (Hz).
timeInSecondsDuration is specified in seconds.
Returns:
Returns an autoreleased SndAudioBuffer instance.
+ (id) audioBufferWithDataFormat: (SndSampleFormat)  newDataFormat
channelCount: (int)  newChannelCount
samplingRate: (double)  newSamplingRate
frameCount: (long)  newFrameCount 

Factory method creating an instance from a set of parameters individually specified.

Parameters:
newDataFormatA SndSampleFormat.
newChannelCountThe number of sound channels per frame.
newSamplingRateThe sampling rate specified in Hertz (Hz).
newFrameCountDuration is specified in frames.
Returns:
Returns an autoreleased SndAudioBuffer instance.
+ (id) audioBufferWithDataFormat: (SndSampleFormat)  newDataFormat
channelCount: (int)  newChannelCount
samplingRate: (double)  newSamplingRate
frameCount: (long)  newFrameCount 

Factory method creating an instance from a set of parameters individually specified.

Parameters:
newDataFormatA SndSampleFormat.
newChannelCountThe number of sound channels per frame.
newSamplingRateThe sampling rate specified in Hertz (Hz).
newFrameCountDuration is specified in frames.
Returns:
Returns an autoreleased SndAudioBuffer instance.
+ (id) audioBufferWithFormat: (SndFormat format

Factory method creating a zeroed buffer of the given format and length.

Parameters:
formatA SndFormat describing the format of the buffer to be created.
Returns:
Returns an autoreleased SndAudioBuffer instance.
+ (id) audioBufferWithFormat: (SndFormat format

Factory method creating a zeroed buffer of the given format and length.

Parameters:
formatA SndFormat describing the format of the buffer to be created.
Returns:
Returns an autoreleased SndAudioBuffer instance.
+ (id) audioBufferWithFormat: (SndFormat *)  format
data: (void *)  dataPointer 

Factory method creating an audio buffer in the given format with the audio data.

The frameCount member of format MUST match the length of d (in bytes)!

Parameters:
formatA pointer to a SndFormat.
dataPointer
Returns:
Returns an autoreleased SndAudioBuffer instance.
+ (id) audioBufferWithFormat: (SndFormat *)  format
data: (void *)  dataPointer 

Factory method creating an audio buffer in the given format with the audio data.

The frameCount member of format MUST match the length of d (in bytes)!

Parameters:
formatA pointer to a SndFormat.
dataPointer
Returns:
Returns an autoreleased SndAudioBuffer instance.
+ (id) audioBufferWithSnd: (Snd *)  snd
inRange: (NSRange)  rangeInFrames 

Factory method creating audioBuffers from a region of the given Snd.

Parameters:
snd
rangeInFramesAn NSRange structure indicating the start and end of the region in samples.
Returns:
Returns an autoreleased SndAudioBuffer instance.
+ (id) audioBufferWithSnd: (Snd *)  snd
inRange: (NSRange)  rangeInFrames 

Factory method creating audioBuffers from a region of the given Snd.

Parameters:
snd
rangeInFramesAn NSRange structure indicating the start and end of the region in samples.
Returns:
Returns an autoreleased SndAudioBuffer instance.

Factory method creating an SndAudioBuffer instance from a SNDStreamBuffer.

Parameters:
streamBufferA fully populated SNDStreamBuffer structure.
Returns:
Returns an autoreleased SndAudioBuffer instance.

Factory method creating an SndAudioBuffer instance from a SNDStreamBuffer.

Parameters:
streamBufferA fully populated SNDStreamBuffer structure.
Returns:
Returns an autoreleased SndAudioBuffer instance.
- (void *) bytes

Returns a C pointer to the sample data.

The user of this method will need to have determined the format of the data in order to correctly traverse it.

Returns:
Pointer to the audio data.
- (void *) bytes

Returns a C pointer to the sample data.

The user of this method will need to have determined the format of the data in order to correctly traverse it.

Returns:
Pointer to the audio data.
- (int) channelCount

Returns the number of channels in the audio buffer.

Returns:
Number of channels
- (int) channelCount

Returns the number of channels in the audio buffer.

Returns:
Number of channels
- (long) convertBytes: (void *)  fromDataPtr
intoFrameRange: (NSRange)  bufferFrameRange
fromFormat: (SndSampleFormat)  fromDataFormat
channelCount: (int)  fromChannelCount
samplingRate: (double)  fromSamplingRate 

Converts from a data pointer described by the given data format, channel count and sampling rate to the current buffer format.

Checks the range does not exceed the bounds of the buffer. The number of frames read during the conversion is returned. This may be larger or smaller than the bufferFrameRange.length specified number if sample rate conversion is performed. This allows the calling method to correctly update it's read pointer.

Parameters:
fromDataPtrA pointer to raw sample data.
bufferFrameRangeIndicates the region of the buffer which will be converted, specified in channel independent samples.
fromDataFormatA SndSampleFormat representing different sample data formats.
fromChannelCountThe old number of channels in the raw sample data.
fromSamplingRateThe old sampling rate in the raw sample data.
Returns:
Returns the number of frames that were read if conversion was successful, 0 if conversion was not possible, such as due to incompatible channel counts.
- (long) convertBytes: (void *)  fromDataPtr
intoFrameRange: (NSRange)  bufferFrameRange
fromFormat: (SndSampleFormat)  fromDataFormat
channelCount: (int)  fromChannelCount
samplingRate: (double)  fromSamplingRate 

Converts from a data pointer described by the given data format, channel count and sampling rate to the current buffer format.

Checks the range does not exceed the bounds of the buffer. The number of frames read during the conversion is returned. This may be larger or smaller than the bufferFrameRange.length specified number if sample rate conversion is performed. This allows the calling method to correctly update it's read pointer.

Parameters:
fromDataPtrA pointer to raw sample data.
bufferFrameRangeIndicates the region of the buffer which will be converted, specified in channel independent samples.
fromDataFormatA SndSampleFormat representing different sample data formats.
fromChannelCountThe old number of channels in the raw sample data.
fromSamplingRateThe old sampling rate in the raw sample data.
Returns:
Returns the number of frames that were read if conversion was successful, 0 if conversion was not possible, such as due to incompatible channel counts.
- (id) convertToFormat: (SndFormat newFormat

Converts the buffer to the sample format, sample rate and channel count described by SndFormat.

The SndFormat field frameCount is ignored.

Parameters:
newFormatThe SndFormat giving the new format to convert the SndAudioBuffer instance to.
- (id) convertToFormat: (SndFormat newFormat

Converts the buffer to the sample format, sample rate and channel count described by SndFormat.

The SndFormat field frameCount is ignored.

Parameters:
newFormatThe SndFormat giving the new format to convert the SndAudioBuffer instance to.
- (id) convertToSampleFormat: (SndSampleFormat)  newDataFormat

Converts the sample data to the given format.

Only the format is changed, the number of channels and sampling rate are preserved.

Parameters:
newDataFormatA SndSampleFormat representing different sample data formats.
Returns:
Returns self if conversion was successful, nil if conversion was not possible, such as due to incompatible channel counts.
- (id) convertToSampleFormat: (SndSampleFormat)  newDataFormat

Converts the sample data to the given format.

Only the format is changed, the number of channels and sampling rate are preserved.

Parameters:
newDataFormatA SndSampleFormat representing different sample data formats.
Returns:
Returns self if conversion was successful, nil if conversion was not possible, such as due to incompatible channel counts.
- (id) convertToSampleFormat: (SndSampleFormat)  toDataFormat
channelCount: (int)  toChannelCount 

Converts the sample data to the given format and channel count.

Reallocates sample data if necessary for channel count changes.

Parameters:
toDataFormatA SndSampleFormat representing different sample data formats.
toChannelCountNumber of channels for the new sound. If less than the current number, channels are averaged, if more, channels are duplicated.
Returns:
Returns self if conversion was successful, nil if conversion was not possible, such as due to incompatible channel counts.
- (id) convertToSampleFormat: (SndSampleFormat)  toDataFormat
channelCount: (int)  toChannelCount 

Converts the sample data to the given format and channel count.

Reallocates sample data if necessary for channel count changes.

Parameters:
toDataFormatA SndSampleFormat representing different sample data formats.
toChannelCountNumber of channels for the new sound. If less than the current number, channels are averaged, if more, channels are duplicated.
Returns:
Returns self if conversion was successful, nil if conversion was not possible, such as due to incompatible channel counts.
- (id) convertToSampleFormat: (SndSampleFormat)  toDataFormat
channelCount: (int)  toChannelCount
samplingRate: (double)  toSampleRate
useLargeFilter: (BOOL)  largeFilter
interpolateFilter: (BOOL)  interpolateFilter
useLinearInterpolation: (BOOL)  linearInterpolation 

Converts the sample data to the given format, channel count and sampling rate.

The parameter fields useLargeFilter: interpolateFilter: and useLinearInterpolation: control the particular resampling methods used.

Parameters:
toDataFormatA SndSampleFormat representing different sample data formats.
toChannelCountThe new number of channels. Reallocation occurs if expanding buffers.
toSampleRateThe new sampling rate.
largeFilterTRUE means use 65tap FIR filter, with higher quality.
interpolateFilterWhen not in "fast" mode, controls whether or not the filter coefficients are interpolated (disregarded in fast mode).
linearInterpolationIf TRUE, linear interpolation uses a fast, noninterpolating resample routine but is relatively noisy.
Returns:
Returns self if conversion was successful, nil if conversion was not possible, such as due to incompatible channel counts.
- (id) convertToSampleFormat: (SndSampleFormat)  toDataFormat
channelCount: (int)  toChannelCount
samplingRate: (double)  toSampleRate
useLargeFilter: (BOOL)  largeFilter
interpolateFilter: (BOOL)  interpolateFilter
useLinearInterpolation: (BOOL)  linearInterpolation 

Converts the sample data to the given format, channel count and sampling rate.

The parameter fields useLargeFilter: interpolateFilter: and useLinearInterpolation: control the particular resampling methods used.

Parameters:
toDataFormatA SndSampleFormat representing different sample data formats.
toChannelCountThe new number of channels. Reallocation occurs if expanding buffers.
toSampleRateThe new sampling rate.
largeFilterTRUE means use 65tap FIR filter, with higher quality.
interpolateFilterWhen not in "fast" mode, controls whether or not the filter coefficients are interpolated (disregarded in fast mode).
linearInterpolationIf TRUE, linear interpolation uses a fast, noninterpolating resample routine but is relatively noisy.
Returns:
Returns self if conversion was successful, nil if conversion was not possible, such as due to incompatible channel counts.
- (id) copyBytes: (void *)  bytes
count: (unsigned int)  count
format: (SndFormat format 

Copies bytes from the void * array given.

Grows the internal NSMutableData object as necessary

Parameters:
bytesThe void * array to copy from.
countThe number of bytes to copy from the array.
formatA SndFormat containing valid channelCount, samplingRate and dataFormat variables.
Returns:
Returns self.
- (id) copyBytes: (void *)  bytes
count: (unsigned int)  count
format: (SndFormat format 

Copies bytes from the void * array given.

Grows the internal NSMutableData object as necessary

Parameters:
bytesThe void * array to copy from.
countThe number of bytes to copy from the array.
formatA SndFormat containing valid channelCount, samplingRate and dataFormat variables.
Returns:
Returns self.
- (id) copyBytes: (void *)  bytes
intoRange: (NSRange)  range
format: (SndFormat format 

Copies bytes from the void * array given into a sub region of the buffer.

Grows the internal NSMutableData object as necessary

Parameters:
bytesThe void * array to copy from.
rangeThe start location and number of bytes to copy from the array.
formatA SndFormat containing valid channelCount, samplingRate and dataFormat variables.
Returns:
Returns self.
- (id) copyBytes: (void *)  bytes
intoRange: (NSRange)  range
format: (SndFormat format 

Copies bytes from the void * array given into a sub region of the buffer.

Grows the internal NSMutableData object as necessary

Parameters:
bytesThe void * array to copy from.
rangeThe start location and number of bytes to copy from the array.
formatA SndFormat containing valid channelCount, samplingRate and dataFormat variables.
Returns:
Returns self.
- (id) copyDataFromBuffer: (SndAudioBuffer *)  audioBufferToCopyFrom

Copies the audio buffer NSData instance from the given buffer to the receiver.

Audio buffers must be the same format.

Parameters:
audioBufferToCopyFromThe audio buffer instance to copy the data from.
Returns:
Returns self.
- (id) copyDataFromBuffer: (SndAudioBuffer *)  audioBufferToCopyFrom

Copies the audio buffer NSData instance from the given buffer to the receiver.

Audio buffers must be the same format.

Parameters:
audioBufferToCopyFromThe audio buffer instance to copy the data from.
Returns:
Returns self.
- (long) copyFromBuffer: (SndAudioBuffer *)  fromBuffer
intoFrameRange: (NSRange)  bufferRange
fromFrameRange: (NSRange)  fromFrameRange 

Copies from the given region of the given buffer into a sub region of the receiving buffer.

Grows the internal NSMutableData object as necessary

Parameters:
fromBufferThe audio buffer to copy from.
bufferRangeThe range of fromBuffer in sample frames to copy into.
fromFrameRangeThe start location and number of samples to copy to the receiving buffer.
Returns:
Returns the number of frames actually copied.
- (long) copyFromBuffer: (SndAudioBuffer *)  fromBuffer
intoFrameRange: (NSRange)  bufferRange
fromFrameRange: (NSRange)  fromFrameRange 

Copies from the given region of the given buffer into a sub region of the receiving buffer.

Grows the internal NSMutableData object as necessary

Parameters:
fromBufferThe audio buffer to copy from.
bufferRangeThe range of fromBuffer in sample frames to copy into.
fromFrameRangeThe start location and number of samples to copy to the receiving buffer.
Returns:
Returns the number of frames actually copied.
- (id) copyFromBuffer: (SndAudioBuffer *)  sourceBuffer
intoRange: (NSRange)  rangeInSamples 

Copies from the start of the given buffer into a sub region of the receiving buffer.

Grows the internal NSMutableData object as necessary

Parameters:
sourceBufferThe audio buffer to copy from.
rangeInSamplesThe start location and number of samples to copy to the receiving buffer.
Returns:
Returns self.
- (id) copyFromBuffer: (SndAudioBuffer *)  sourceBuffer
intoRange: (NSRange)  rangeInSamples 

Copies from the start of the given buffer into a sub region of the receiving buffer.

Grows the internal NSMutableData object as necessary

Parameters:
sourceBufferThe audio buffer to copy from.
rangeInSamplesThe start location and number of samples to copy to the receiving buffer.
Returns:
Returns self.
- (id) copyWithZone: (NSZone *)  zone

SndAudioBuffer object copying.

Returns:
A duplicate SndAudioBuffer with its own, identical data.
- (id) copyWithZone: (NSZone *)  zone

SndAudioBuffer object copying.

Returns:
A duplicate SndAudioBuffer with its own, identical data.
- (SndSampleFormat) dataFormat

Returns the format of the sample data as a SndSampleFormat enumerated type.

Returns:
Data format enumerated type.
- (SndSampleFormat) dataFormat

Returns the format of the sample data as a SndSampleFormat enumerated type.

Returns:
Data format enumerated type.
- (NSString *) description

Returns a description of the instance as an NSString.

Returns:
NSString describing the audio buffer.
- (NSString *) description

Returns a description of the instance as an NSString.

Returns:
NSString describing the audio buffer.
- (double) duration

Returns the length of the audio buffer in seconds.

Returns:
Duration in seconds (as determined by format sampling rate).
- (double) duration

Returns the length of the audio buffer in seconds.

Returns:
Duration in seconds (as determined by format sampling rate).
- (void) fillSNDStreamBuffer: (SNDStreamBuffer *)  streamBuffer

Fills the given stream buffer from the receiving audio buffer.

Manages any conversion from interleaved SndAudioBuffer format to possibly non-interleaved SNDStreamBuffers.

Parameters:
streamBufferPointer to the structure that describes the underlying audio API format.
- (void) fillSNDStreamBuffer: (SNDStreamBuffer *)  streamBuffer

Fills the given stream buffer from the receiving audio buffer.

Manages any conversion from interleaved SndAudioBuffer format to possibly non-interleaved SNDStreamBuffers.

Parameters:
streamBufferPointer to the structure that describes the underlying audio API format.
- (float) findMaximumMagnitudeAt: (unsigned long *)  sampleIndex

Finds the maximum absolute value amplitude sample in the audio buffer and returns it's index.

Parameters:
sampleIndexPoints to an unsigned long to store the sample index of the maximum magnitude sample.
- (float) findMaximumMagnitudeAt: (unsigned long *)  sampleIndex

Finds the maximum absolute value amplitude sample in the audio buffer and returns it's index.

Parameters:
sampleIndexPoints to an unsigned long to store the sample index of the maximum magnitude sample.
- (float) findMaximumMagnitudeAt: (unsigned long *)  frameIndex
channel: (unsigned int *)  channel 

Finds the maximum absolute value amplitude sample in the audio buffer and returns it's index.

Parameters:
frameIndexPoints to an unsigned long to store the frame index of the maximum magnitude sample.
channelPoints to an unsigned int to store the channel of the maximum magnitude sample.
- (float) findMaximumMagnitudeAt: (unsigned long *)  frameIndex
channel: (unsigned int *)  channel 

Finds the maximum absolute value amplitude sample in the audio buffer and returns it's index.

Parameters:
frameIndexPoints to an unsigned long to store the frame index of the maximum magnitude sample.
channelPoints to an unsigned int to store the channel of the maximum magnitude sample.
- (void) findMin: (float *)  pMin
at: (unsigned long *)  minLocation
max: (float *)  pMax
at: (unsigned long *)  maxLocation 

Finds the maximum and minimum sample values in the audio buffer and returns them as floats along with their locations.

Parameters:
pMinPoints to a float to store the minimum sample value (between -1.0 and 1.0).
minLocationPoints to an unsigned long to store the sample index of the minimum sample.
pMaxPoints to a float to store the maximum sample value (between -1.0 and 1.0).
maxLocationPoints to an unsigned long to store the sample index of the maximum sample.
- (void) findMin: (float *)  pMin
at: (unsigned long *)  minLocation
max: (float *)  pMax
at: (unsigned long *)  maxLocation 

Finds the maximum and minimum sample values in the audio buffer and returns them as floats along with their locations.

Parameters:
pMinPoints to a float to store the minimum sample value (between -1.0 and 1.0).
minLocationPoints to an unsigned long to store the sample index of the minimum sample.
pMaxPoints to a float to store the maximum sample value (between -1.0 and 1.0).
maxLocationPoints to an unsigned long to store the sample index of the maximum sample.
- (void) findMin: (float *)  pMin
max: (float *)  pMax 

Finds the maximum and minimum sample values in the audio buffer and returns them as floats.

Parameters:
pMinPoints to a float to store the minimum sample value (between -1.0 and 1.0).
pMaxPoints to a float to store the maximum sample value (between -1.0 and 1.0).
- (void) findMin: (float *)  pMin
max: (float *)  pMax 

Finds the maximum and minimum sample values in the audio buffer and returns them as floats.

Parameters:
pMinPoints to a float to store the minimum sample value (between -1.0 and 1.0).
pMaxPoints to a float to store the maximum sample value (between -1.0 and 1.0).

Returns the format (number of frames, channels, dataFormat) of the audio buffer as a SndFormat structure.

Returns:
Returns a SndFormat.

Returns the format (number of frames, channels, dataFormat) of the audio buffer as a SndFormat structure.

Returns:
Returns a SndFormat.

Returns the size of a sample frame in bytes.

Returns:
Integer size of sample frame (channels * sample size in bytes)

Returns the size of a sample frame in bytes.

Returns:
Integer size of sample frame (channels * sample size in bytes)

compares the data format and length of this buffer to a second buffer.

The number of frames (frameCount) are compared.

Parameters:
buffThe SndAudioBuffer to compare to.
Returns:
YES if the buffers have the same format and length, NO if there are any differences in format between buffers.

compares the data format and length of this buffer to a second buffer.

The number of frames (frameCount) are compared.

Parameters:
buffThe SndAudioBuffer to compare to.
Returns:
YES if the buffers have the same format and length, NO if there are any differences in format between buffers.
- (id) initWithBuffer: (SndAudioBuffer *)  sndBuffer

Initialize a buffer with a matching format to the supplied buffer.

Creates a duplicated buffer (with a shallow copy, the data is referenced)

Parameters:
sndBufferAn existing initialised SndAudioBuffer.
Returns:
Returns self.
- (id) initWithBuffer: (SndAudioBuffer *)  sndBuffer

Initialize a buffer with a matching format to the supplied buffer.

Creates a duplicated buffer (with a shallow copy, the data is referenced)

Parameters:
sndBufferAn existing initialised SndAudioBuffer.
Returns:
Returns self.
- (id) initWithBuffer: (SndAudioBuffer *)  sndBuffer
range: (NSRange)  rangeInFrames 

Initialize a buffer with a matching format to the supplied buffer, for a subset range of that audio buffer.

Parameters:
sndBufferAn existing initialised SndAudioBuffer.
rangeInFramesThe NSRange of the supplied sndBuffer to initialise the new instance with.
Returns:
Returns self.
- (id) initWithBuffer: (SndAudioBuffer *)  sndBuffer
range: (NSRange)  rangeInFrames 

Initialize a buffer with a matching format to the supplied buffer, for a subset range of that audio buffer.

Parameters:
sndBufferAn existing initialised SndAudioBuffer.
rangeInFramesThe NSRange of the supplied sndBuffer to initialise the new instance with.
Returns:
Returns self.
- (id) initWithDataFormat: (SndSampleFormat)  dataFormat
channelCount: (int)  channelCount
samplingRate: (double)  samplingRate
duration: (double)  timeInSeconds 

Initializes this audio buffer with sound data of the given format, channels, sample rate and duration.

The samples are all silence.

Parameters:
dataFormatA SndSampleFormat.
channelCountNumber of audio channels, 1 for mono, 2 for stereo, 4 for quad etc..
samplingRateSample rate in Hertz.
timeInSecondsThe size of the buffer in seconds.
Returns:
Returns self.
- (id) initWithDataFormat: (SndSampleFormat)  dataFormat
channelCount: (int)  channelCount
samplingRate: (double)  samplingRate
duration: (double)  timeInSeconds 

Initializes this audio buffer with sound data of the given format, channels, sample rate and duration.

The samples are all silence.

Parameters:
dataFormatA SndSampleFormat.
channelCountNumber of audio channels, 1 for mono, 2 for stereo, 4 for quad etc..
samplingRateSample rate in Hertz.
timeInSecondsThe size of the buffer in seconds.
Returns:
Returns self.
- (id) initWithDataFormat: (SndSampleFormat)  dataFormat
channelCount: (int)  channelCount
samplingRate: (double)  samplingRate
frameCount: (long)  newFrameCount 

Initializes the instance to the given format.

Initializes the instance to the given sample data format, number of sound channels, sample rate, and frames (channel independent samples).

Parameters:
dataFormatA SndSampleFormat.
channelCountThe number of sound channels.
samplingRateSample rate in Hertz.
newFrameCountThe number of frames, each frame consists of channelCount number of samples.
Returns:
Returns self.
- (id) initWithDataFormat: (SndSampleFormat)  dataFormat
channelCount: (int)  channelCount
samplingRate: (double)  samplingRate
frameCount: (long)  newFrameCount 

Initializes the instance to the given format.

Initializes the instance to the given sample data format, number of sound channels, sample rate, and frames (channel independent samples).

Parameters:
dataFormatA SndSampleFormat.
channelCountThe number of sound channels.
samplingRateSample rate in Hertz.
newFrameCountThe number of frames, each frame consists of channelCount number of samples.
Returns:
Returns self.
- (id) initWithFormat: (SndFormat *)  format
data: (void *)  sampleData 

Initialization method from a SndFormat and the data it describes.

Can be used to initialize an instance with a buffer of data or with empty (i.e zeroed) data of the length given by format.frameCount if sampleData is NULL.

Parameters:
formatA SndFormat. All fields must be valid before calling this method.
sampleDataA pointer to the memory holding the sample data in the format described by format.
Returns:
Returns self.
- (id) initWithFormat: (SndFormat *)  format
data: (void *)  sampleData 

Initialization method from a SndFormat and the data it describes.

Can be used to initialize an instance with a buffer of data or with empty (i.e zeroed) data of the length given by format.frameCount if sampleData is NULL.

Parameters:
formatA SndFormat. All fields must be valid before calling this method.
sampleDataA pointer to the memory holding the sample data in the format described by format.
Returns:
Returns self.
- (long) lengthInBytes

Returns the length of the buffer's sample data in bytes.

Returns:
buffer length in bytes
- (long) lengthInBytes

Returns the length of the buffer's sample data in bytes.

Returns:
buffer length in bytes
- (unsigned long) lengthInSampleFrames

Returns the number of sample frames in the audio buffer.

A sample frame is a channel independent time position duration, it's duration is the reciprocal of the sample rate.

Returns:
Returns the buffer length in sample frames.
- (unsigned long) lengthInSampleFrames

Returns the number of sample frames in the audio buffer.

A sample frame is a channel independent time position duration, it's duration is the reciprocal of the sample rate.

Returns:
Returns the buffer length in sample frames.
- (double) maximumAmplitude

Returns the maximum amplitude of the format, that is, the maximum positive value of a sample.

Returns:
Returns the maximum value of a sample.
- (double) maximumAmplitude

Returns the maximum amplitude of the format, that is, the maximum positive value of a sample.

Returns:
Returns the maximum value of a sample.
- (long) mixWithBuffer: (SndAudioBuffer *)  buff

Mixes supplied SndAudioBuffer instance with the receiving instance, modifying it.

Mixes the entire buffer onto the original buffer.

Parameters:
buffThe SndAudioBuffer instance to mix.
Returns:
Returns the number of frames mixed.
- (long) mixWithBuffer: (SndAudioBuffer *)  buff

Mixes supplied SndAudioBuffer instance with the receiving instance, modifying it.

Mixes the entire buffer onto the original buffer.

Parameters:
buffThe SndAudioBuffer instance to mix.
Returns:
Returns the number of frames mixed.
- (long) mixWithBuffer: (SndAudioBuffer *)  buff
fromStart: (unsigned long)  start
toEnd: (unsigned long)  end
canExpand: (BOOL)  expand 

Mixes supplied SndAudioBuffer instance with the receiving instance, modifying it.

Mixes over the given range of the buffer.

Parameters:
buffThe SndAudioBuffer instance to mix.
startThe sample frame to begin mixing from.
endThe sample frame to end mixing at.
expandIf TRUE, receiver is allowed to expand buff in place if required to change data format before mixing, (not sample rate).
Returns:
Returns the number of frames mixed.
- (long) mixWithBuffer: (SndAudioBuffer *)  buff
fromStart: (unsigned long)  start
toEnd: (unsigned long)  end
canExpand: (BOOL)  expand 

Mixes supplied SndAudioBuffer instance with the receiving instance, modifying it.

Mixes over the given range of the buffer.

Parameters:
buffThe SndAudioBuffer instance to mix.
startThe sample frame to begin mixing from.
endThe sample frame to end mixing at.
expandIf TRUE, receiver is allowed to expand buff in place if required to change data format before mixing, (not sample rate).
Returns:
Returns the number of frames mixed.
- (void) normalise

Scale signal to maximum dynamic range of data format.

Manages both signals below the dynamic range and in the case of floating point format, exceeding the normalised dynamic range (-1.0 to 1.0). Scales such that no D.C shift occurs across all channels.

- (void) normalise

Scale signal to maximum dynamic range of data format.

Manages both signals below the dynamic range and in the case of floating point format, exceeding the normalised dynamic range (-1.0 to 1.0). Scales such that no D.C shift occurs across all channels.

- (float) sampleAtFrameIndex: (unsigned long)  frameIndex
channel: (int)  channel 

Retrieves a normalised sample given the frame number (time position) and channel number.

Parameters:
frameIndexThe frame index, between 0 and the value returned by lengthInSampleFrames less one, inclusive.
channelThe channel index, between 0 and the number of channels in the buffer (channelCount - 1) to retrieve a single channel, use channelCount to average all channels to a single value.
Returns:
Returns a normalised sample value as a float regardless of the data format.
- (float) sampleAtFrameIndex: (unsigned long)  frameIndex
channel: (int)  channel 

Retrieves a normalised sample given the frame number (time position) and channel number.

Parameters:
frameIndexThe frame index, between 0 and the value returned by lengthInSampleFrames less one, inclusive.
channelThe channel index, between 0 and the number of channels in the buffer (channelCount - 1) to retrieve a single channel, use channelCount to average all channels to a single value.
Returns:
Returns a normalised sample value as a float regardless of the data format.
- (double) samplingRate

Returns the sampling rate of the audio buffer in Hertz.

Returns:
sampling rate
- (double) samplingRate

Returns the sampling rate of the audio buffer in Hertz.

Returns:
sampling rate
- (void) scaleBy: (float)  scaleFactor

Scale signal by a given factor.

Scales the sample values in the buffer by the given multiplier across all channels.

- (void) scaleBy: (float)  scaleFactor

Scale signal by a given factor.

Scales the sample values in the buffer by the given multiplier across all channels.

- (id) setLengthInSampleFrames: (unsigned long)  newSampleFrameCount

Changes the length of the buffer to newSampleFrameCount sample frames.

TODO Need to explain the consequences of setting the length longer or shorter than current. See the source code.

- (id) setLengthInSampleFrames: (unsigned long)  newSampleFrameCount

Changes the length of the buffer to newSampleFrameCount sample frames.

TODO Need to explain the consequences of setting the length longer or shorter than current. See the source code.

- (BOOL) setSample: (float)  sampleValue
atFrameIndex: (unsigned long)  frameIndex
channel: (int)  channelNumber 

Allows assignment of a normalised sample in the buffer, given the frame number (time position) and channel number.

Parameters:
sampleValueA value specified as a bivalent normalised value (between -1.0 and 1.0).
frameIndexThe frame index, between 0 and the value returned by lengthInSampleFrames less one, inclusive.
channelThe channel index, between 0 and the number of channels in the buffer (channelCount - 1).
Returns:
Returns YES if able to assign the value, NO if the parameters specified an address outside the buffer.
- (BOOL) setSample: (float)  sampleValue
atFrameIndex: (unsigned long)  frameIndex
channel: (int)  channelNumber 

Allows assignment of a normalised sample in the buffer, given the frame number (time position) and channel number.

Parameters:
sampleValueA value specified as a bivalent normalised value (between -1.0 and 1.0).
frameIndexThe frame index, between 0 and the value returned by lengthInSampleFrames less one, inclusive.
channelThe channel index, between 0 and the number of channels in the buffer (channelCount - 1).
Returns:
Returns YES if able to assign the value, NO if the parameters specified an address outside the buffer.
- (SNDKIT_API void) SndChangeSampleRate (const SndFormat fromSound
(void *)  inputPtr
(SndFormat *)  toSound
(short *)  outPtr
(BOOL)  largeFilter
(BOOL)  interpFilter
(BOOL)  fast 

Resamples an input buffer into an output buffer, effectively changing the sampling rate.

Internal function which uses the "resample" routine to resample an input buffer into an output buffer. Various boolean flags control the speed and accuracy of the conversion. The output is always 16 bit, but the input routine can read ulaw, char, short, int, float and double types, of any number of channels. The old and new sample rates are determined by fromSound.samplingRate and toSound->samplingRate, respectively. Data must be in host endian order.

Parameters:
fromSoundHolds header information about the input sound.
inputPtrPoints to a contiguous buffer of input data to be used.
toSoundHolds header information about the target sound.
outPtrPointer to a buffer big enough to hold the output data.
factorRatio of new_sample_rate / old_sample_rate
largeFilterTRUE means use 65tap FIR filter, with higher quality.
interpFilterWhen not in "fast" mode, controls whether or not the filter coefficients are interpolated (disregarded in fast mode).
fastif TRUE, uses a fast, noninterpolating resample routine.
- (SNDKIT_API void) SndChangeSampleRate (const SndFormat fromSound
(void *)  inputPtr
(SndFormat *)  toSound
(short *)  outPtr
(BOOL)  largeFilter
(BOOL)  interpFilter
(BOOL)  fast 

Resamples an input buffer into an output buffer, effectively changing the sampling rate.

Internal function which uses the "resample" routine to resample an input buffer into an output buffer. Various boolean flags control the speed and accuracy of the conversion. The output is always 16 bit, but the input routine can read ulaw, char, short, int, float and double types, of any number of channels. The old and new sample rates are determined by fromSound.samplingRate and toSound->samplingRate, respectively. Data must be in host endian order.

Parameters:
fromSoundHolds header information about the input sound.
inputPtrPoints to a contiguous buffer of input data to be used.
toSoundHolds header information about the target sound.
outPtrPointer to a buffer big enough to hold the output data.
factorRatio of new_sample_rate / old_sample_rate
largeFilterTRUE means use 65tap FIR filter, with higher quality.
interpFilterWhen not in "fast" mode, controls whether or not the filter coefficients are interpolated (disregarded in fast mode).
fastif TRUE, uses a fast, noninterpolating resample routine.
- (SNDKIT_API int) SndChangeSampleType (void *)  fromPtr
(void *)  toPtr
(SndSampleFormat)  dfFrom
(SndSampleFormat)  dfTo
(long)  outCount 

Does a conversion from one sample type to another.

If fromPtr and toPtr are the same it does the conversion inplace. The buffer must be long enough to hold the increased number of bytes if the conversion calls for it.

Data must be in host endian order. Currently knows about ulaw, char, short, int, float and double data types, represented by the data format parameters (prefixed SND_FORMAT_).

Parameters:
fromPtrPointer to the byte buffer to read data from.
toPtrPointer to the byte buffer to write data to.
dfFromThe data format to convert from.
dfToThe data format to convert to.
outCountLength in samples of the original buffer, counting number of channels, that is duration in samples * number of channels.
Returns:
Returns error code.
- (SNDKIT_API int) SndChangeSampleType (void *)  fromPtr
(void *)  toPtr
(SndSampleFormat)  dfFrom
(SndSampleFormat)  dfTo
(long)  outCount 

Does a conversion from one sample type to another.

If fromPtr and toPtr are the same it does the conversion inplace. The buffer must be long enough to hold the increased number of bytes if the conversion calls for it.

Data must be in host endian order. Currently knows about ulaw, char, short, int, float and double data types, represented by the data format parameters (prefixed SND_FORMAT_).

Parameters:
fromPtrPointer to the byte buffer to read data from.
toPtrPointer to the byte buffer to write data to.
dfFromThe data format to convert from.
dfToThe data format to convert to.
outCountLength in samples of the original buffer, counting number of channels, that is duration in samples * number of channels.
Returns:
Returns error code.
- (SNDKIT_API void) SndChannelDecrease (void *)  inPtr
(void *)  outPtr
(unsigned long)  frames
(int)  oldNumChannels
(int)  newNumChannels
(SndSampleFormat)  df
(short *)  map 

Decreases the number of channels in the buffer, in place.

Because samples are read and averaged, must be hostendian. Remaps channels in an arbitary fashion, decreasing the channels by mixing them. The channel map determines which old channels are to be mixed to the new channel arrangement. This is an array of oldNumChannels length containing the indexes of the new channels. Channel indexes are zero based. If an index in the map is negative, that channel is zeroed in the output. For example, to map a quadraphonic file to stereo where the even numbered channels project to the left, odd numbered channels to the right, the map would be 0 1 0 1.

Parameters:
inPtr
outPtr
frames
oldNumChannels
newNumChannels
dfdata format of buffer
mapAn array oldNumChannels long indicating which oldNumChannel to use in the new channel. Not yet implemented: A channel index of -1 indicates zeroing (silencing) that channel.
- (SNDKIT_API void) SndChannelDecrease (void *)  inPtr
(void *)  outPtr
(unsigned long)  frames
(int)  oldNumChannels
(int)  newNumChannels
(SndSampleFormat)  df
(short *)  map 

Decreases the number of channels in the buffer, in place.

Because samples are read and averaged, must be hostendian. Remaps channels in an arbitary fashion, decreasing the channels by mixing them. The channel map determines which old channels are to be mixed to the new channel arrangement. This is an array of oldNumChannels length containing the indexes of the new channels. Channel indexes are zero based. If an index in the map is negative, that channel is zeroed in the output. For example, to map a quadraphonic file to stereo where the even numbered channels project to the left, odd numbered channels to the right, the map would be 0 1 0 1.

Parameters:
inPtr
outPtr
frames
oldNumChannels
newNumChannels
dfdata format of buffer
mapAn array oldNumChannels long indicating which oldNumChannel to use in the new channel. Not yet implemented: A channel index of -1 indicates zeroing (silencing) that channel.
- (SNDKIT_API void) SndChannelMap (void *)  inPtr
(void *)  outPtr
(long)  frames
(int)  oldNumChannels
(int)  newNumChannels
(SndSampleFormat)  df
(short *)  map 

Maps old channels to the new number of channels in the buffer, in place.

Endian-agnostic. Buffer must have enough memory allocated to hold the increased data. Remaps channels in an arbitary fashion, either increasing or decreasing the channels or rearranging them. The channel map determines which old channels are to be copied to the new channel arrangement. This is an array of newNumChannels length containing the indexes of the old channels. Channel indexes are zero based. If an index in the map is negative, that channel is zeroed in the output. For example, to map a stereo file to hexaphonic where the even numbered channels project to the left, odd numbered channels to the right, the map would be 0 1 0 1 0 1.

Parameters:
inPtr
outPtr
frames
oldNumChannels
newNumChannels
dfA SndSampleFormat giving the data format of buffer.
mapAn array newNumChannels long indicating which oldNumChannel to use in the new channel. A channel index of -1 indicates zeroing (silencing) that channel.
- (SNDKIT_API void) SndChannelMap (void *)  inPtr
(void *)  outPtr
(long)  frames
(int)  oldNumChannels
(int)  newNumChannels
(SndSampleFormat)  df
(short *)  map 

Maps old channels to the new number of channels in the buffer, in place.

Endian-agnostic. Buffer must have enough memory allocated to hold the increased data. Remaps channels in an arbitary fashion, either increasing or decreasing the channels or rearranging them. The channel map determines which old channels are to be copied to the new channel arrangement. This is an array of newNumChannels length containing the indexes of the old channels. Channel indexes are zero based. If an index in the map is negative, that channel is zeroed in the output. For example, to map a stereo file to hexaphonic where the even numbered channels project to the left, odd numbered channels to the right, the map would be 0 1 0 1 0 1.

Parameters:
inPtr
outPtr
frames
oldNumChannels
newNumChannels
dfA SndSampleFormat giving the data format of buffer.
mapAn array newNumChannels long indicating which oldNumChannel to use in the new channel. A channel index of -1 indicates zeroing (silencing) that channel.
- (void) stereoChannels: (int *)  leftAndRightChannels

Retrieve the channels used for stereo presentation (left and right).

This allows multichannel sound buffers to have a stereo version.

Parameters:
leftAndRightChannelsAn array of at least two integers which will be assigned the channel number of the left speaker in the zeroth element of the array, the channel number of the right speaker in the first element of the array.
- (void) stereoChannels: (int *)  leftAndRightChannels

Retrieve the channels used for stereo presentation (left and right).

This allows multichannel sound buffers to have a stereo version.

Parameters:
leftAndRightChannelsAn array of at least two integers which will be assigned the channel number of the left speaker in the zeroth element of the array, the channel number of the right speaker in the first element of the array.
- (id) zero

Sets buffer data to zero. Silence.

Returns:
Returns self.
- (id) zero

Sets buffer data to zero. Silence.

Returns:
Returns self.
- (id) zeroFrameRange: (NSRange)  frameRange

Zeros (silences) a given range of frames.

The range must be between 0 and the buffers frame length.

Returns:
Returns self.
- (id) zeroFrameRange: (NSRange)  frameRange

Zeros (silences) a given range of frames.

The range must be between 0 and the buffers frame length.

Returns:
Returns self.

Member Data Documentation

- (NSMutableData *) data [protected]

The audio sample data.

- (SndFormat) format [protected]

Holds sound parameters (sample rate, data format, channel count, frame count).

- (signed char *) speakerConfiguration [protected]

Holds the association of channels to speakers. Each element holds a channel number (0 - format.channelCount), -1 for unused and silent. Elements are arranged as described by SndSpeakerPosition above.


The documentation for this class was generated from the following files: