HephAudio v3.1.0
A cross-platform C++ library for recording, playing, and processing audio on Windows, Android, Linux, iOS, and macOS.
Loading...
Searching...
No Matches
HephAudio::ChannelMapper Class Reference

remaps the audio channels. More...

#include <ChannelMapper.h>

Inheritance diagram for HephAudio::ChannelMapper:
HephAudio::DoubleBufferedAudioEffect HephAudio::AudioEffect

Classes

struct  AudioChannelLayoutHasher
 

Public Member Functions

 ChannelMapper ()
 
 ChannelMapper (const AudioChannelLayout &targetLayout)
 
virtual ~ChannelMapper ()=default
 
virtual std::string Name () const override
 
virtual const AudioChannelLayoutGetTargetLayout () const
 
virtual void SetTargetLayout (const AudioChannelLayout &targetLayout)
 
- Public Member Functions inherited from HephAudio::DoubleBufferedAudioEffect
virtual ~DoubleBufferedAudioEffect ()=default
 
virtual void Process (AudioBuffer &buffer, size_t startIndex, size_t frameCount) override
 
virtual void Process (AudioBuffer &buffer)
 
virtual void Process (AudioBuffer &buffer, size_t startIndex)
 
- Public Member Functions inherited from HephAudio::AudioEffect
virtual ~AudioEffect ()=default
 
virtual bool HasMTSupport () const
 
virtual bool HasRTSupport () const
 
virtual size_t GetThreadCount () const
 
virtual void SetThreadCount (size_t threadCount)
 
virtual size_t CalculateRequiredFrameCount (size_t outputFrameCount, const AudioFormatInfo &formatInfo) const
 
virtual size_t CalculateOutputFrameCount (size_t inputFrameCount, const AudioFormatInfo &formatInfo) const
 
virtual size_t CalculateAdvanceSize (size_t renderFrameCount, const AudioFormatInfo &formatInfo) const
 
virtual void ResetInternalState ()
 

Static Public Member Functions

static void SetMapping (const AudioChannelLayout &targetLayout, const AudioChannelLayout &inputLayout, const std::function< void(heph_audio_sample_t *, heph_audio_sample_t *)> &f)
 

Protected Types

typedef std::unordered_map< AudioChannelLayout, std::unordered_map< AudioChannelLayout, std::function< void(heph_audio_sample_t *, heph_audio_sample_t *)>, AudioChannelLayoutHasher >, AudioChannelLayoutHasherChannelMapperMap
 

Protected Member Functions

virtual void ProcessST (const AudioBuffer &inputBuffer, AudioBuffer &outputBuffer, size_t startIndex, size_t frameCount) override
 
virtual AudioBuffer CreateOutputBuffer (const AudioBuffer &inputBuffer, size_t startIndex, size_t frameCount) const override
 
virtual void InitializeOutputBuffer (const AudioBuffer &inputBuffer, AudioBuffer &outputBuffer, size_t startIndex, size_t frameCount) const override
 
- Protected Member Functions inherited from HephAudio::DoubleBufferedAudioEffect
 DoubleBufferedAudioEffect ()
 
- Protected Member Functions inherited from HephAudio::AudioEffect
 AudioEffect ()
 
virtual void ProcessMT (const AudioBuffer &inputBuffer, AudioBuffer &outputBuffer, size_t startIndex, size_t frameCount)
 

Static Protected Member Functions

static ChannelMapperMap CreateMap ()
 

Protected Attributes

AudioChannelLayout targetLayout
 
- Protected Attributes inherited from HephAudio::AudioEffect
size_t threadCount
 

Static Protected Attributes

static ChannelMapperMap map
 

Detailed Description

remaps the audio channels.

Member Typedef Documentation

◆ ChannelMapperMap

layout-(layout-function) map.

Example
from mono to stereo would look like stereo-(mono-function) where function would do the conversion.

Constructor & Destructor Documentation

◆ ChannelMapper() [1/2]

HephAudio::ChannelMapper::ChannelMapper ( )

creates a new instance and initializes it with default values.

◆ ChannelMapper() [2/2]

HephAudio::ChannelMapper::ChannelMapper ( const AudioChannelLayout & targetLayout)
explicit

creates a new instance and initializes it with the provided values.

Parameters
targetLayoutchannel layout the input buffer will be remapped to.

◆ ~ChannelMapper()

virtual HephAudio::ChannelMapper::~ChannelMapper ( )
virtualdefault

releases the resources and destroys the instance.

Member Function Documentation

◆ Name()

virtual std::string HephAudio::ChannelMapper::Name ( ) const
overridevirtual

gets the name of the audio effect.

Implements HephAudio::AudioEffect.

◆ GetTargetLayout()

virtual const AudioChannelLayout & HephAudio::ChannelMapper::GetTargetLayout ( ) const
virtual

gets the target channel layout.

◆ SetTargetLayout()

virtual void HephAudio::ChannelMapper::SetTargetLayout ( const AudioChannelLayout & targetLayout)
virtual

sets the target channel layout.

Parameters
targetLayoutchannel layout the input buffer will be remapped to.

◆ ProcessST()

virtual void HephAudio::ChannelMapper::ProcessST ( const AudioBuffer & inputBuffer,
AudioBuffer & outputBuffer,
size_t startIndex,
size_t frameCount )
overrideprotectedvirtual

applies the effect using single thread.

Parameters
inputBuffercontains the audio data which will be processed.
outputBuffercontains the processed audio data.
startIndexindex of the first sample to process.
frameCountnumber of frames to process.

Implements HephAudio::AudioEffect.

◆ CreateOutputBuffer()

virtual AudioBuffer HephAudio::ChannelMapper::CreateOutputBuffer ( const AudioBuffer & inputBuffer,
size_t startIndex,
size_t frameCount ) const
overrideprotectedvirtual

creates the output buffer but does not initialize it.

Parameters
inputBuffercontains the audio data which will be processed.
startIndexindex of the first sample to process.
frameCountnumber of frames to process.

Reimplemented from HephAudio::DoubleBufferedAudioEffect.

◆ InitializeOutputBuffer()

virtual void HephAudio::ChannelMapper::InitializeOutputBuffer ( const AudioBuffer & inputBuffer,
AudioBuffer & outputBuffer,
size_t startIndex,
size_t frameCount ) const
overrideprotectedvirtual

initializes the output buffer.

Parameters
inputBuffercontains the audio data which will be processed.
outputBuffercontains the processed audio data.
startIndexindex of the first sample to process.
frameCountnumber of frames to process.

Reimplemented from HephAudio::DoubleBufferedAudioEffect.

◆ SetMapping()

static void HephAudio::ChannelMapper::SetMapping ( const AudioChannelLayout & targetLayout,
const AudioChannelLayout & inputLayout,
const std::function< void(heph_audio_sample_t *, heph_audio_sample_t *)> & f )
static

sets mapping from targetLayout to inputLayout.

Parameters
targetLayouttarget (output) channel layout.
inputLayoutinput channel layout.
ffunction that maps the channels.

◆ CreateMap()

static ChannelMapperMap HephAudio::ChannelMapper::CreateMap ( )
staticprotected

creates the ChannelMapper::map.

Member Data Documentation

◆ map

ChannelMapperMap HephAudio::ChannelMapper::map
staticprotected

contains the functions to map the channel layouts.

◆ targetLayout

AudioChannelLayout HephAudio::ChannelMapper::targetLayout
protected

channel layout the input buffer will be remapped to.