From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/a02298.html | 1053 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1053 insertions(+) create mode 100644 docs/doxygen/nel/a02298.html (limited to 'docs/doxygen/nel/a02298.html') diff --git a/docs/doxygen/nel/a02298.html b/docs/doxygen/nel/a02298.html new file mode 100644 index 00000000..d06003f4 --- /dev/null +++ b/docs/doxygen/nel/a02298.html @@ -0,0 +1,1053 @@ + + +NeL: NLSOUND::IBuffer class Reference + + + +
+

NLSOUND::IBuffer Class Reference

#include <buffer.h> +

+

Inheritance diagram for NLSOUND::IBuffer: +

+ +NLSOUND::CBufferAL +NLSOUND::CBufferDSound + +

Detailed Description

+Sound buffer interface (implemented in sound driver dynamic library)
Author:
Olivier Cado

+Nevrax France

+
Date:
2001
+ +

+ +

+Definition at line 44 of file buffer.h. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Source properties

virtual uint32 getBufferADPCMEncoded (std::vector< uint8 > &result)=0
virtual uint32 getBufferMono16 (std::vector< sint16 > &result)=0
void decodeADPCM (uint8 *indata, sint16 *outdata, uint nbSample, TADPCMState &state)
void encodeADPCM (sint16 *indata, uint8 *outdata, uint nbSample, TADPCMState &state)
const sint _IndexTable [16]
const uint _StepsizeTable [89]

Public Member Functions

virtual bool fillBuffer (void *src, uint32 bufsize)=0
 Set the buffer size and fill the buffer. Return true if ok. Call setFormat() first.

virtual bool fillMore (void *src, uint32 srcsize)
virtual float getDuration () const=0
 Return the duration (in ms) of the sample in the buffer.

virtual void getFormat (TSampleFormat &format, uint &freq) const=0
 Return the format and frequency.

virtual const NLMISC::TStringIdgetName ()=0
 Return the name of this buffer.

virtual uint32 getSize () const=0
 Return the size of the buffer, in bytes.

virtual bool isBufferLoaded ()=0
 Return true if the buffer is loaded. Used for async load/unload.

virtual bool isFillMoreSupported () const=0
virtual bool isStereo () const=0
 Return true if the buffer is stereo, false if mono.

virtual void presetName (const NLMISC::TStringId &bufferName)=0
virtual void setFormat (TSampleFormat format, uint freq)=0
 Set the sample format. Example: freq=44100.

virtual void setSize (uint32 size)
 Force the buffer size without filling data (if isFillMoreSupported() only).

virtual ~IBuffer ()
 Destructor.


Protected Member Functions

 IBuffer ()
 Constructor.

+


Constructor & Destructor Documentation

+

+ + + + +
+ + + + + + + + + +
NLSOUND::IBuffer::IBuffer  )  [inline, protected]
+
+ + + + + +
+   + + +

+Constructor. +

+ +

+Definition at line 119 of file buffer.h. +

+

00119 {};
+
+

+ + + + +
+ + + + + + + + + +
virtual NLSOUND::IBuffer::~IBuffer  )  [inline, virtual]
+
+ + + + + +
+   + + +

+Destructor. +

+ +

+Definition at line 124 of file buffer.h. +

+

00124 {}
+
+


Member Function Documentation

+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NLSOUND::IBuffer::decodeADPCM uint8 indata,
sint16 outdata,
uint  nbSample,
TADPCMState state
[static]
+
+ + + + + +
+   + + +

+Unoptimized utility function designed to build ADPCM encoded sample bank file. Return the number of sample in the buffer. +

+Definition at line 164 of file buffer.cpp. +

+References _IndexTable, _StepsizeTable, index, NLSOUND::IBuffer::TADPCMState::PreviousSample, sint16, NLSOUND::IBuffer::TADPCMState::StepIndex, uint, and uint8. +

+

