Sound Byte Libs 0.5.1-340-gab5b79a
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
transport.hpp File Reference

The processing call's shape as a checked contract. More...

Detailed Description

The processing call's shape as a checked contract.

A component declares its ports, in the order its processing call takes them, and takes them as a parameter pack after the frame count:

static constexpr transport::Port PORTS[] = {{"pitch"}, {"wave", transport::Spelling::Scalar}};

template<class... Ports>
void process(float* out, uint16_t frames, Ports... ports);                     // a source
template<class... Ports>
void process(const float* in, float* out, uint16_t frames, Ports... ports);    // a processor

Each position is one declared port. An argument is a block, const float* with one value per frame, or a scalar, any arithmetic type; a port's Spelling says which it accepts. Trailing ports may be left off, and arg() gives Omitted for them; the component documents what a port left off does. A component with no ports declares none and takes none.

fits_v checks a call's port arguments against the declaration: no more arguments than ports, and each one a spelling its port accepts. A component static_asserts it at the top of process(), with its own message. is_source_v and is_processor_v tell the two kinds apart by the call they accept. PARAMETERS, also optional, declares the setters and their units for tools such as sbl-render.

Everything here is resolved at compile time; nothing is stored.

Definition in file transport.hpp.

#include <cstddef>
#include <cstdint>
#include <iterator>
#include <tuple>
#include <type_traits>
#include <utility>

Go to the source code of this file.

Classes

struct  sbl::transport::Port
 
struct  sbl::transport::Parameter< T >
 
struct  sbl::transport::Omitted
 
struct  sbl::transport::port_count< T, class >
 
struct  sbl::transport::port_count< T, std::void_t< decltype(T::PORTS)> >
 
struct  sbl::transport::parameter_count< T, class >
 
struct  sbl::transport::parameter_count< T, std::void_t< decltype(T::PARAMETERS)> >
 
struct  sbl::transport::is_source< T, class >
 
struct  sbl::transport::is_source< T, std::void_t< decltype(std::declval< T & >().process(std::declval< float * >(), std::declval< uint16_t >()))> >
 
struct  sbl::transport::is_processor< T, class >
 
struct  sbl::transport::is_processor< T, std::void_t< decltype(std::declval< T & >().process(std::declval< const float * >(), std::declval< float * >(), std::declval< uint16_t >()))> >
 

Namespaces

namespace  sbl
 Root namespace for all Sound Byte Libs code.
 
namespace  sbl::transport
 The signal transport trait: a component's declared ports and the check of a processing call against them.
 

Enumerations

enum class  sbl::transport::Spelling : uint8_t { sbl::transport::Either , sbl::transport::Scalar , sbl::transport::Block }
 
enum class  sbl::transport::Unit : uint8_t { sbl::transport::Number , sbl::transport::CyclesPerFrame }
 

Functions

template<std::size_t I, class... A>
constexpr auto sbl::transport::arg (A... args)
 

Variables

template<class A >
constexpr bool sbl::transport::is_block_v
 
template<class A >
constexpr bool sbl::transport::is_scalar_v = std::is_arithmetic_v<std::decay_t<A>>
 
template<class A >
constexpr bool sbl::transport::is_omitted_v = std::is_same_v<std::decay_t<A>, Omitted>
 
template<class T >
constexpr std::size_t sbl::transport::port_count_v = port_count<T>::value
 
template<class T >
constexpr std::size_t sbl::transport::parameter_count_v = parameter_count<T>::value
 
template<class T , class... A>
constexpr bool sbl::transport::fits_v = detail::fits<T, A...>(std::index_sequence_for<A...>{})
 
template<class T >
constexpr bool sbl::transport::is_source_v = is_source<T>::value
 
template<class T >
constexpr bool sbl::transport::is_processor_v = is_processor<T>::value