Description | Uses | Classes, Interfaces, Objects and Records | Functions and Procedures | Types | Constants | Variables |
Set of routines to work with PCM wave data.
Version 2.5.2008.07 Still here
Version 2.5.2011.12 x64 compatibility
Name | Description |
---|---|
record unaPCMChunk |
|
packed record unaPCMFormat |
|
packed record unavclWavePipeFormatExchange |
Data structure used for format exchange. |
packed record unaWaveFormat |
function waveMix(buf1, buf2, buf3: pointer; samples: unsigned; bits1, bits2, bits3: unsigned; doAdd: bool = true; numChannels: unsigned = 1): unsigned; overload; |
function waveMix(const chunk1, chunk2, chunk3: unaPCMChunk; doAdd: bool = true): unsigned; overload; |
function waveGetVolume(buf: pointer; samples: unsigned; bits: unsigned; numChannels: unsigned = 1; channel: unsigned = 0; deltaMethod: bool = false): unsigned; |
function waveGetLogVolume(volume: int): unsigned; |
function waveGetLogVolume100(volume: int): unsigned; |
function waveExtractChannel(buf, dest: pointer; samples: unsigned; bits: unsigned; numChannels: unsigned = 1; channel: unsigned = 0): unsigned; |
function waveReplaceChannel(buf, source: pointer; samples: unsigned; bits: unsigned; numChannels: unsigned = 1; channel: unsigned = 0): unsigned; |
function waveReverse(buf: pointer; samples: unsigned; bits: unsigned; numChannels: unsigned): unsigned; |
function waveResample(bufSrc, bufDst: pointer; samples, numChannelsSrc, numChannelsDst, bitsSrc, bitsDst, rateSrc, rateDst: unsigned): unsigned; overload; |
function waveResample(const bufSrc: unaPCMChunk; var bufDst: unaPCMChunk): unsigned; overload; |
function waveGetChunkMaxSamplesCount(const chunk: unaPCMChunk): unsigned; |
function waveGetChunkCurSamplesCount(const chunk: unaPCMChunk): unsigned; |
function waveReallocateChunk(var chunk: unaPCMChunk; numSamples: unsigned = 0): unsigned; |
function waveReadFromChunk(var chunk: unaPCMChunk; buf: pointer; size: unsigned; bufOffs: unsigned = 0): unsigned; |
function waveWriteToChunk(var chunk: unaPCMChunk; buf: pointer; size: unsigned; bufOffs: unsigned = 0): unsigned; |
function waveFindNextGcd(rate1, rate2: unsigned; startFrom: unsigned): unsigned; |
function waveModifyVolume100(volume: unsigned; buf: pointer; samples: unsigned; bits: unsigned = 16; numChannels: unsigned = 1; channel: int = -1): unsigned; overload; |
function waveModifyVolume100(volume: unsigned; const chunk: unaPCMChunk; channel: int): unsigned; overload; |
punaPCMFormat = ˆunaPCMFormat; |
punaWaveFormat = ˆunaWaveFormat; |
punaPCMChunk = ˆunaPCMChunk; |
punavclWavePipeFormatExchange = ˆunavclWavePipeFormatExchange; |
function waveMix(buf1, buf2, buf3: pointer; samples: unsigned; bits1, bits2, bits3: unsigned; doAdd: bool = true; numChannels: unsigned = 1): unsigned; overload; |
Mixes buf1 and buf2 and stores the result in buf3 (buf3 could be one of buf1 or buf2). bitsN (N = 1, 2 or 3) specifies the number or bits in sample: 8 = 1 byte per sample (from $00 = -128 to $FF = +127; $7F = -1, $80 = 0) 16 = 2 bytes per sample (from $8000 = -32768 to $7FFF = 32767; $0 = 0, $FFFF = -1) 32 = 4 bytes per sample (from $80000000 = -2147483648 to $7FFFFFFF = +2147483647; $0 = 0, $FFFFFFFF = -1) Size of buffer #N in bytes = (bitsN * samples * numChannels) shr 3 Mixing is done by adding (doAdd is true) or subtracting (doAdd is false) samples with clipping. Returnsnumber of samples mixed. |
function waveMix(const chunk1, chunk2, chunk3: unaPCMChunk; doAdd: bool = true): unsigned; overload; |
Mixes two chunks. Returnsnumber of samples mixed. |
function waveGetVolume(buf: pointer; samples: unsigned; bits: unsigned; numChannels: unsigned = 1; channel: unsigned = 0; deltaMethod: bool = false): unsigned; |
Calculates volume. Calculation is done by adding squares of samples and then dividing result on number of samples and applying square root. Assuming data has "natural" source. That means you can get useless results for signals, that are not sound by nature (constant non-zero signal for example).
Parameters
Returnsvalue is from 0 (silence) to 32768 (loudest possible sound) |
function waveGetLogVolume(volume: int): unsigned; |
Returns Logarithmic volume.
Parameters
Returnsvalue range from 0 to 300 |
function waveGetLogVolume100(volume: int): unsigned; |
Returns Logarithmic volume. Input range is from 0 to 32768. Result range is from 0 to 100. |
function waveExtractChannel(buf, dest: pointer; samples: unsigned; bits: unsigned; numChannels: unsigned = 1; channel: unsigned = 0): unsigned; |
Extracts specified channel from PCM chunk.
Parameters
Returnsnumber of samples stored in dest buffer |
function waveReplaceChannel(buf, source: pointer; samples: unsigned; bits: unsigned; numChannels: unsigned = 1; channel: unsigned = 0): unsigned; |
Replaces PCM data for specified channel with new one. Old data for this channel will be lost.
Parameters
Returnsnumber of samples stored in dest buffer |
function waveReverse(buf: pointer; samples: unsigned; bits: unsigned; numChannels: unsigned): unsigned; |
Reverses PCM samples in wave chunk. bits specifies number of bits in sample. numChannels specifies number of channels in stream. Returnsnumber of samples processed. |
function waveResample(bufSrc, bufDst: pointer; samples, numChannelsSrc, numChannelsDst, bitsSrc, bitsDst, rateSrc, rateDst: unsigned): unsigned; overload; |
Changes PCM stream characteristics. numChannels conversions supported: mono => any Number Of Channels stereo => mono; stereo; 4 channels; 6 channels; 8 channels ... 3 channels => mono; 3 channels; 6 channels; 9 channels ... 4 channels => mono; stereo; 4 channels; 8 channels; 12 channels ... 5 channels => mono; 5 channels; 10 channels; 15 channels ... 6 channels => mono; 3 channels; 6 channels; 12 channels ... ... i.e. (number of dst channels) mod (number of src channels) must be 0
Parameters
Returnsnumber of bytes produced by the function. |
function waveResample(const bufSrc: unaPCMChunk; var bufDst: unaPCMChunk): unsigned; overload; |
Changes PCM stream characteristics. Returnsnumber of bytes produced by the function. |
function waveGetChunkMaxSamplesCount(const chunk: unaPCMChunk): unsigned; |
Returnsnumber of full samples which can be stored in given PCM chunk. |
function waveGetChunkCurSamplesCount(const chunk: unaPCMChunk): unsigned; |
Returnscurrent number of full samples which is stored in given PCM chunk. |
function waveReallocateChunk(var chunk: unaPCMChunk; numSamples: unsigned = 0): unsigned; |
Reallocates PCM chunk to hold required number of samples. NOTE: chunk.chunkData must be a valid pointer (or nil) before calling this function. Returnsnumber of bytes allocated. |
function waveReadFromChunk(var chunk: unaPCMChunk; buf: pointer; size: unsigned; bufOffs: unsigned = 0): unsigned; |
Reads bytes from PCM chunk. Returnsnumber of bytes read |
function waveWriteToChunk(var chunk: unaPCMChunk; buf: pointer; size: unsigned; bufOffs: unsigned = 0): unsigned; |
Writes bytes to PCM chunk. |
function waveFindNextGcd(rate1, rate2: unsigned; startFrom: unsigned): unsigned; |
Returns next gcd value. |
function waveModifyVolume100(volume: unsigned; buf: pointer; samples: unsigned; bits: unsigned = 16; numChannels: unsigned = 1; channel: int = -1): unsigned; overload; |
Modifies linear volume for all samples.
Parameters
ReturnsNumber of samples processed. |
function waveModifyVolume100(volume: unsigned; const chunk: unaPCMChunk; channel: int): unsigned; overload; |
Modifies linear volume for all samples.
Parameters
ReturnsNumber of samples processed. |
punaPCMFormat = ˆunaPCMFormat; |
– – |
punaWaveFormat = ˆunaWaveFormat; |
number of channels – – |
punaPCMChunk = ˆunaPCMChunk; |
channel mask – – |
punavclWavePipeFormatExchange = ˆunavclWavePipeFormatExchange; |
(c) 2012 Lake of Soft