00165 {
+00166     uint8 *inp;         /* Input buffer pointer */
+00167     sint16 *outp;               /* output buffer pointer */
+00168     int sign;                   /* Current adpcm sign bit */
+00169     int delta;                  /* Current adpcm output value */
+00170     int step;                   /* Stepsize */
+00171     int valpred;                /* Predicted value */
+00172     int vpdiff;                 /* Current change to valpred */
+00173     int index;                  /* Current step change index */
+00174     int inputbuffer;            /* place to keep next 4-bit value */
+00175     int bufferstep;             /* toggle between inputbuffer/input */
+00176         
+00177     outp = outdata;
+00178     inp = indata;
+00179         
+00180     valpred = state.PreviousSample;
+00181     index = state.StepIndex;
+00182     step = _StepsizeTable[index];
+00183         
+00184     bufferstep = 0;
+00185     
+00186     for ( ; nbSample > 0 ; nbSample-- ) 
+00187         {
+00188                 
+00189                 /* Step 1 - get the delta value */
+00190                 if ( bufferstep ) 
+00191                 {
+00192                         delta = inputbuffer & 0xf;
+00193                 }
+00194                 else 
+00195                 {
+00196                         inputbuffer = *inp++;
+00197                         delta = (inputbuffer >> 4) & 0xf;
+00198                 }
+00199                 bufferstep = !bufferstep;
+00200                 
+00201                 /* Step 2 - Find new index value (for later) */
+00202                 index += _IndexTable[delta];
+00203                 if ( index < 0 )
+00204                         index = 0;
+00205                 if ( index > 88 )
+00206                         index = 88;
+00207                 
+00208                 /* Step 3 - Separate sign and magnitude */
+00209                 sign = delta & 8;
+00210                 delta = delta & 7;
+00211                 
+00212                 /* Step 4 - Compute difference and new predicted value */
+00213                 /*
+00214                 ** Computes 'vpdiff = (delta+0.5)*step/4', but see comment
+00215                 ** in adpcm_coder.
+00216                 */
+00217                 vpdiff = step >> 3;
+00218                 if ( delta & 4 )
+00219                         vpdiff += step;
+00220                 if ( delta & 2 )
+00221                         vpdiff += step>>1;
+00222                 if ( delta & 1 )
+00223                         vpdiff += step>>2;
+00224                 
+00225                 if ( sign )
+00226                         valpred -= vpdiff;
+00227                 else
+00228                         valpred += vpdiff;
+00229                 
+00230                 /* Step 5 - clamp output value */
+00231                 if ( valpred > 32767 )
+00232                         valpred = 32767;
+00233                 else if ( valpred < -32768 )
+00234                         valpred = -32768;
+00235                 
+00236                 /* Step 6 - Update step value */
+00237                 step = _StepsizeTable[index];
+00238                 
+00239                 /* Step 7 - Output value */
+00240                 *outp++ = valpred;
+00241     }
+00242         
+00243     state.PreviousSample = valpred;
+00244     state.StepIndex = index;
+00245 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NLSOUND::IBuffer::encodeADPCM sint16 indata,
uint8 outdata,
uint  nbSample,
TADPCMState state
[static]
+
+ + + + + +
+   + + +

+Unoptimized utility function designed to build ADPCM encoded sample bank file. Return the number of sample in the buffer. +

+Definition at line 51 of file buffer.cpp. +

+References _IndexTable, _StepsizeTable, index, NLSOUND::IBuffer::TADPCMState::PreviousSample, sint16, NLSOUND::IBuffer::TADPCMState::StepIndex, uint, and uint8. +

+Referenced by NLSOUND::CBufferDSound::getBufferADPCMEncoded(). +

+

00052 {
+00053     sint16 *inp;                        /* Input buffer pointer */
+00054     uint8 *outp;                /* output buffer pointer */
+00055     int val;                    /* Current input sample value */
+00056     int sign;                   /* Current adpcm sign bit */
+00057     int delta;                  /* Current adpcm output value */
+00058     int diff;                   /* Difference between val and valprev */
+00059     int step;                   /* Stepsize */
+00060     int valpred;                /* Predicted output value */
+00061     int vpdiff;                 /* Current change to valpred */
+00062     int index;                  /* Current step change index */
+00063     int outputbuffer;           /* place to keep previous 4-bit value */
+00064     int bufferstep;             /* toggle between outputbuffer/output */
+00065         
+00066     outp = outdata;
+00067     inp = indata;
+00068         
+00069     valpred = state.PreviousSample;
+00070     index = state.StepIndex;
+00071     step = _StepsizeTable[index];
+00072     
+00073     bufferstep = 1;
+00074         
+00075     for ( ; nbSample > 0 ; nbSample-- ) 
+00076         {
+00077                 val = *inp++;
+00078                 
+00079                 /* Step 1 - compute difference with previous value */
+00080                 diff = val - valpred;
+00081                 sign = (diff < 0) ? 8 : 0;
+00082                 if ( sign ) diff = (-diff);
+00083                 
+00084                 /* Step 2 - Divide and clamp */
+00085                 /* Note:
+00086                 ** This code *approximately* computes:
+00087                 **    delta = diff*4/step;
+00088                 **    vpdiff = (delta+0.5)*step/4;
+00089                 ** but in shift step bits are dropped. The net result of this is
+00090                 ** that even if you have fast mul/div hardware you cannot put it to
+00091                 ** good use since the fixup would be too expensive.
+00092                 */
+00093                 delta = 0;
+00094                 vpdiff = (step >> 3);
+00095                 
+00096                 if ( diff >= step ) 
+00097                 {
+00098                         delta = 4;
+00099                         diff -= step;
+00100                         vpdiff += step;
+00101                 }
+00102                 step >>= 1;
+00103                 if ( diff >= step  )
+00104                 {
+00105                         delta |= 2;
+00106                         diff -= step;
+00107                         vpdiff += step;
+00108                 }
+00109                 step >>= 1;
+00110                 if ( diff >= step ) 
+00111                 {
+00112                         delta |= 1;
+00113                         vpdiff += step;
+00114                 }
+00115                 
+00116                 /* Step 3 - Update previous value */
+00117                 if ( sign )
+00118                         valpred -= vpdiff;
+00119                 else
+00120                         valpred += vpdiff;
+00121                 
+00122                 /* Step 4 - Clamp previous value to 16 bits */
+00123                 if ( valpred > 32767 )
+00124                 {
+00125                         printf("over+ %d\n",valpred);
+00126                         valpred = 32767;
+00127                 }
+00128                 else if ( valpred < -32768 )
+00129                 {
+00130                         printf("over- %d\n",valpred);
+00131                         valpred = -32768;
+00132                 }
+00133                 
+00134                 /* Step 5 - Assemble value, update index and step values */
+00135                 delta |= sign;
+00136                 
+00137                 index += _IndexTable[delta];
+00138                 if ( index < 0 ) 
+00139                         index = 0;
+00140                 if ( index > 88 ) 
+00141                         index = 88;
+00142                 step = _StepsizeTable[index];
+00143                 
+00144                 /* Step 6 - Output value */
+00145                 if ( bufferstep ) 
+00146                 {
+00147                         outputbuffer = (delta << 4) & 0xf0;
+00148                 } 
+00149                 else 
+00150                 {
+00151                         *outp++ = (delta & 0x0f) | outputbuffer;
+00152                 }
+00153                 bufferstep = !bufferstep;
+00154     }
+00155         
+00156     /* Output last step, if needed */
+00157     if ( !bufferstep )
+00158                 *outp++ = outputbuffer;
+00159     
+00160     state.PreviousSample = valpred;
+00161     state.StepIndex = index;
+00162 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
virtual bool NLSOUND::IBuffer::fillBuffer void *  src,
uint32  bufsize
[pure virtual]
+
+ + + + + +
+   + + +

+Set the buffer size and fill the buffer. Return true if ok. Call setFormat() first. +

+ +

+Implemented in NLSOUND::CBufferDSound, and NLSOUND::CBufferAL. +

+Referenced by NLSOUND::ILoader::fillBuffer(), NLSOUND::ILoader::fillBufferPart(), and NLSOUND::CSoundDriverAL::loadWavFile().

+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
virtual bool NLSOUND::IBuffer::fillMore void *  src,
uint32  srcsize
[inline, virtual]
+
+ + + + + +
+   + + +

+Fill the buffer partially (if isFillMoreSupported() only), beginning at the pos changed by a previous call to fillMore(). If the pos+srcsize exceeds the buffer size, the exceeding data is put at the beginning of the buffer. srcsize must be smaller than the buffer size. +

+Reimplemented in NLSOUND::CBufferAL. +

+Definition at line 79 of file buffer.h. +

+References uint32. +

+Referenced by NLSOUND::ILoader::fillBufferPart(). +

+

00079 { throw ESoundDriverNotSupp(); }
+
+

+ + + + +
+ + + + + + + + + + +
virtual uint32 NLSOUND::IBuffer::getBufferADPCMEncoded std::vector< uint8 > &  result  )  [pure virtual]
+
+ + + + + +
+   + + +

+Unoptimized utility function designed to build ADPCM encoded sample bank file. Return the number of sample in the buffer. +

+Implemented in NLSOUND::CBufferDSound, and NLSOUND::CBufferAL.

+

+ + + + +
+ + + + + + + + + + +
virtual uint32 NLSOUND::IBuffer::getBufferMono16 std::vector< sint16 > &  result  )  [pure virtual]
+
+ + + + + +
+   + + +

