Dali: Audio Buffer -- C API

[ Header Files | Types | Constants | Allocation | Manipulation | Casting | Queries | See Also ]

Header Files

#include <dvmbasic.h>

Type Definitions

Audio

The Audio abstraction stores generic 8-bit and 16-bit audio samples in a 1D array. The Audio buffer can be either physical or virtual. The buffer may contains contiguous samples from a single channel, or interleaved samples from both left and right channel. In cases where we store both channels, we can select an individual channel for processing by passing in a (offset, stride) pair.

     typedef struct Audio {
         int start;
         int length;
         unsigned char *firstSample;
         unsigned char *buffer;
         char isVirtual;
     } Audio;
   
start
number of samples skipped from the physical buffer
length
number of samples in the current buffer
firstSample
pointer to the first audio sample
buffer
pointer to the beginning of the physical buffer
isVirtual
1 if the audio buffer is a virtual buffer, 0 otherwise.

Constants

Return Code

The return codes indicate if an audio operation is successful. DVM_AUDIO_OK is returned if an operation is completed successfully. Otherwise DVM_AUDIO_ERROR is returned.

    #define DVM_AUDIO_OK 0
    #define DVM_AUDIO_ERROR 1
    

Operators

Allocation

Audio *Audio8New (int numSamples)
Audio *Audio16New (int numSamples)

void AudioFree (Audio *audio)

Audio *Audio8Clip (Audio *audio, int x, int numSamples)
Audio *Audio16Clip (Audio *audio, int x, int numSamples);

void Audio8Reclip (Audio *audio, int x, int numSamples, Audio *clipped)
void Audio16Reclip (Audio *audio, int x, int numSamples, Audio *clipped);


Manipulation

void Audio8Set (Audio *audio, unsigned char v)

void Audio8SetSome (Audio *audio, unsigned char v, int offset, int stride)
void Audio16SetSome (Audio *audio, short value, int offset, int stride)

void Audio8Copy (Audio *src, Audio *dest)
void Audio16Copy (Audio *src, Audio *dest)

void Audio8CopySome (Audio *src, Audio *dest, int srcOffset, int srcStride, int destOffset, int destStride)
void Audio16CopySome (Audio *src, Audio *dest, int srcOffset, int srcStride, int destOffset, int destStride)

void Audio8Split (Audio *src, Audio *left, Audio *right)
void Audio16Split (Audio *src, Audio *left, Audio *right)

void Audio8Merge (Audio *left, Audio *right, Audio *dest)
void Audio16Merge (Audio *left, Audio *right, Audio *dest)

void Audio8ResampleHalf(Audio *in, Audio *out)
void Audio8ResampleQuarter(Audio *in, Audio *out)
void Audio16ResampleHalf(Audio *in, Audio *out)
void Audio16ResampleQuarter(Audio *in, Audio *out)

void Audio8ResampleLinear(Audio *src, int srcSamples, int destSamples, Audio *dest)
void Audio8ResampleDecimate(Audio *src, int srcSamples, int destSamples, Audio *dest)
void Audio16ResampleLinear(Audio *src, int srcSamples, int destSamples, Audio *dest)
void Audio16ResampleDecimate(Audio *src, int srcSamples, int destSamples, Audio *dest)


Casting

Audio *BitstreamCastToAudio8(BitStream *bs, int offset, int length)
Audio *BitstreamCastToAudio16(BitStream *bs, int offset, int length)

BitStream *Audio8CastToBitstream(Audio *audio);
BitStream *Audio16CastToBitstream(Audio *audio);


Queries

AudioGetStartOffset(Audio *audio)
AudioGetNumOfSamples(Audio *audio)

int Audio8ChunkAbsSum(Audio *audio, int chunkSize, int **pSums)
int Audio16ChunkAbsSum(Audio *audio, int chunkSize, int **pSums)

int Audio8MaxAbs(Audio *audio)
int Audio16MaxAbs(Audio *audio)


See Also

Streams , AudioMap


Last updated : Saturday, November 14, 1998, 07:50 PM