iPlug2 - C++ Audio Plug-in Framework
Loading...
Searching...
No Matches
ISender.h
Go to the documentation of this file.
1/*
2 ==============================================================================
3
4 This file is part of the iPlug 2 library. Copyright (C) the iPlug 2 developers.
5
6 See LICENSE.txt for more info.
7
8 ==============================================================================
9*/
10
11#pragma once
12
19#include "denormal.h"
20#include "fft.h"
21
22#include "IPlugPlatform.h"
23#include "IPlugQueue.h"
24#include <array>
25
26#if defined OS_IOS || defined OS_MAC
27#include <Accelerate/Accelerate.h>
28#endif
29
30BEGIN_IPLUG_NAMESPACE
31
33template <int MAXNC = 1, typename T = float>
35{
36 int ctrlTag = kNoTag;
37 int nChans = MAXNC;
38 int chanOffset = 0;
39 std::array<T, MAXNC> vals;
40
42 : vals{}
43 {
44 }
45
46 ISenderData(int ctrlTag, int nChans, int chanOffset)
47 : ctrlTag(ctrlTag)
48 , nChans(nChans)
49 , chanOffset(chanOffset)
50 , vals{}
51 {
52 }
53
54 ISenderData(int ctrlTag, const std::array<T, MAXNC>& vals, int nChans = MAXNC, int chanOffset = 0)
55 : ctrlTag(ctrlTag)
56 , nChans(nChans)
57 , chanOffset(chanOffset)
58 , vals(vals)
59 {
60 }
61};
62
64template <int MAXNC = 1, int QUEUE_SIZE = 64, typename T = float>
66{
67public:
68 static constexpr int kUpdateMessage = 0;
69
72 {
73 mQueue.Push(d);
74 }
75
77 virtual void PrepareDataForUI(ISenderData<MAXNC, T>& d) { /* NO-OP*/ }
78
82 {
83 while (mQueue.ElementsAvailable())
84 {
86 mQueue.Pop(d);
87 assert(d.ctrlTag != kNoTag && "You must supply a control tag");
89 dlg.SendControlMsgFromDelegate(d.ctrlTag, kUpdateMessage, sizeof(ISenderData<MAXNC, T>), (void*) &d);
90 mLastData = d;
91 }
92 }
93
97 void TransmitDataToControlsWithTags(IEditorDelegate& dlg, const std::initializer_list<int>& ctrlTags)
98 {
99 while(mQueue.ElementsAvailable())
100 {
102 mQueue.Pop(d);
103
104 for (auto tag : ctrlTags)
105 {
106 d.ctrlTag = tag;
107 dlg.SendControlMsgFromDelegate(tag, kUpdateMessage, sizeof(ISenderData<MAXNC, T>), (void*) &d);
108 }
109 }
110 }
111
113 ISenderData<MAXNC, T> GetLastData() { return mLastData; }
114
115protected:
116 IPlugQueue<ISenderData<MAXNC, T>> mQueue {QUEUE_SIZE};
117 ISenderData<MAXNC, T> mLastData;
118};
119
123template <int MAXNC = 1, int QUEUE_SIZE = 64>
124class IPeakSender : public ISender<MAXNC, QUEUE_SIZE, float>
125{
126public:
127 IPeakSender(double minThresholdDb = -90., float windowSizeMs = 5.0f)
129 , mThreshold(static_cast<float>(DBToAmp(minThresholdDb)))
130 , mWindowSizeMs(windowSizeMs)
131 {
132 Reset(DEFAULT_SAMPLE_RATE);
133 }
134
135 void Reset(double sampleRate)
136 {
137 SetWindowSizeMs(mWindowSizeMs, sampleRate);
138 std::fill(mPeaks.begin(), mPeaks.end(), 0.0f);
139 }
140
141 void SetWindowSizeMs(double timeMs, double sampleRate)
142 {
143 mWindowSizeMs = static_cast<float>(timeMs);
144 mWindowSize = static_cast<int>(timeMs * 0.001 * sampleRate);
145 }
146
153 void ProcessBlock(sample** inputs, int nFrames, int ctrlTag = kNoTag, int nChans = MAXNC, int chanOffset = 0)
154 {
155 for (auto s = 0; s < nFrames; s++)
156 {
157 if (mCount == 0)
158 {
159 ISenderData<MAXNC, float> d {ctrlTag, nChans, chanOffset};
160
161 float sum = 0.0f;
162
163 for (auto c = chanOffset; c < (chanOffset + nChans); c++)
164 {
165 d.vals[c] = mPeaks[c] / mWindowSize;
166 mPeaks[c] = 0.0f;
167 sum += d.vals[c];
168 }
169
170 if (sum > mThreshold || mPreviousSum > mThreshold)
172
173 mPreviousSum = sum;
174 }
175
176 for (auto c = chanOffset; c < (chanOffset + nChans); c++)
177 {
178 mPeaks[c] += std::fabs(static_cast<float>(inputs[c][s]));
179 }
180
181 mCount++;
182 mCount %= mWindowSize;
183 }
184 }
185private:
186 float mPreviousSum = 1.f;
187 float mThreshold = 0.01f;
188 float mWindowSizeMs = 5.0f;
189 int mWindowSize = 32;
190 int mCount = 0;
191 std::array<float, MAXNC> mPeaks = {0.0};
192};
193
197template <int MAXNC = 1, int QUEUE_SIZE = 64>
198class IPeakAvgSender : public ISender<MAXNC, QUEUE_SIZE, std::pair<float, float>>
199{
200public:
202 {
203 public:
204 inline float Process(float& input, float& attackTimeSamples, float& decayTimeSamples)
205 {
206 if (input > mPreviousOutput)
207 {
208 if (attackTimeSamples > 1.0f)
209 {
210 mPreviousOutput += (input - mPreviousOutput) / attackTimeSamples;
211 }
212 else
213 {
214 mPreviousOutput = input;
215 }
216 }
217 else if (input < mPreviousOutput)
218 {
219 if (decayTimeSamples > 1.0f)
220 {
221 mPreviousOutput += (input - mPreviousOutput) / decayTimeSamples;
222 }
223 else
224 {
225 mPreviousOutput = input;
226 }
227 }
228
229 denormal_fix(&mPreviousOutput);
230 return mPreviousOutput;
231 }
232
233 private:
234 float mPreviousOutput = 0.0f;
235 };
236
237 IPeakAvgSender(double minThresholdDb = -90.0, bool rmsMode = true, float windowSizeMs = 5.0f, float attackTimeMs = 1.0f, float decayTimeMs = 100.0f, float peakHoldTimeMs = 500.0f)
238 : ISender<MAXNC, QUEUE_SIZE, std::pair<float, float>>()
239 , mThreshold(static_cast<float>(DBToAmp(minThresholdDb)))
240 , mRMSMode(rmsMode)
241 , mWindowSizeMs(windowSizeMs)
242 , mAttackTimeMs(attackTimeMs)
243 , mDecayTimeMs(decayTimeMs)
244 , mPeakHoldTimeMs(peakHoldTimeMs)
245 {
246 Reset(DEFAULT_SAMPLE_RATE);
247 }
248
249 void Reset(double sampleRate)
250 {
251 SetWindowSizeMs(mWindowSizeMs, sampleRate);
252 SetAttackTimeMs(mAttackTimeMs, sampleRate);
253 SetDecayTimeMs(mDecayTimeMs, sampleRate);
254 SetPeakHoldTimeMs(mPeakHoldTimeMs, sampleRate);
255 std::fill(mHeldPeaks.begin(), mHeldPeaks.end(), 0.0f);
256 }
257
258 void SetAttackTimeMs(double timeMs, double sampleRate)
259 {
260 mAttackTimeMs = static_cast<float>(timeMs);
261 mAttackTimeSamples = static_cast<float>(timeMs * 0.001 * (sampleRate / double(mWindowSize)));
262 }
263
264 void SetDecayTimeMs(double timeMs, double sampleRate)
265 {
266 mDecayTimeMs = static_cast<float>(timeMs);
267 mDecayTimeSamples = static_cast<float>(timeMs * 0.001 * (sampleRate / mWindowSize));
268 }
269
270 void SetWindowSizeMs(double timeMs, double sampleRate)
271 {
272 mWindowSizeMs = static_cast<float>(timeMs);
273 mWindowSize = static_cast<int>(timeMs * 0.001 * sampleRate);
274 mCount = 0;
275
276 for (auto i=0; i<MAXNC; i++)
277 {
278 mBuffers[i].resize(mWindowSize);
279 std::fill(mBuffers[i].begin(), mBuffers[i].end(), 0.0f);
280 }
281 }
282
283 void SetPeakHoldTimeMs(double timeMs, double sampleRate)
284 {
285 mPeakHoldTimeMs = static_cast<float>(timeMs);
286 mPeakHoldTime = static_cast<int>(timeMs * 0.001 * sampleRate);
287 std::fill(mPeakHoldCounters.begin(), mPeakHoldCounters.end(), mPeakHoldTime);
288 }
289
296 void ProcessBlock(sample** inputs, int nFrames, int ctrlTag = kNoTag, int nChans = MAXNC, int chanOffset = 0)
297 {
298 for (auto s = 0; s < nFrames; s++)
299 {
300 for (auto c = chanOffset; c < (chanOffset + nChans); c++)
301 {
302 mBuffers[c][mCount] = static_cast<float>(inputs[c][s]);
303 }
304
305 if (mCount == 0)
306 {
307 ISenderData<MAXNC, std::pair<float, float>> d {ctrlTag, nChans, chanOffset};
308
309 auto avgSum = 0.0f;
310 bool peakHeld = false;
311
312 for (auto c = chanOffset; c < (chanOffset + nChans); c++)
313 {
314 auto peakVal = 0.0f;
315 auto avgVal = 0.0f;
316#if defined OS_IOS || defined OS_MAC
317 vDSP_vabs(mBuffers[c].data(), 1, mBuffers[c].data(), 1, mWindowSize);
318 vDSP_maxv(mBuffers[c].data(), 1, &peakVal, mWindowSize);
319
320 if (mRMSMode)
321 {
322 vDSP_rmsqv(mBuffers[c].data(), 1, &avgVal, mWindowSize);
323 }
324 else
325 {
326 vDSP_meanv(mBuffers[c].data(), 1, &avgVal, mWindowSize);
327 }
328#else
329 for (auto i=0; i<mWindowSize; i++)
330 {
331 auto absVal = std::fabs(mBuffers[c][i]);
332
333 if (absVal > peakVal)
334 {
335 peakVal = absVal;
336 }
337
338 if (mRMSMode)
339 {
340 absVal = absVal * absVal;
341 }
342
343 avgVal += absVal;
344 }
345
346 avgVal /= static_cast<float>(mWindowSize);
347
348 if (mRMSMode)
349 {
350 avgVal = std::sqrt(avgVal);
351 }
352#endif
353
354 // set peak-hold value
355 if (mPeakHoldCounters[c] <= 0)
356 {
357 mHeldPeaks[c] = 0.0f;
358 }
359
360 if (mHeldPeaks[c] < peakVal)
361 {
362 mHeldPeaks[c] = peakVal;
363 mPeakHoldCounters[c] = mPeakHoldTime;
364 }
365 else
366 {
367 if (mPeakHoldCounters[c] > 0)
368 {
369 mPeakHoldCounters[c] -= mWindowSize;
370 }
371 }
372
373 std::get<0>(d.vals[c]) = mHeldPeaks[c];
374 peakHeld |= mHeldPeaks[c] > 0.0f;
375
376 // set avg value
377 auto smoothedAvg = mEnvFollowers[c].Process(avgVal, mAttackTimeSamples, mDecayTimeSamples);
378 std::get<1>(d.vals[c]) = smoothedAvg;
379
380 avgSum += smoothedAvg;
381 }
382
383 if (mPreviousSum > mThreshold)
384 {
386 }
387 else
388 {
389 // This makes sure that the data is still pushed if
390 // peakholds are still active: the held peaks are sent, with
391 // the average cleared, and once the holds have run out one
392 // more push clears the peaks
393 for (auto c = chanOffset; c < (chanOffset + nChans); c++)
394 {
395 std::get<1>(d.vals[c]) = 0.0f;
396 }
397
398 if (peakHeld || mPeakWasHeld)
399 {
401 }
402 }
403
404 mPreviousSum = avgSum;
405 mPeakWasHeld = peakHeld;
406 }
407
408 mCount++;
409 mCount %= mWindowSize;
410 }
411 }
412private:
413 float mThreshold = 0.01f;
414 bool mRMSMode = false;
415 float mPreviousSum = 1.0f;
416 bool mPeakWasHeld = false;
417 int mWindowSize = 32;
418 int mPeakHoldTime = 1 << 16;
419 int mCount = 0;
420 float mWindowSizeMs = 5.f;
421 float mAttackTimeMs = 1.f;
422 float mDecayTimeMs = 100.f;
423 float mPeakHoldTimeMs = 100.f;
424 float mAttackTimeSamples = 1.0f;
425 float mDecayTimeSamples = DEFAULT_SAMPLE_RATE/10.0f;
426 std::array<float, MAXNC> mHeldPeaks = {0};
427 std::array<std::vector<float>, MAXNC> mBuffers;
428 std::array<int, MAXNC> mPeakHoldCounters;
429 std::array<EnvelopeFollower, MAXNC> mEnvFollowers;
430};
431
433template <int MAXNC = 1, int QUEUE_SIZE = 64, int MAXBUF = 128>
434class IBufferSender : public ISender<MAXNC, QUEUE_SIZE, std::array<float, MAXBUF>>
435{
436public:
437 using TDataPacket = std::array<float, MAXBUF>;
439 const double kNoThresholdDb = -100;
440
441 IBufferSender(double minThresholdDb = -90., int bufferSize = MAXBUF)
442 : TSender()
443 {
444 if (minThresholdDb <= kNoThresholdDb)
445 mThreshold = -1.0f;
446 else
447 mThreshold = DBToAmp(minThresholdDb);
448
449 SetBufferSize(bufferSize);
450 }
451
458 void ProcessBlock(sample** inputs, int nFrames, int ctrlTag = kNoTag, int nChans = MAXNC, int chanOffset = 0)
459 {
460 for (auto s = 0; s < nFrames; s++)
461 {
462 if (mBufCount == mBufferSize)
463 {
464 float sum = 0.0f;
465 for (auto c = chanOffset; c < (chanOffset + nChans); c++)
466 {
467 sum += mRunningSum[c];
468 mRunningSum[c] = 0.0f;
469 }
470
471 if (sum > mThreshold || mPreviousSum > mThreshold)
472 {
473 mBuffer.ctrlTag = ctrlTag;
474 mBuffer.nChans = nChans;
475 mBuffer.chanOffset = chanOffset;
476 TSender::PushData(mBuffer);
477 }
478
479 mPreviousSum = sum;
480 mBufCount = 0;
481 }
482
483 for (auto c = chanOffset; c < (chanOffset + nChans); c++)
484 {
485 const float inputSample = static_cast<float>(inputs[c][s]);
486 mBuffer.vals[c][mBufCount] = inputSample;
487 mRunningSum[c] += std::fabs(inputSample);
488 }
489
490 mBufCount++;
491 }
492 }
493
494 void SetBufferSize(int bufferSize)
495 {
496 assert(bufferSize > 0);
497 assert(bufferSize <= MAXBUF);
498
499 mBufferSize = bufferSize;
500 mBufCount = 0;
501 }
502
503 int GetBufferSize() const { return mBufferSize; }
504
505private:
507 int mBufCount = 0;
508 int mBufferSize = MAXBUF;
509 std::array<float, MAXNC> mRunningSum {0.};
510 float mPreviousSum = 1.f;
511 float mThreshold = 0.01f;
512};
513
515template <int MAXNC = 1, int QUEUE_SIZE = 64, int MAX_FFT_SIZE = 4096>
516class ISpectrumSender : public IBufferSender<MAXNC, QUEUE_SIZE, MAX_FFT_SIZE>
517{
518public:
519 using TDataPacket = std::array<float, MAX_FFT_SIZE>;
521
522 enum class EWindowType {
523 Hann = 0,
524 BlackmanHarris,
525 Hamming,
526 Flattop,
527 Rectangular
528 };
529
530 enum class EOutputType {
531 Complex = 0,
532 MagPhase,
533 };
534
535 ISpectrumSender(int fftSize = 1024, int overlap = 1, EWindowType window = EWindowType::Hann, EOutputType outputType = EOutputType::MagPhase, double minThresholdDb = -100.0)
536 : TBufferSender(minThresholdDb, fftSize / overlap)
537 , mWindowType(window)
538 , mOutputType(outputType)
539 {
540 WDL_fft_init();
541 SetFFTSizeAndOverlap(fftSize, overlap);
542 }
543
544 void SetFFTSize(int fftSize)
545 {
546 SetFFTSizeAndOverlap(fftSize, mOverlap);
547 }
548
549 void SetFFTSizeAndOverlap(int fftSize, int overlap)
550 {
551 mFFTSize = fftSize;
552 mOverlap = overlap;
553 int hopSize = fftSize / overlap;
554 TBufferSender::SetBufferSize(hopSize);
555 InitSTFTFrames();
556 CalculateWindow();
557 CalculateScalingFactors();
558 }
559
560 void SetWindowType(EWindowType windowType)
561 {
562 mWindowType = windowType;
563 CalculateWindow();
564 CalculateScalingFactors();
565 }
566
567 void SetOutputType(EOutputType outputType)
568 {
569 mOutputType = outputType;
570 }
571
572 void PrepareDataForUI(ISenderData<MAXNC, TDataPacket>& d) override
573 {
574 int hopSize = TBufferSender::GetBufferSize();
575
576 for (auto s = 0; s < hopSize; s++)
577 {
578 for (auto stftFrameIdx = 0; stftFrameIdx < mOverlap; stftFrameIdx++)
579 {
580 auto& stftFrame = mSTFTFrames[stftFrameIdx];
581
582 for (auto ch = 0; ch < MAXNC; ch++)
583 {
584 auto windowedValue = (float) d.vals[ch][s] * mWindow[stftFrame.pos];
585 stftFrame.bins[ch][stftFrame.pos].re = windowedValue;
586 stftFrame.bins[ch][stftFrame.pos].im = 0.0f;
587 }
588
589 stftFrame.pos++;
590
591 if (stftFrame.pos >= mFFTSize)
592 {
593 stftFrame.pos = 0;
594
595 for (auto ch = 0; ch < MAXNC; ch++)
596 {
597 Permute(ch, stftFrameIdx);
598 memcpy(d.vals[ch].data(), mSTFTOutput[ch].data(), mFFTSize * sizeof(float));
599 }
600 }
601 }
602 }
603 }
604
605 int GetFFTSize() const
606 {
607 return mFFTSize;
608 }
609
610 int GetOverlap() const
611 {
612 return mOverlap;
613 }
614
615 int GetHopSize() const
616 {
617 return TBufferSender::GetBufferSize();
618 }
619
620 EWindowType GetWindowType() const
621 {
622 return mWindowType;
623 }
624
625private:
626 void InitSTFTFrames()
627 {
628 if (mSTFTFrames.size() != mOverlap)
629 {
630 mSTFTFrames.resize(mOverlap);
631 }
632
633 int hopSize = mFFTSize / mOverlap;
634
635 for (int i = 0; i < mOverlap; i++)
636 {
637 auto& frame = mSTFTFrames[i];
638 for (auto ch = 0; ch < MAXNC; ch++)
639 {
640 std::fill(frame.bins[ch].begin(), frame.bins[ch].end(), WDL_FFT_COMPLEX{0.0f, 0.0f});
641 }
642 // Stagger frame positions so FFTs are computed at different times
643 frame.pos = i * hopSize;
644 }
645
646 for (auto ch = 0; ch < MAXNC; ch++)
647 {
648 std::fill(mSTFTOutput[ch].begin(), mSTFTOutput[ch].end(), 0.0f);
649 }
650 }
651
652 void CalculateWindow()
653 {
654 const float M = static_cast<float>(mFFTSize - 1);
655
656 switch (mWindowType)
657 {
658 case EWindowType::Hann:
659 for (auto i = 0; i < mFFTSize; i++) { mWindow[i] = 0.5f * (1.0f - std::cos(PI * 2.0f * i / M)); }
660 break;
661 case EWindowType::BlackmanHarris:
662 for (auto i = 0; i < mFFTSize; i++) {
663 mWindow[i] = 0.35875 - (0.48829f * std::cos(2.0f * PI * i / M)) +
664 (0.14128f * std::cos(4.0f * PI * i / M)) -
665 (0.01168f * std::cos(6.0f * PI * i / M));
666 }
667 break;
668 case EWindowType::Hamming:
669 for (auto i = 0; i < mFFTSize; i++) { mWindow[i] = 0.54f - 0.46f * std::cos(2.0f * PI * i / M); }
670 break;
671 case EWindowType::Flattop:
672 for (auto i = 0; i < mFFTSize; i++) {
673 mWindow[i] = 0.21557895f - 0.41663158f * std::cos(2.0f * PI * i / M) +
674 0.277263158f * std::cos(4.0f * PI * i / M) -
675 0.083578947f * std::cos(6.0f * PI * i / M) +
676 0.006947368f * std::cos(8.0f * PI * i / M);
677 }
678 break;
679 case EWindowType::Rectangular:
680 std::fill(mWindow.begin(), mWindow.end(), 1.0f);
681 break;
682 default:
683 break;
684 }
685 }
686
687 void CalculateScalingFactors()
688 {
689 auto scaling = 0.0f;
690
691 for (auto i = 0; i < mFFTSize; i++)
692 {
693 scaling += mWindow[i];
694 }
695
696 mScalingFactor = scaling * scaling;
697 }
698
699 void Permute(int ch, int frameIdx)
700 {
701 WDL_fft(mSTFTFrames[frameIdx].bins[ch].data(), mFFTSize, false);
702
703 if (mOutputType == EOutputType::Complex)
704 {
705 auto nBins = mFFTSize / 2;
706 for (auto i = 0; i < nBins; ++i)
707 {
708 int sortIdx = WDL_fft_permute(mFFTSize, i);
709 mSTFTOutput[ch][i] = mSTFTFrames[frameIdx].bins[ch][sortIdx].re;
710 mSTFTOutput[ch][i + nBins] = mSTFTFrames[frameIdx].bins[ch][sortIdx].im;
711 }
712 }
713 else // magPhase
714 {
715 auto nBins = mFFTSize / 2;
716 for (auto i = 0; i < nBins; ++i)
717 {
718 int sortIdx = WDL_fft_permute(mFFTSize, i);
719 auto re = mSTFTFrames[frameIdx].bins[ch][sortIdx].re;
720 auto im = mSTFTFrames[frameIdx].bins[ch][sortIdx].im;
721 mSTFTOutput[ch][i] = std::sqrt(2.0f * (re * re + im * im) / mScalingFactor);
722 mSTFTOutput[ch][i + nBins] = std::atan2(im, re);
723 }
724 }
725 }
726
727 struct STFTFrame
728 {
729 int pos;
730 std::array<std::array<WDL_FFT_COMPLEX, MAX_FFT_SIZE>, MAXNC> bins;
731 };
732
733 int mFFTSize = 1024;
734 int mOverlap = 1;
735 EWindowType mWindowType;
736 EOutputType mOutputType;
737 std::array<float, MAX_FFT_SIZE> mWindow;
738 std::vector<STFTFrame> mSTFTFrames;
739 std::array<std::array<float, MAX_FFT_SIZE>, MAXNC> mSTFTOutput;
740 float mScalingFactor = 0.0f;
741};
742
743END_IPLUG_NAMESPACE
Include to get consistently named preprocessor macros for different platforms and logging functionali...
IBufferSender is a utility class which can be used to defer buffer data for sending to the GUI.
Definition: ISender.h:435
void ProcessBlock(sample **inputs, int nFrames, int ctrlTag=kNoTag, int nChans=MAXNC, int chanOffset=0)
Queue sample buffers into the sender, checking the data is over the required threshold.
Definition: ISender.h:458
This pure virtual interface delegates communication in both directions between a UI editor and someth...
virtual void SendControlMsgFromDelegate(int ctrlTag, int msgTag, int dataSize=0, const void *pData=nullptr)
SendControlMsgFromDelegate (Abbreviation: SCMFD) WARNING: should not be called on the realtime audio ...
IPeakAvgSender is a utility class which can be used to defer peak & avg/RMS data from sample buffers ...
Definition: ISender.h:199
void ProcessBlock(sample **inputs, int nFrames, int ctrlTag=kNoTag, int nChans=MAXNC, int chanOffset=0)
Queue peaks from sample buffers into the sender This can be called on the realtime audio thread.
Definition: ISender.h:296
IPeakSender is a utility class which can be used to defer peak data from sample buffers for sending t...
Definition: ISender.h:125
void ProcessBlock(sample **inputs, int nFrames, int ctrlTag=kNoTag, int nChans=MAXNC, int chanOffset=0)
Queue peaks from sample buffers into the sender This can be called on the realtime audio thread.
Definition: ISender.h:153
A lock-free SPSC queue used to transfer data between threads based on MLQueue.h by Randy Jones based ...
Definition: IPlugQueue.h:32
ISender is a utility class which can be used to defer data from the realtime audio processing and sen...
Definition: ISender.h:66
ISenderData< MAXNC, T > GetLastData()
Gets the last data item sent to the UI
Definition: ISender.h:113
virtual void PrepareDataForUI(ISenderData< MAXNC, T > &d)
This is called on the main thread and can be used to transform the data, e.g.
Definition: ISender.h:77
void PushData(const ISenderData< MAXNC, T > &d)
Pushes a data element onto the queue.
Definition: ISender.h:71
void TransmitDataToControlsWithTags(IEditorDelegate &dlg, const std::initializer_list< int > &ctrlTags)
This variation can be used if you need to supply multiple controls with the same ISenderData,...
Definition: ISender.h:97
void TransmitData(IEditorDelegate &dlg)
Pops elements off the queue and sends messages to controls.
Definition: ISender.h:81
ISpectrumSender is designed for sending Spectral Data from the plug-in to the UI.
Definition: ISender.h:517
static double DBToAmp(double dB)
Calculates gain from a given dB value.
ISenderData is used to represent a typed data packet, that may contain values for multiple channels.
Definition: ISender.h:35