+Unoptimized utility function designed to build Mono 16 bits encoded sample bank file. Return the number of sample in the buffer. +

+Implemented in NLSOUND::CBufferDSound, and NLSOUND::CBufferAL.

+

+ + + + +
+ + + + + + + + + +
virtual float NLSOUND::IBuffer::getDuration  )  const [pure virtual]
+
+ + + + + +
+   + + +

+Return the duration (in ms) of the sample in the buffer. +

+ +

+Implemented in NLSOUND::CBufferDSound, and NLSOUND::CBufferAL.

+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
virtual void NLSOUND::IBuffer::getFormat TSampleFormat format,
uint freq
const [pure virtual]
+
+ + + + + +
+   + + +

+Return the format and frequency. +

+ +

+Implemented in NLSOUND::CBufferDSound, and NLSOUND::CBufferAL. +

+Referenced by NLSOUND::CSourceDSound::getPitch(), NLSOUND::CSourceDSound::getTime(), NLSOUND::CSourceDSound::play(), and NLSOUND::CSourceDSound::setPitch().

+

+ + + + +
+ + + + + + + + + +
virtual const NLMISC::TStringId& NLSOUND::IBuffer::getName  )  [pure virtual]
+
+ + + + + +
+   + + +

+Return the name of this buffer. +

