1 #ifndef _AUDIOBUFFERCONTAINER_
2 #define _AUDIOBUFFERCONTAINER_
11 #define CHANNELPINMAPPER_MAXPINS 64
13 class ChannelPinMapper
17 ChannelPinMapper() : m_nCh(0), m_nPins(0) {}
18 ~ChannelPinMapper() {}
20 void SetNPins(int nPins
);
21 void SetNChannels(int nCh
);
23 void Init(const WDL_UINT64
* pMapping
, int nPins
);
25 int GetNPins() const { return m_nPins
; }
26 int GetNChannels() const { return m_nCh
; }
28 void ClearPin(int pinIdx
);
29 void SetPin(int pinIdx
, int chIdx
, bool on
);
30 bool TogglePin(int pinIdx
, int chIdx
);
32 // true if this pin is mapped to this channel
33 bool GetPin(int pinIdx
, int chIdx
) const;
34 // true if this pin is to any higher channel
35 bool PinHasMoreMappings(int pinIdx
, int chIdx
) const;
36 // true if this mapper is a straight 1:1 passthrough
37 bool IsStraightPassthrough() const;
39 char* SaveStateNew(int* pLen
); // owned
40 bool LoadState(const char* buf
, int len
);
42 WDL_UINT64 m_mapping
[CHANNELPINMAPPER_MAXPINS
];
50 // converts interleaved buffer to interleaved buffer, using min(len_in,len_out) and zeroing any extra samples
51 // isInput means it reads from track channels and writes to plugin pins
52 // wantZeroExcessOutput=false means that untouched channels will be preserved in buf_out
53 void PinMapperConvertBuffers(const double *buf
, int len_in
, int nch_in
,
54 double *buf_out
, int len_out
, int nch_out
,
55 const ChannelPinMapper
*pinmap
, bool isInput
, bool wantZeroExcessOutput
);
57 // use for float and double only ... ints will break it
58 class AudioBufferContainer
62 AudioBufferContainer();
63 ~AudioBufferContainer() {}
71 static bool BufConvert(void* dest
, const void* src
, int destFmt
, int srcFmt
, int nFrames
, int destStride
, int srcStride
);
73 int GetNChannels() const { return m_nCh
; }
74 int GetNFrames() const { return m_nFrames
; }
75 int GetFormat() const { return m_fmt
; }
77 void Resize(int nCh
, int nFrames
, bool preserveData
);
78 // call Reformat(GetFormat(), false) to discard current data (for efficient repopulating)
79 void Reformat(int fmt
, bool preserveData
);
81 // src=NULL to memset(0)
82 void* SetAllChannels(int fmt
, const void* src
, int nCh
, int nFrames
);
84 // src=NULL to memset(0)
85 void* SetChannel(int fmt
, const void* src
, int chIdx
, int nFrames
);
87 void* MixChannel(int fmt
, const void* src
, int chIdx
, int nFrames
, bool addToDest
, double wt_start
, double wt_end
);
89 void* GetAllChannels(int fmt
, bool preserveData
);
90 void* GetChannel(int fmt
, int chIdx
, bool preserveData
);
92 void CopyFrom(const AudioBufferContainer
* rhs
);
96 void ReLeave(bool interleave
, bool preserveData
);
108 void SetPinsFromChannels(AudioBufferContainer
* dest
, AudioBufferContainer
* src
, const ChannelPinMapper
* mapper
, int forceMinChanCnt
=0);
109 void SetChannelsFromPins(AudioBufferContainer
* dest
, AudioBufferContainer
* src
, const ChannelPinMapper
* mapper
, double wt_start
=1.0, double wt_end
=1.0);