| ## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# csplugincommon/sndsys/convert.h File Reference

Some helper functions for sound elements. More...

Go to the source code of this file.

## Namespaces
namespace | CS
namespace | CS::SndSys
## Classes
class | CS::SndSys::PCMSampleConverter
| A PCMSampleConverter object converts PCM data from one format to another. More...
## Defines
#define | CS_SOUND_ELEMENT_MAX_CHANNELS 8
| This is the maximum number of channels we'll mix.
#define | CS_SOUND_INTERNAL_FREQUENCY_DIVISOR 1024
| This setting controls how many steps are used internally between source samples.

## Detailed Description

Some helper functions for sound elements.

Definition in file convert.h.

## Define Documentation

#define CS_SOUND_ELEMENT_MAX_CHANNELS 8

This is the maximum number of channels we'll mix.

Mono sound is 1 channel Stereo is 2 channels 5.1 sound is 6 channels

Definition at line 32 of file convert.h.

#define CS_SOUND_INTERNAL_FREQUENCY_DIVISOR 1024

This setting controls how many steps are used internally between source samples.

Time is steped along based on the ratio of the input frequency to the output frequency. If the output frequency is twice as fast as the input frequency, then two times as many sample points are needed in the output as in the input. In order to generate samples that sound appropriate when the time is between two actual source samples, the amplitude of the sound wave at the given time is approximated by interpolating between two adjacent source samples. The position in the source data is internally represented by a signed integer which can be thought of as the sample number multiplied by this divisor value. The first sample is at CS_SOUND_INTERNAL_FREQUENCY_DIVISOR, the second is at 2*CS_SOUND_INTERNAL_FREQUENCY_DIVISOR. A position mid way between the two is at 1.5 * CS_SOUND_INTERNAL_FREQUENCY_DIVISOR.

In order to keep things quick, use a power of 2 here (power of 2 division and multiplication will be optimized into a bit shift). This value is multiplied with frequency values and stored in a signed integer. Beware of making it too big!

Definition at line 56 of file convert.h.