+ +

+Implemented in NLSOUND::CBufferDSound, and NLSOUND::CBufferAL. +

+Referenced by NLSOUND::CSimpleSound::setBuffer().

+

+ + + + +
+ + + + + + + + + +
virtual uint32 NLSOUND::IBuffer::getSize  )  const [pure virtual]
+
+ + + + + +
+   + + +

+Return the size of the buffer, in bytes. +

+ +

+Implemented in NLSOUND::CBufferDSound, and NLSOUND::CBufferAL. +

+Referenced by NLSOUND::ILoader::fillBufferPart(), NLSOUND::CSampleBank::load(), and NLSOUND::CSourceDSound::play().

+

+ + + + +
+ + + + + + + + + +
virtual bool NLSOUND::IBuffer::isBufferLoaded  )  [pure virtual]
+
+ + + + + +
+   + + +

+Return true if the buffer is loaded. Used for async load/unload. +

+ +

+Implemented in NLSOUND::CBufferDSound, and NLSOUND::CBufferAL. +

+Referenced by NLSOUND::CSimpleSource::play().

+

+ + + + +
+ + + + + + + + + +
virtual bool NLSOUND::IBuffer::isFillMoreSupported  )  const [pure virtual]
+
+ + + + + +
+   + + +

+Return true if the buffer is able to be fill part by part, false if it must be filled in one call OpenAL 1.0 -> false +

