libpsynth 0.2.1
Classes | Functions
ChannelBaseAlgorithmSemanticAtC

kth_semantic_element_type, kth_semantic_element_reference_type, kth_semantic_element_const_reference_type, semantic_at_c More...

Classes

struct  psynth::sound::kth_semantic_element_type< ChannelBase, K >
 Specifies the type of the K-th semantic element of a channel base. More...
struct  psynth::sound::kth_semantic_element_reference_type< ChannelBase, K >
 Specifies the return type of the mutable semantic_at_c<K>(channel_base);. More...
struct  psynth::sound::kth_semantic_element_const_reference_type< ChannelBase, K >
 Specifies the return type of the constant semantic_at_c<K>(channel_base);. More...

Functions

template<int K, typename ChannelBase >
boost::disable_if
< boost::is_const< ChannelBase >
, typename
kth_semantic_element_reference_type
< ChannelBase, K >::type >
::type 
psynth::sound::semantic_at_c (ChannelBase &p)
 A mutable accessor to the K-th semantic element of a channel base.
template<int K, typename ChannelBase >
kth_semantic_element_const_reference_type
< ChannelBase, K >::type 
psynth::sound::semantic_at_c (const ChannelBase &p)
 A constant accessor to the K-th semantic element of a channel base.

Detailed Description

kth_semantic_element_type, kth_semantic_element_reference_type, kth_semantic_element_const_reference_type, semantic_at_c

Support for accessing the elements of a channel base by semantic index

The semantic index of an element is the index of its channel in the channel space. Semantic indexing allows for proper pairing of elements of channel bases independent on their layout. For example, red is the first semantic element of a channel base regardless of whether it has an RGB layout or a BGR layout. All GIL channel base algorithms taking multiple channel bases use semantic indexing to access their elements.

Example:

    // 16-bit BGR frame, 4 bits for the blue, 3 bits for the green, 2
    // bits for the red sample and 7 unused bits

    typedef packed_frame_type<uint16_t,
    boost::mpl::vector3_c<unsigned,4,3,2>, bgr_layout>::type
    bgr432_frame_t;
    

    // A reference to its red sample. Although the red sample is the
    // third, its semantic index is 0 in the RGB channel space
    typedef kth_semantic_element_reference_type<bgr432_frame_t,
    0>::type red_sample_reference_t;

    // Initialize the frame to black
    bgr432_frame_t red_frame(0,0,0);

    // Set the red sample to 100%
    red_sample_reference_t red_sample = semantic_at_c<0>(red_frame);
    red_sample = sample_traits<red_sample_reference_t>::max_value();       

Function Documentation

template<int K, typename ChannelBase >
boost::disable_if< boost::is_const< ChannelBase >, typename kth_semantic_element_reference_type< ChannelBase, K >::type >::type psynth::sound::semantic_at_c ( ChannelBase &  p) [inline]

A mutable accessor to the K-th semantic element of a channel base.

template<int K, typename ChannelBase >
kth_semantic_element_const_reference_type< ChannelBase, K >::type psynth::sound::semantic_at_c ( const ChannelBase &  p) [inline]

A constant accessor to the K-th semantic element of a channel base.