MusicKit
0.0.0
|
An in-memory audio buffer. More...
#import <SndAudioBuffer.h>
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 |
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.
- (void) amplitudeRMSOfChannels: | (float *) | rmsAmpPerChannel |
Returns the root mean squared amplitude of each channel in the audio buffer.
rmsAmpPerChannel | Points 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.
rmsAmpPerChannel | Points 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.
toDataFormat | A SndSampleFormat representing different sample data formats. |
toChannelCount | The new number of channels in the raw sample data. |
toSamplingRate |
- (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.
toDataFormat | A SndSampleFormat representing different sample data formats. |
toChannelCount | The new number of channels in the raw sample data. |
toSamplingRate |
- (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.
channel | The channel to extract. Must be in the range {0..[self channelCount] - 1}. |
- (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.
channel | The channel to extract. Must be in the range {0..[self channelCount] - 1}. |
+ (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.
dataFormat | A SndSampleFormat. |
channelCount | The number of sound channels per frame. |
sampleRate | The sampling rate specified in Hertz (Hz). |
timeInSeconds | Duration is specified in seconds. |
+ (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.
dataFormat | A SndSampleFormat. |
channelCount | The number of sound channels per frame. |
sampleRate | The sampling rate specified in Hertz (Hz). |
timeInSeconds | Duration is specified in seconds. |
+ (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.
newDataFormat | A SndSampleFormat. |
newChannelCount | The number of sound channels per frame. |
newSamplingRate | The sampling rate specified in Hertz (Hz). |
newFrameCount | Duration is specified in frames. |
+ (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.
newDataFormat | A SndSampleFormat. |
newChannelCount | The number of sound channels per frame. |
newSamplingRate | The sampling rate specified in Hertz (Hz). |
newFrameCount | Duration is specified in frames. |
+ (id) audioBufferWithFormat: | (SndFormat) | format |
Factory method creating a zeroed buffer of the given format and length.
format | A SndFormat describing the format of the buffer to be created. |
+ (id) audioBufferWithFormat: | (SndFormat) | format |
Factory method creating a zeroed buffer of the given format and length.
format | A SndFormat describing the format of the buffer to be created. |
+ (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)!
format | A pointer to a SndFormat. |
dataPointer |
+ (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)!
format | A pointer to a SndFormat. |
dataPointer |
+ (id) audioBufferWithSnd: | (Snd *) | snd | |
inRange: | (NSRange) | rangeInFrames | |
Factory method creating audioBuffers from a region of the given Snd.
snd | |
rangeInFrames | An NSRange structure indicating the start and end of the region in samples. |
+ (id) audioBufferWithSnd: | (Snd *) | snd | |
inRange: | (NSRange) | rangeInFrames | |
Factory method creating audioBuffers from a region of the given Snd.
snd | |
rangeInFrames | An NSRange structure indicating the start and end of the region in samples. |
+ (id) audioBufferWithSNDStreamBuffer: | (SNDStreamBuffer *) | streamBuffer |
Factory method creating an SndAudioBuffer instance from a SNDStreamBuffer.
streamBuffer | A fully populated SNDStreamBuffer structure. |
+ (id) audioBufferWithSNDStreamBuffer: | (SNDStreamBuffer *) | streamBuffer |
Factory method creating an SndAudioBuffer instance from a SNDStreamBuffer.
streamBuffer | A fully populated SNDStreamBuffer structure. |
- (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.
- (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.
- (int) channelCount |
Returns the number of channels in the audio buffer.
- (int) channelCount |
Returns the number of channels in the audio buffer.
- (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.
fromDataPtr | A pointer to raw sample data. |
bufferFrameRange | Indicates the region of the buffer which will be converted, specified in channel independent samples. |
fromDataFormat | A SndSampleFormat representing different sample data formats. |
fromChannelCount | The old number of channels in the raw sample data. |
fromSamplingRate | The old sampling rate in the raw sample data. |
- (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.
fromDataPtr | A pointer to raw sample data. |
bufferFrameRange | Indicates the region of the buffer which will be converted, specified in channel independent samples. |
fromDataFormat | A SndSampleFormat representing different sample data formats. |
fromChannelCount | The old number of channels in the raw sample data. |
fromSamplingRate | The old sampling rate in the raw sample data. |
- (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.
newFormat | The 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.
newFormat | The 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.
newDataFormat | A SndSampleFormat representing different sample data formats. |
- (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.
newDataFormat | A SndSampleFormat representing different sample data formats. |
- (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.
toDataFormat | A SndSampleFormat representing different sample data formats. |
toChannelCount | Number of channels for the new sound. If less than the current number, channels are averaged, if more, channels are duplicated. |
- (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.
toDataFormat | A SndSampleFormat representing different sample data formats. |
toChannelCount | Number of channels for the new sound. If less than the current number, channels are averaged, if more, channels are duplicated. |
- (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.
toDataFormat | A SndSampleFormat representing different sample data formats. |
toChannelCount | The new number of channels. Reallocation occurs if expanding buffers. |
toSampleRate | The new sampling rate. |
largeFilter | TRUE means use 65tap FIR filter, with higher quality. |
interpolateFilter | When not in "fast" mode, controls whether or not the filter coefficients are interpolated (disregarded in fast mode). |
linearInterpolation | If TRUE, linear interpolation uses a fast, noninterpolating resample routine but is relatively noisy. |
- (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.
toDataFormat | A SndSampleFormat representing different sample data formats. |
toChannelCount | The new number of channels. Reallocation occurs if expanding buffers. |
toSampleRate | The new sampling rate. |
largeFilter | TRUE means use 65tap FIR filter, with higher quality. |
interpolateFilter | When not in "fast" mode, controls whether or not the filter coefficients are interpolated (disregarded in fast mode). |
linearInterpolation | If TRUE, linear interpolation uses a fast, noninterpolating resample routine but is relatively noisy. |
- (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
bytes | The void * array to copy from. |
count | The number of bytes to copy from the array. |
format | A SndFormat containing valid channelCount, samplingRate and dataFormat variables. |
- (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
bytes | The void * array to copy from. |
count | The number of bytes to copy from the array. |
format | A SndFormat containing valid channelCount, samplingRate and dataFormat variables. |
- (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
bytes | The void * array to copy from. |
range | The start location and number of bytes to copy from the array. |
format | A SndFormat containing valid channelCount, samplingRate and dataFormat variables. |
- (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
bytes | The void * array to copy from. |
range | The start location and number of bytes to copy from the array. |
format | A SndFormat containing valid channelCount, samplingRate and dataFormat variables. |
- (id) copyDataFromBuffer: | (SndAudioBuffer *) | audioBufferToCopyFrom |
Copies the audio buffer NSData instance from the given buffer to the receiver.
Audio buffers must be the same format.
audioBufferToCopyFrom | The audio buffer instance to copy the data from. |
- (id) copyDataFromBuffer: | (SndAudioBuffer *) | audioBufferToCopyFrom |
Copies the audio buffer NSData instance from the given buffer to the receiver.
Audio buffers must be the same format.
audioBufferToCopyFrom | The audio buffer instance to copy the data from. |
- (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
fromBuffer | The audio buffer to copy from. |
bufferRange | The range of fromBuffer in sample frames to copy into. |
fromFrameRange | The start location and number of samples to copy to the receiving buffer. |
- (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
fromBuffer | The audio buffer to copy from. |
bufferRange | The range of fromBuffer in sample frames to copy into. |
fromFrameRange | The start location and number of samples to copy to the receiving buffer. |
- (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
sourceBuffer | The audio buffer to copy from. |
rangeInSamples | The start location and number of samples to copy to the receiving buffer. |
- (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
sourceBuffer | The audio buffer to copy from. |
rangeInSamples | The start location and number of samples to copy to the receiving buffer. |
- (id) copyWithZone: | (NSZone *) | zone |
SndAudioBuffer object copying.
- (id) copyWithZone: | (NSZone *) | zone |
SndAudioBuffer object copying.
- (SndSampleFormat) dataFormat |
Returns the format of the sample data as a SndSampleFormat enumerated type.
- (SndSampleFormat) dataFormat |
Returns the format of the sample data as a SndSampleFormat enumerated type.
- (NSString *) description |
Returns a description of the instance as an NSString.
- (NSString *) description |
Returns a description of the instance as an NSString.
- (double) duration |
Returns the length of the audio buffer in seconds.
- (double) duration |
Returns the length of the audio buffer in seconds.
- (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.
streamBuffer | Pointer 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.
streamBuffer | Pointer 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.
sampleIndex | Points 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.
sampleIndex | Points 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.
frameIndex | Points to an unsigned long to store the frame index of the maximum magnitude sample. |
channel | Points 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.
frameIndex | Points to an unsigned long to store the frame index of the maximum magnitude sample. |
channel | Points 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.
pMin | Points to a float to store the minimum sample value (between -1.0 and 1.0). |
minLocation | Points to an unsigned long to store the sample index of the minimum sample. |
pMax | Points to a float to store the maximum sample value (between -1.0 and 1.0). |
maxLocation | Points 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.
pMin | Points to a float to store the minimum sample value (between -1.0 and 1.0). |
minLocation | Points to an unsigned long to store the sample index of the minimum sample. |
pMax | Points to a float to store the maximum sample value (between -1.0 and 1.0). |
maxLocation | Points 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.
pMin | Points to a float to store the minimum sample value (between -1.0 and 1.0). |
pMax | Points 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.
pMin | Points to a float to store the minimum sample value (between -1.0 and 1.0). |
pMax | Points to a float to store the maximum sample value (between -1.0 and 1.0). |
- (int) frameSizeInBytes |
Returns the size of a sample frame in bytes.
- (int) frameSizeInBytes |
Returns the size of a sample frame in bytes.
- (BOOL) hasSameFormatAsBuffer: | (SndAudioBuffer *) | buff |
compares the data format and length of this buffer to a second buffer.
The number of frames (frameCount) are compared.
buff | The SndAudioBuffer to compare to. |
- (BOOL) hasSameFormatAsBuffer: | (SndAudioBuffer *) | buff |
compares the data format and length of this buffer to a second buffer.
The number of frames (frameCount) are compared.
buff | The SndAudioBuffer to compare to. |
- (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)
sndBuffer | An existing initialised SndAudioBuffer. |
- (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)
sndBuffer | An existing initialised SndAudioBuffer. |
- (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.
sndBuffer | An existing initialised SndAudioBuffer. |
rangeInFrames | The NSRange of the supplied sndBuffer to initialise the new instance with. |
- (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.
sndBuffer | An existing initialised SndAudioBuffer. |
rangeInFrames | The NSRange of the supplied sndBuffer to initialise the new instance with. |
- (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.
dataFormat | A SndSampleFormat. |
channelCount | Number of audio channels, 1 for mono, 2 for stereo, 4 for quad etc.. |
samplingRate | Sample rate in Hertz. |
timeInSeconds | The size of the buffer in seconds. |
- (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.
dataFormat | A SndSampleFormat. |
channelCount | Number of audio channels, 1 for mono, 2 for stereo, 4 for quad etc.. |
samplingRate | Sample rate in Hertz. |
timeInSeconds | The size of the buffer in seconds. |
- (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).
dataFormat | A SndSampleFormat. |
channelCount | The number of sound channels. |
samplingRate | Sample rate in Hertz. |
newFrameCount | The number of frames, each frame consists of channelCount number of samples. |
- (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).
dataFormat | A SndSampleFormat. |
channelCount | The number of sound channels. |
samplingRate | Sample rate in Hertz. |
newFrameCount | The number of frames, each frame consists of channelCount number of samples. |
- (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.
format | A SndFormat. All fields must be valid before calling this method. |
sampleData | A pointer to the memory holding the sample data in the format described by format. |
- (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.
format | A SndFormat. All fields must be valid before calling this method. |
sampleData | A pointer to the memory holding the sample data in the format described by format. |
- (long) lengthInBytes |
Returns the length of the buffer's sample data in bytes.
- (long) lengthInBytes |
Returns the length of the buffer's sample data 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.
- (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.
- (double) maximumAmplitude |
Returns the maximum amplitude of the format, that is, the maximum positive value of a sample.
- (double) maximumAmplitude |
Returns the maximum amplitude of the format, that is, the maximum positive 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.
buff | The SndAudioBuffer instance to mix. |
- (long) mixWithBuffer: | (SndAudioBuffer *) | buff |
Mixes supplied SndAudioBuffer instance with the receiving instance, modifying it.
Mixes the entire buffer onto the original buffer.
buff | The SndAudioBuffer instance to mix. |
- (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.
buff | The SndAudioBuffer instance to mix. |
start | The sample frame to begin mixing from. |
end | The sample frame to end mixing at. |
expand | If TRUE, receiver is allowed to expand buff in place if required to change data format before mixing, (not sample rate). |
- (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.
buff | The SndAudioBuffer instance to mix. |
start | The sample frame to begin mixing from. |
end | The sample frame to end mixing at. |
expand | If TRUE, receiver is allowed to expand buff in place if required to change data format before mixing, (not sample rate). |
- (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.
frameIndex | The frame index, between 0 and the value returned by lengthInSampleFrames less one, inclusive. |
channel | The 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. |
- (float) sampleAtFrameIndex: | (unsigned long) | frameIndex | |
channel: | (int) | channel | |
Retrieves a normalised sample given the frame number (time position) and channel number.
frameIndex | The frame index, between 0 and the value returned by lengthInSampleFrames less one, inclusive. |
channel | The 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. |
- (double) samplingRate |
Returns the sampling rate of the audio buffer in Hertz.
- (double) samplingRate |
Returns the sampling rate of the audio buffer in Hertz.
- (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.
sampleValue | A value specified as a bivalent normalised value (between -1.0 and 1.0). |
frameIndex | The frame index, between 0 and the value returned by lengthInSampleFrames less one, inclusive. |
channel | The channel index, between 0 and the number of channels in the buffer (channelCount - 1). |
- (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.
sampleValue | A value specified as a bivalent normalised value (between -1.0 and 1.0). |
frameIndex | The frame index, between 0 and the value returned by lengthInSampleFrames less one, inclusive. |
channel | The channel index, between 0 and the number of channels in the buffer (channelCount - 1). |
- (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.
fromSound | Holds header information about the input sound. |
inputPtr | Points to a contiguous buffer of input data to be used. |
toSound | Holds header information about the target sound. |
outPtr | Pointer to a buffer big enough to hold the output data. |
factor | Ratio of new_sample_rate / old_sample_rate |
largeFilter | TRUE means use 65tap FIR filter, with higher quality. |
interpFilter | When not in "fast" mode, controls whether or not the filter coefficients are interpolated (disregarded in fast mode). |
fast | if 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.
fromSound | Holds header information about the input sound. |
inputPtr | Points to a contiguous buffer of input data to be used. |
toSound | Holds header information about the target sound. |
outPtr | Pointer to a buffer big enough to hold the output data. |
factor | Ratio of new_sample_rate / old_sample_rate |
largeFilter | TRUE means use 65tap FIR filter, with higher quality. |
interpFilter | When not in "fast" mode, controls whether or not the filter coefficients are interpolated (disregarded in fast mode). |
fast | if 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_).
fromPtr | Pointer to the byte buffer to read data from. |
toPtr | Pointer to the byte buffer to write data to. |
dfFrom | The data format to convert from. |
dfTo | The data format to convert to. |
outCount | Length in samples of the original buffer, counting number of channels, that is duration in samples * number of channels. |
- (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_).
fromPtr | Pointer to the byte buffer to read data from. |
toPtr | Pointer to the byte buffer to write data to. |
dfFrom | The data format to convert from. |
dfTo | The data format to convert to. |
outCount | Length in samples of the original buffer, counting number of channels, that is duration in samples * number of channels. |
- (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.
inPtr | |
outPtr | |
frames | |
oldNumChannels | |
newNumChannels | |
df | data format of buffer |
map | An 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.
inPtr | |
outPtr | |
frames | |
oldNumChannels | |
newNumChannels | |
df | data format of buffer |
map | An 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.
inPtr | |
outPtr | |
frames | |
oldNumChannels | |
newNumChannels | |
df | A SndSampleFormat giving the data format of buffer. |
map | An 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.
inPtr | |
outPtr | |
frames | |
oldNumChannels | |
newNumChannels | |
df | A SndSampleFormat giving the data format of buffer. |
map | An 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.
leftAndRightChannels | An 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.
leftAndRightChannels | An 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.
- (id) zero |
Sets buffer data to zero. Silence.
- (id) zeroFrameRange: | (NSRange) | frameRange |
Zeros (silences) a given range of frames.
The range must be between 0 and the buffers frame length.
- (id) zeroFrameRange: | (NSRange) | frameRange |
Zeros (silences) a given range of frames.
The range must be between 0 and the buffers frame length.
- (NSMutableData *) data [protected] |
The audio sample data.
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.