+Implemented in NLSOUND::CBufferDSound, and NLSOUND::CBufferAL. +

+Referenced by NLSOUND::ILoader::fillBufferPart().

+

+ + + + +
+ + + + + + + + + +
virtual bool NLSOUND::IBuffer::isStereo  )  const [pure virtual]
+
+ + + + + +
+   + + +

+Return true if the buffer is stereo, false if mono. +

+ +

+Implemented in NLSOUND::CBufferDSound, and NLSOUND::CBufferAL. +

+Referenced by NLSOUND::CAudioMixerUser::createSource(), NLSOUND::CSimpleSource::play(), and NLSOUND::CSimpleSource::setDirection().

+

+ + + + +
+ + + + + + + + + + +
virtual void NLSOUND::IBuffer::presetName const NLMISC::TStringId bufferName  )  [pure virtual]
+
+ + + + + +
+   + + +

+Preset the name of the buffer. Used for async loading to give a name before the buffer is effectivly loaded. If the name after loading of the buffer doesn't match the preset name, the load will assert. +

+Implemented in NLSOUND::CBufferDSound, and NLSOUND::CBufferAL. +

+Referenced by NLSOUND::CSampleBank::load().

+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
virtual void NLSOUND::IBuffer::setFormat TSampleFormat  format,
uint  freq
[pure virtual]
+
+ + + + + +
+   + + +

+Set the sample format. Example: freq=44100. +

+ +

+Implemented in NLSOUND::CBufferDSound, and NLSOUND::CBufferAL. +

+Referenced by NLSOUND::CSoundDriverAL::loadWavFile().

+

+ + + + +
+ + + + + + + + + + +
virtual void NLSOUND::IBuffer::setSize uint32  size  )  [inline, virtual]
+
+ + + + + +
+   + + +

+Force the buffer size without filling data (if isFillMoreSupported() only). +

+ +

+Reimplemented in NLSOUND::CBufferAL. +

+Definition at line 73 of file buffer.h. +

+References size, and uint32. +

+

00073 { throw ESoundDriverNotSupp(); }
+
+


Field Documentation

+

+ + + + +
+ + +
const sint NLSOUND::IBuffer::_IndexTable [static, private] +
+
+ + + + + +
+   + + +

+Initial value:

 
+{
+        -1, -1, -1, -1, 2, 4, 6, 8,
+        -1, -1, -1, -1, 2, 4, 6, 8,
+}
+
Unoptimized utility function designed to build ADPCM encoded sample bank file. Return the number of sample in the buffer. +

+Definition at line 31 of file buffer.cpp. +

+Referenced by decodeADPCM(), and encodeADPCM().

+

+ + + + +
+ + +
const uint NLSOUND::IBuffer::_StepsizeTable [static, private] +
+
+ + + + + +
+   + + +

+Initial value:

 
+{
+        7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
+        19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
+        50, 55, 60, 66, 73, 80, 88, 97, 107, 118,
+        130, 143, 157, 173, 190, 209, 230, 253, 279, 307,
+        337, 371, 408, 449, 494, 544, 598, 658, 724, 796,
+        876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066,
+        2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358,
+        5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899,
+        15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
+}
+
Unoptimized utility function designed to build ADPCM encoded sample bank file. Return the number of sample in the buffer. +

+Definition at line 37 of file buffer.cpp. +

+Referenced by decodeADPCM(), and encodeADPCM().

+


The documentation for this class was generated from the following files: +
Generated on Tue Mar 16 14:50:54 2004 for NeL by + +doxygen +1.3.6
+ + -- cgit v1.2.1