libpsynth 0.2.1
Classes
scoped_sample_value

A sample adaptor that modifies the range of the source sample. More...

Classes

struct  psynth::sound::scoped_sample_value< BaseSampleValue, MinVal, MaxVal, ZeroVal >
 A sample adaptor that modifies the range of the source sample. More...

Detailed Description

A sample adaptor that modifies the range of the source sample.

Models: SampleValueConcept

Example:

// Create a double sample with range [-0.5 .. 0.5]
struct double_minus_half  { static double apply() { return -0.5; } };
struct double_plus_half   { static double apply() { return  0.5; } };
typedef scoped_sample_value<double, double_minus_half, double_plus_half> bits64custom_t;

// sample_convert its maximum should map to the maximum
bits64custom_t x = sample_traits<bits64custom_t>::max_value();
assert(x == 0.5);
bits16 y = sample_convert<bits16>(x);
assert(y == 65535);