00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00017
00018 #ifndef __SNDAUDIOBUFFER_H__
00019 #define __SNDAUDIOBUFFER_H__
00020
00021 #import <Foundation/Foundation.h>
00022 #import "Snd.h"
00023 #import "SndFunctions.h"
00024 #import "SndFormat.h"
00025
00026
00027 typedef enum {
00028 SND_SPEAKER_UNUSED = -1,
00029 SND_SPEAKER_LEFT = 0,
00030 SND_SPEAKER_RIGHT = 1,
00031 SND_SPEAKER_LEFT_SURROUND = 2,
00032 SND_SPEAKER_RIGHT_SURROUND = 3,
00033 SND_SPEAKER_CENTRE = 4,
00034 SND_SPEAKER_LFE = 5,
00035 SND_SPEAKER_CENTRE_REAR = 6,
00036
00037 SND_SPEAKER_SIZE
00038 } SndSpeakerPosition;
00039
00051 @interface SndAudioBuffer : NSObject
00052 {
00054 SndFormat format;
00056 NSMutableData *data;
00061 signed char *speakerConfiguration;
00062 }
00063
00072 + audioBufferWithDataFormat: (SndSampleFormat) dataFormat
00073 channelCount: (int) channelCount
00074 samplingRate: (double) sampleRate
00075 duration: (double) timeInSeconds;
00076
00085 + audioBufferWithDataFormat: (SndSampleFormat) newDataFormat
00086 channelCount: (int) newChannelCount
00087 samplingRate: (double) newSamplingRate
00088 frameCount: (long) newFrameCount;
00089
00095 + audioBufferWithFormat: (SndFormat) format;
00096
00105 + audioBufferWithFormat: (SndFormat *) format data: (void *) dataPointer;
00106
00112 + audioBufferWithSNDStreamBuffer: (SNDStreamBuffer *) streamBuffer;
00113
00120 + audioBufferWithSnd: (Snd *) snd inRange: (NSRange) rangeInFrames;
00121
00131 - initWithFormat: (SndFormat *) format data: (void *) sampleData;
00132
00140 - initWithBuffer: (SndAudioBuffer *) sndBuffer;
00141
00148 - initWithBuffer: (SndAudioBuffer *) sndBuffer
00149 range: (NSRange) rangeInFrames;
00150
00161 - initWithDataFormat: (SndSampleFormat) dataFormat
00162 channelCount: (int) channelCount
00163 samplingRate: (double) samplingRate
00164 frameCount: (long) newFrameCount;
00165
00176 - initWithDataFormat: (SndSampleFormat) dataFormat
00177 channelCount: (int) channelCount
00178 samplingRate: (double) samplingRate
00179 duration: (double) timeInSeconds;
00180
00192 - (long) mixWithBuffer: (SndAudioBuffer *) buff
00193 fromStart: (unsigned long) start
00194 toEnd: (unsigned long) end
00195 canExpand: (BOOL) expand;
00196
00204 - (long) mixWithBuffer: (SndAudioBuffer *) buff;
00205
00210 - (id) copyWithZone: (NSZone *) zone;
00211
00219 - copyDataFromBuffer: (SndAudioBuffer *) audioBufferToCopyFrom;
00220
00231 - copyBytes: (void *) bytes count: (unsigned int) count format: (SndFormat) format;
00232
00243 - copyBytes: (void *) bytes intoRange: (NSRange) range format: (SndFormat) format;
00244
00253 - copyFromBuffer: (SndAudioBuffer *) sourceBuffer intoRange: (NSRange) rangeInSamples;
00254
00264 - (long) copyFromBuffer: (SndAudioBuffer *) fromBuffer
00265 intoFrameRange: (NSRange) bufferRange
00266 fromFrameRange: (NSRange) fromFrameRange;
00267
00274 - (void) fillSNDStreamBuffer: (SNDStreamBuffer *) streamBuffer;
00275
00284 - (SndAudioBuffer *) audioBufferOfChannel: (int) channel;
00285
00293 - (unsigned long) lengthInSampleFrames;
00294
00300 - setLengthInSampleFrames: (unsigned long) newSampleFrameCount;
00301
00306 - (long) lengthInBytes;
00307
00312 - (double) duration;
00313
00318 - (double) samplingRate;
00319
00324 - (int) channelCount;
00325
00330 - (SndSampleFormat) dataFormat;
00331
00336 - (SndFormat) format;
00337
00344 - (void *) bytes;
00345
00354 - (BOOL) hasSameFormatAsBuffer: (SndAudioBuffer*) buff;
00355
00360 - zero;
00361
00368 - zeroFrameRange: (NSRange) frameRange;
00369
00374 - (int) frameSizeInBytes;
00375
00380 - (NSString *) description;
00381
00387 - (void) findMin: (float *) pMin max: (float *) pMax;
00388
00393 - (double) maximumAmplitude;
00394
00402 - (void) normalise;
00403
00409 - (void) scaleBy: (float) scaleFactor;
00410
00419 - (float) sampleAtFrameIndex: (unsigned long) frameIndex channel: (int) channel;
00420
00429 - (void) stereoChannels: (int *) leftAndRightChannels;
00430
00431 @end
00432
00434
00435 @interface SndAudioBuffer(SampleConversion)
00436
00445 - (SndAudioBuffer *) audioBufferConvertedToFormat: (SndSampleFormat) toDataFormat
00446 channelCount: (int) toChannelCount
00447 samplingRate: (double) toSamplingRate;
00448
00455 - convertToFormat: (SndFormat) newFormat;
00456
00464 - convertToSampleFormat: (SndSampleFormat) newDataFormat;
00465
00483 - (long) convertBytes: (void *) fromDataPtr
00484 intoFrameRange: (NSRange) bufferFrameRange
00485 fromFormat: (SndSampleFormat) fromDataFormat
00486 channelCount: (int) fromChannelCount
00487 samplingRate: (double) fromSamplingRate;
00488
00498 - convertToSampleFormat: (SndSampleFormat) toDataFormat
00499 channelCount: (int) toChannelCount;
00500
00515 - convertToSampleFormat: (SndSampleFormat) toDataFormat
00516 channelCount: (int) toChannelCount
00517 samplingRate: (double) toSampleRate
00518 useLargeFilter: (BOOL) largeFilter
00519 interpolateFilter: (BOOL) interpolateFilter
00520 useLinearInterpolation: (BOOL) linearInterpolation;
00521
00539 SNDKIT_API int SndChangeSampleType(void *fromPtr, void *toPtr, SndSampleFormat dfFrom, SndSampleFormat dfTo, long outCount);
00540
00563 SNDKIT_API void SndChangeSampleRate(const SndFormat fromSound,
00564 void *inputPtr,
00565 SndFormat *toSound,
00566 short *outPtr,
00567 BOOL largeFilter,
00568 BOOL interpFilter,
00569 BOOL fast);
00570
00590 SNDKIT_API void SndChannelMap(void *inPtr,
00591 void *outPtr,
00592 long frames,
00593 int oldNumChannels,
00594 int newNumChannels,
00595 SndSampleFormat df,
00596 short *map);
00597
00598
00619 SNDKIT_API void SndChannelDecrease(void *inPtr,
00620 void *outPtr,
00621 unsigned long frames,
00622 int oldNumChannels,
00623 int newNumChannels,
00624 SndSampleFormat df,
00625 short *map);
00626
00627 @end
00628
00629 #endif