16 #include "vstgui/vstgui.h" 17 #include "vstgui/vstgui_uidescription.h" 19 #include "../PluginKernel/pluginstructures.h" 24 const int DATA_QUEUE_LEN = 4096;
48 WaveView(
const CRect& size, IControlListener* listener, int32_t tag);
74 void draw(CDrawContext* pContext)
override;
118 const int FFT_LEN = 512;
149 SpectrumView(
const CRect& size, IControlListener* listener, int32_t tag);
167 void draw(CDrawContext* pContext)
override;
206 inline double getMagnitude(
double re,
double im)
208 return sqrt((re*re)+(im*im));
219 double maxRetValue = 0;
222 for(
int j=0; j<bufferSize; j++)
224 if((fabs(buffer[j])) > max)
226 max = fabs(buffer[j]);
233 for(
int j=0; j<bufferSize; j++)
235 buffer[j] = buffer[j]/max;
236 if(j == *ptrMaxIndex)
237 maxRetValue = buffer[j];
252 int x1 = (int)fractionalIndex;
264 double dx = (fractionalIndex - x1)/(x2 - x1);
267 return dx*array[x2] + (1-dx)*array[x1];
284 #endif // defined FFTW 288 const unsigned int MESSAGE_SHOW_CONTROL = 0;
289 const unsigned int MESSAGE_HIDE_CONTROL = 1;
290 const unsigned int MESSAGE_SET_CONTROL_ALPHA = 1;
343 CustomKnobView(
const CRect& size, IControlListener* listener, int32_t tag, int32_t subPixmaps,
344 CCoord heightOfOneImage, CBitmap* background,
const CPoint &offset,
345 bool bSwitchKnob =
false);
421 return std::find(linkedKnobs.begin(), linkedKnobs.end(), control) != linkedKnobs.end();
431 virtual CView*
verifyView(CView* view,
const UIAttributes& attributes,
const IUIDescription* description)
override 433 CAnimKnob* knob =
dynamic_cast<CAnimKnob*
>(view);
434 CTextButton* button =
dynamic_cast<CTextButton*
>(view);
440 if (button->getValueNormalized() != 0)
446 linkedKnobs.push_back(knob);
460 if (control->getValueNormalized() != 0)
478 for (std::vector<CAnimKnob*>::iterator it = linkedKnobs.begin(); it != linkedKnobs.end(); ++it)
481 CControl* ctrl = *it;
483 if (ctrl && control != ctrl)
486 ctrl->setValueNormalized(control->getValueNormalized());
502 virtual CView*
createView(
const UIAttributes& attributes,
const IUIDescription* description)
override {
return parentController->createView(attributes, description); }
522 pControl->setListener(
this);
533 pControl->setListener(
this);
spectrumViewWindowType
Use this strongly typed enum to easily set the window type for the spectrum view. ...
Definition: customviews.h:115
This object demonstrates how to create a sub-controller. In this object, you can link multiple knob c...
Definition: customviews.h:396
This object displays an audio histogram waveform view. .
Definition: customviews.h:45
virtual void valueChanged(CControl *control) override
Definition: customviews.h:455
bool visible
simple show/hide flag
Definition: customviews.h:323
bool paintXAxis
flag for painting X Axis
Definition: customviews.h:81
fftw_plan plan_forward
plan for FFT
Definition: customviews.h:181
void showFilledFFT(bool _filledFFT)
Definition: customviews.h:159
int circularBufferLength
circular buffer length
Definition: customviews.h:87
virtual void updateView() override
Definition: customviews.cpp:62
bool linkControls
enable linking
Definition: customviews.h:549
virtual void controlBeginEdit(CControl *pControl) override
Definition: customviews.h:507
fftw_complex * ifft_result
ifft output (not used)
Definition: customviews.h:180
std::vector< CAnimKnob * > KnobList
list of knobs
Definition: customviews.h:545
void draw(CDrawContext *pContext) override
Definition: customviews.cpp:104
bool addFFTInputData(double inputSample)
Definition: customviews.cpp:250
CRect currentRect
the rect to draw into
Definition: customviews.h:88
virtual CView * verifyView(CView *view, const UIAttributes &attributes, const IUIDescription *description) override
Definition: customviews.h:431
CustomKnobView(const CRect &size, IControlListener *listener, int32_t tag, int32_t subPixmaps, CCoord heightOfOneImage, CBitmap *background, const CPoint &offset, bool bSwitchKnob=false)
CustomKnobView constructor.
Definition: customviews.cpp:434
void clearBuffer()
Definition: customviews.cpp:96
virtual void pushDataValue(double data) override
Definition: customviews.cpp:54
void draw(CDrawContext *pContext) override
Definition: customviews.cpp:334
double controlAlpha
transparency: 0 = invisible (100% transparent) and 1 = solidly visible (0% transparent) ...
Definition: customviews.h:325
double interpArrayValue(double *array, int arraySize, double fractionalIndex)
Definition: customviews.h:249
bool filledFFT
flag for filled FFT
Definition: customviews.h:272
virtual void updateView() override
Definition: customviews.cpp:274
Custom View interface to allow plugin core to create safe communication channels with GUI custom view...
Definition: pluginstructures.h:1141
fftw_plan plan_backward
plan for IFFT (not used)
Definition: customviews.h:182
int writeIndex
circular buffer write location
Definition: customviews.h:85
This object demonstrates how to subclass an existing VSTGUI4 control to setup a communcation channel ...
Definition: customviews.h:340
CTextButton * linkControl
the link button is defined as a CTextButton (by me)
Definition: customviews.h:541
KnobLinkController(IController *_parentController)
Definition: customviews.h:402
Definition: customcontrols.cpp:20
double * currentFFTMagBuffer
poitner to current FFT buffer
Definition: customviews.h:202
fftw_complex * data
fft input data
Definition: customviews.h:178
virtual void pushDataValue(double data) override
Definition: customviews.cpp:266
double fftMagnitudeArray_B[FFT_LEN]
1/2 of double buffer (yes this is overkill but showing as demonstration!!)
Definition: customviews.h:195
void showXAxis(bool _paintXAxis)
Definition: customviews.h:69
virtual void controlTagDidChange(CControl *pControl) override
Definition: customviews.h:529
virtual CView * createView(const UIAttributes &attributes, const IUIDescription *description) override
Definition: customviews.h:502
int fftInputCounter
input counter for FFT
Definition: customviews.h:185
void setWindow(spectrumViewWindowType _window)
Definition: customviews.cpp:222
double * circularBuffer
circular buffer to store peak values
Definition: customviews.h:84
virtual void sendMessage(void *data) override
Definition: customviews.cpp:447
WaveView(const CRect &size, IControlListener *listener, int32_t tag)
WaveView constructor.
Definition: customviews.cpp:25
double fftWindow[FFT_LEN]
window buffer
Definition: customviews.h:198
int readIndex
circular buffer read location
Definition: customviews.h:86
IController * parentController
pointer to owning listener
Definition: customviews.h:538
double fftMagnitudeArray_A[FFT_LEN]
1/2 of double buffer (yes this is overkill but showing as demonstration!!)
Definition: customviews.h:194
void addWaveDataPoint(float fSample)
Definition: customviews.cpp:87
virtual void updateView() override
Definition: customviews.cpp:455
This object displays the FFT of the incoming data. .
Definition: customviews.h:146
unsigned int message
message to send/receive
Definition: customviews.h:322
double normalizeBufferGetFMax(double *buffer, unsigned int bufferSize, int *ptrMaxIndex)
Definition: customviews.h:216
SpectrumView(const CRect &size, IControlListener *listener, int32_t tag)
SpectrumView constructor.
Definition: customviews.cpp:179
fftw_complex * fft_result
fft output data
Definition: customviews.h:179
virtual void controlTagWillChange(CControl *pControl) override
Definition: customviews.h:518
spectrumViewWindowType window
window type
Definition: customviews.h:175
bool isLinkedControl(CControl *control)
Definition: customviews.h:419
bool showAlternateGraphic
flag to show another graphic
Definition: customviews.h:324
virtual void controlEndEdit(CControl *pControl) override
Definition: customviews.h:512
Custom structure for passing messages and data to and from the plugin core object. See the Custom View tutorial project for more informaiton.
Definition: customviews.h:304