16#include "vstgui/vstgui.h"
17#include "vstgui/vstgui_uidescription.h"
19#include "../PluginKernel/pluginstructures.h"
25const int DATA_QUEUE_LEN = 4096;
28const unsigned int MESSAGE_SET_STRINGLIST = 0;
29const unsigned int MESSAGE_SET_STRING = 1;
54 WaveView(
const CRect& size, IControlListener* listener, int32_t tag);
80 void draw(CDrawContext* pContext)
override;
119enum class spectrumViewWindowType {kRectWindow, kHannWindow, kBlackmanHarrisWindow};
122const int FFT_LEN = 512;
150class SpectrumView :
public CControl,
public ICustomView
153 SpectrumView(
const CRect& size, IControlListener* listener, int32_t tag);
157 virtual void updateView()
override;
160 virtual void pushDataValue(
double data)
override;
163 void showFilledFFT(
bool _filledFFT) { filledFFT = _filledFFT; }
168 void setWindow(spectrumViewWindowType _window);
171 void draw(CDrawContext* pContext)
override;
174 CLASS_METHODS(SpectrumView, CControl)
179 spectrumViewWindowType window = spectrumViewWindowType::kRectWindow;
182 fftw_complex* data =
nullptr;
183 fftw_complex* fft_result =
nullptr;
184 fftw_complex* ifft_result =
nullptr;
185 fftw_plan plan_forward;
186 fftw_plan plan_backward;
189 int fftInputCounter = 0;
195 bool addFFTInputData(
double inputSample);
198 double fftMagnitudeArray_A[FFT_LEN] = {0.0};
199 double fftMagnitudeArray_B[FFT_LEN] = {0.0};
202 double fftWindow[FFT_LEN] = {1.0};
206 double* currentFFTMagBuffer =
nullptr;
212 return sqrt((re*re)+(im*im));
220 inline double normalizeBufferGetFMax(
double* buffer,
unsigned int bufferSize,
int* ptrMaxIndex)
223 double maxRetValue = 0;
226 for(
int j=0; j<bufferSize; j++)
228 if((fabs(buffer[j])) > max)
230 max = fabs(buffer[j]);
237 for(
int j=0; j<bufferSize; j++)
239 buffer[j] = buffer[j]/max;
240 if(j == *ptrMaxIndex)
241 maxRetValue = buffer[j];
253 inline double interpArrayValue(
double* array,
int arraySize,
double fractionalIndex)
256 int x1 = (int)fractionalIndex;
268 double dx = (fractionalIndex - x1)/(x2 - x1);
271 return dx*array[x2] + (1-dx)*array[x1];
276 bool filledFFT =
true;
292const unsigned int MESSAGE_SHOW_CONTROL = 0;
293const unsigned int MESSAGE_HIDE_CONTROL = 1;
294const unsigned int MESSAGE_SET_CONTROL_ALPHA = 2;
295const unsigned int MESSAGE_QUERY_CONTROL = 3;
314 message = initMessage.message;
315 visible = initMessage.visible;
316 showAlternateGraphic = initMessage.showAlternateGraphic;
317 controlAlpha = initMessage.controlAlpha;
318 queryString = initMessage.queryString;
319 replyString = initMessage.replyString;
320 messageData = initMessage.messageData;
325 message = viewMessage.message;
326 visible = viewMessage.visible;
327 showAlternateGraphic = viewMessage.showAlternateGraphic;
328 controlAlpha = viewMessage.controlAlpha;
329 queryString = viewMessage.queryString;
330 replyString = viewMessage.replyString;
331 messageData = viewMessage.messageData;
336 unsigned int message = MESSAGE_HIDE_CONTROL;
339 bool showAlternateGraphic =
false;
340 double controlAlpha = 1.0;
341 std::string queryString;
342 std::string replyString;
343 void* messageData =
nullptr;
361 CustomKnobView(
const CRect& size, IControlListener* listener, int32_t tag, int32_t subPixmaps,
362 CCoord heightOfOneImage, CBitmap* background,
const CPoint &offset,
363 bool bSwitchKnob =
false);
439 return std::find(linkedKnobs.begin(), linkedKnobs.end(), control) != linkedKnobs.end();
449 virtual CView*
verifyView(CView* view,
const UIAttributes& attributes,
const IUIDescription* description)
override
451 CAnimKnob* knob =
dynamic_cast<CAnimKnob*
>(view);
452 CTextButton* button =
dynamic_cast<CTextButton*
>(view);
458 if (button->getValueNormalized() != 0)
464 linkedKnobs.push_back(knob);
478 if (control->getValueNormalized() != 0)
496 for (std::vector<CAnimKnob*>::iterator it = linkedKnobs.begin(); it != linkedKnobs.end(); ++it)
499 CControl* ctrl = *it;
501 if (ctrl && control != ctrl)
504 ctrl->setValueNormalized(control->getValueNormalized());
522 virtual CView*
createView(
const UIAttributes& attributes,
const IUIDescription* description)
override {
return parentController->createView(attributes, description); }
542 pControl->setListener(
this);
553 pControl->setListener(
this);
588 unsigned int message = MESSAGE_SET_STRING;
590 std::string labelString;
591 std::vector<std::string> stringList;
593 uint32_t controlStringCount = 0;
610 uint32_t message = MESSAGE_SET_STRING;
612 const char* labelString;
614 uint32_t stringCount = 0;
630 CustomTextLabel(
const CRect& size, CHoriTxtAlign horizTA = CHoriTxtAlign::kCenterText, UTF8StringPtr txt = 0, CBitmap* background = 0,
const int32_t style = 0)
631 : CTextLabel(size, txt, background, style)
633 textAlignment = horizTA;
642 void draw(CDrawContext* pContext)
override
644 setHoriAlign(textAlignment);
645 CTextLabel::draw(pContext);
654 if (viewMessage->message == MESSAGE_SET_STRING)
657 this->setText(viewMessage->labelString.c_str());
664 CHoriTxtAlign textAlignment = CHoriTxtAlign::kCenterText;
681 CustomOptionMenu(
const CRect& size, IControlListener* listener, int32_t tag, CBitmap* background =
nullptr, CBitmap* bgWhenClick =
nullptr,
const int32_t style = 0)
682 : COptionMenu(size, listener, tag, background, bgWhenClick, style)
684 this->setNbItemsPerColumn(8);
697 CMenuItem* item = getEntry((int32_t)getValue());
699 if (item->getTitle() ==
"-----")
701 setValue((
float)lastActualEntryIndex);
705 COptionMenu::valueChanged();
714 if (viewMessage->message == MESSAGE_SET_STRINGLIST)
717 this->removeAllEntry();
718 for (uint32_t i = 0; i < viewMessage->controlStringCount; i++)
720 if (i < viewMessage->stringList.size())
722 COptionMenu::addEntry(viewMessage->stringList[i].c_str(), i);
723 if(viewMessage->stringList[i].compare(
"-----") != 0)
724 lastActualEntryIndex = i;
727 COptionMenu::addEntry(
"-----", i);
730 if (lastActualEntryIndex < 0) lastActualEntryIndex = 0;
737 int32_t lastActualEntryIndex = 0;
Custom View interface to allow plugin core to create safe communication channels with GUI custom view...
Definition: pluginstructures.h:1462
This object demonstrates how to subclass an existing VSTGUI4 control to setup a communcation channel ...
Definition: customviews.h:359
virtual void updateView() override
Definition: customviews.cpp:471
virtual void sendMessage(void *data) override
Definition: customviews.cpp:453
Custom object for dynamic lables that can change their text programmatically. .
Definition: customviews.h:628
virtual void sendMessage(void *data) override
Definition: customviews.h:649
virtual void updateView() override
Definition: customviews.h:637
virtual ~CustomTextLabel(void)
Definition: customviews.h:663
This object demonstrates how to create a sub-controller. In this object, you can link multiple knob c...
Definition: customviews.h:415
std::vector< CAnimKnob * > KnobList
list of knobs
Definition: customviews.h:565
bool linkControls
enable linking
Definition: customviews.h:569
CTextButton * linkControl
the link button is defined as a CTextButton (by me)
Definition: customviews.h:561
virtual void controlEndEdit(CControl *pControl) override
Definition: customviews.h:532
KnobLinkController(IController *_parentController)
Definition: customviews.h:420
bool isLinkedControl(CControl *control)
Definition: customviews.h:437
virtual void controlTagWillChange(CControl *pControl) override
Definition: customviews.h:538
virtual CView * verifyView(CView *view, const UIAttributes &attributes, const IUIDescription *description) override
Definition: customviews.h:449
virtual CView * createView(const UIAttributes &attributes, const IUIDescription *description) override
Definition: customviews.h:522
IController * parentController
pointer to owning listener
Definition: customviews.h:558
virtual void controlBeginEdit(CControl *pControl) override
Definition: customviews.h:527
virtual void valueChanged(CControl *control) override
Definition: customviews.h:473
virtual void controlTagDidChange(CControl *pControl) override
Definition: customviews.h:549
This object displays an audio histogram waveform view. .
Definition: customviews.h:52
void draw(CDrawContext *pContext) override
Definition: customviews.cpp:104
CRect currentRect
the rect to draw into
Definition: customviews.h:94
int circularBufferLength
circular buffer length
Definition: customviews.h:93
int readIndex
circular buffer read location
Definition: customviews.h:92
int writeIndex
circular buffer write location
Definition: customviews.h:91
virtual void pushDataValue(double data) override
Definition: customviews.cpp:54
virtual void updateView() override
Definition: customviews.cpp:62
void showXAxis(bool _paintXAxis)
Definition: customviews.h:75
void addWaveDataPoint(float fSample)
Definition: customviews.cpp:87
bool paintXAxis
flag for painting X Axis
Definition: customviews.h:87
double * circularBuffer
circular buffer to store peak values
Definition: customviews.h:90
void clearBuffer()
Definition: customviews.cpp:96
Definition: readerwriterqueue.h:60
double getMagnitude(double re, double im)
calculates magnitude of a complex numb er
Definition: fxobjects.h:1003
Custom structure for passing messages and data to and from the plugin core object....
Definition: customviews.h:310
Custom structure for dynamic option menus in RackAFX only - NOTE: unused in ASPiK and not needed....
Definition: customviews.h:607
Custom structure for dynamic option menus. .
Definition: customviews.h:584