[IPLUG/AAX] remove IPlugAAX::SetParameterFromGUI()
[wdl/wdl-ol.git] / WDL / audiobuffercontainer.h
blob6b4963b92cd7d45960755502b3cb4c9dd92dadb3
1 #ifndef _AUDIOBUFFERCONTAINER_
2 #define _AUDIOBUFFERCONTAINER_
4 #include "wdltypes.h"
5 #include <string.h>
6 #include <stdlib.h>
7 #include "ptrlist.h"
8 #include "queue.h"
11 #define CHANNELPINMAPPER_MAXPINS 64
13 class ChannelPinMapper
15 public:
17 ChannelPinMapper() : m_nCh(0), m_nPins(0) {}
18 ~ChannelPinMapper() {}
20 void SetNPins(int nPins);
21 void SetNChannels(int nCh);
22 // or ...
23 void Init(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];
44 private:
46 WDL_Queue m_cfgret;
47 int m_nCh, m_nPins;
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
60 public:
62 AudioBufferContainer();
63 ~AudioBufferContainer() {}
65 enum
67 FMT_32FP=4,
68 FMT_64FP=8
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);
94 private:
96 void ReLeave(bool interleave, bool preserveData);
98 WDL_HeapBuf m_data;
99 int m_nCh;
100 int m_nFrames;
102 int m_fmt;
103 bool m_interleaved;
104 bool m_hasData;
105 } WDL_FIXALIGN;
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);
112 #endif