13 #define csl_max(a, b) (((a) > (b)) ? (a) : (b))
14 #define csl_min(a, b) (((a) < (b)) ? (a) : (b))
63 g.fillAll (juce::Colours::black);
64 g.setColour (juce::Colours::lightgreen);
66 const float halfHeight = getHeight() * 0.5f;
67 unsigned wid = getWidth();
92 if ((y0 >= 0.0) && (y1 < 0.0))
97 for (
unsigned x = 0; x < wid; x++) {
102 if ( ! std::isnormal(level))
continue;
105 g.drawLine ((
float) x, halfHeight,
106 (
float) x, halfHeight + (halfHeight * level));
133 float** outputChannelData,
int totalNumOutputChannels,
int numSamples) {
140 for (
int i = 0; i < totalNumOutputChannels; ++i) {
141 if (outputChannelData[i] != 0) {
142 for (
int j = 0; j < numSamples; ++j)
148 for (
int j = 0; j < numSamples; ++j)
185 float** outputChannelData,
int totalNumOutputChannels,
int numSamples) {
186 float realV, imagV, pixV;
192 for (
unsigned x = 0; x < numSamples / 2; x++) {
193 realV = outputChannelData[0][x + 1];
194 imagV = outputChannelData[0][numSamples - (x + 1)];
195 pixV = hypotf(realV, imagV) * 10.0;
206 #define SetPixel(g, x, y) g.fillRect(x, y, 1, 1);
210 g.fillAll (juce::Colours::black);
212 unsigned hite = getHeight();
213 unsigned wid = getWidth();
220 for (
unsigned x = 0; x < wid; x++) {
225 for (
unsigned y = 0; y < hite; y++) {
231 for (
unsigned y = 0; y < hite; y++) {
232 g.setColour (juce::Colour(
circularBuffer[y] / maxV, 1.0f, 1.0f, 1.0f));
233 unsigned yVal = hite - y;
234 unsigned xVal = x * xScale;
235 for (
unsigned i = 0; i < xScale; i++) {
242 g.setColour (juce::Colours::lightgreen);
245 for (
unsigned x = 0; x < howWide; x++) {
258 for (
unsigned x = 0; x < howWide; x++) {
270 for (
unsigned x = 0; x < howWide; x += 2) {
272 g.drawLine ((
float) x, hite, (
float) x, realV);
273 g.drawLine ((
float) x+1, hite, (
float) x+1, realV);
286 double RangeSlider::getBaseValue() {
292 double RangeSlider::getRangeValue() {
293 return (rangeValue - minimum) / (maximum - minimum);
296 void RangeSlider::mouseDown (
const MouseEvent& e) {
298 float maxPosDistance;
299 float minPosDistance;
300 mouseWasHidden =
false;
301 incDecDragged =
false;
306 valueBox->hideEditor (
true);
307 sliderBeingDragged = 0;
308 mousePos = (float) (isVertical() ? e.y : e.x);
309 maxPosDistance = fabsf (getLinearSliderPos (getMaxValue()) - 0.1f - mousePos);
310 minPosDistance = fabsf (getLinearSliderPos (getMinValue()) + 0.1f - mousePos);
311 if (maxPosDistance <= minPosDistance)
312 sliderBeingDragged = 2;
314 sliderBeingDragged = 1;
316 minMaxDiff = getMaxValue() - getMinValue();
317 mouseXWhenLastDragged = e.x;
318 mouseYWhenLastDragged = e.y;
319 if (sliderBeingDragged == 2)
320 valueWhenLastDragged = getValue();
321 else if (sliderBeingDragged == 1)
322 valueWhenLastDragged = baseValue;
323 valueOnMouseDown = valueWhenLastDragged;
329 void RangeSlider::mouseDrag (
const MouseEvent& e) {
330 if (isEnabled() && ( ! menuShown)) {
331 const int mousePos = (isHorizontal() || style == RotaryHorizontalDrag) ? e.x : e.y;
332 double scaledMousePos = (mousePos - sliderRegionStart) / (double) sliderRegionSize;
333 if (style == LinearVertical)
334 scaledMousePos = 1.0 - scaledMousePos;
335 valueWhenLastDragged = proportionOfLengthToValue (jlimit (0.0, 1.0, scaledMousePos));
336 mouseXWhenLastDragged = e.x;
337 mouseYWhenLastDragged = e.y;
338 valueWhenLastDragged = jlimit (minimum, maximum, valueWhenLastDragged);
339 if (sliderBeingDragged == 1)
340 setBaseValue(valueWhenLastDragged, ! sendChangeOnlyOnRelease,
false);
341 else if (sliderBeingDragged == 2)
342 setRangeValue(valueWhenLastDragged, ! sendChangeOnlyOnRelease,
false);
343 mouseXWhenLastDragged = e.x;
344 mouseYWhenLastDragged = e.y;
348 void RangeSlider::setBaseValue (
double newValue,
const bool sendUpdateMessage,
const bool sendMessageSynchronously) {
352 if (baseValue != newValue) {
353 baseValue = newValue;
355 currentValue = newValue;
357 if (sendUpdateMessage)
358 triggerChangeMessage (sendMessageSynchronously);
362 void RangeSlider::setRangeValue (
double newValue,
const bool sendUpdateMessage,
const bool sendMessageSynchronously) {
366 if (rangeValue != newValue) {
367 rangeValue = newValue;
370 if (sendUpdateMessage)
371 triggerChangeMessage (sendMessageSynchronously);
385 Component(
"VU Meter"),
390 m_meterType(
VUMeter::Vertical),
396 m_minColour(
juce::Colours::green),
397 m_thresholdColour(
juce::Colours::yellow),
398 m_maxColour(
juce::Colours::red),
399 m_backgroundColour(
juce::Colours::black),
401 m_decayPercent(0.707f),
418 const juce::Colour&
min,
419 const juce::Colour& thresh,
420 const juce::Colour&
max,
421 const juce::Colour& back,
423 Component(
"VU Meter"),
427 m_threshold(threshold),
430 m_markerWidth(markerWidth),
435 m_thresholdColour(thresh),
437 m_backgroundColour(back),
439 m_decayPercent(0.707f),
448 m_needleWidth(markerWidth)
457 juce::Image* background,
458 juce::Image* overlay,
461 juce::Point<int>& needleCenter,
466 const juce::Colour& needleColour,
467 int needleDropShadow,
469 Component(
"Meter Component"),
481 m_thresholdColour(0),
483 m_backgroundColour(0),
485 m_decayPercent(0.707f),
491 m_minPosition(minPosition),
492 m_maxPosition(maxPosition),
493 m_needleLength(needleLength),
494 m_needleWidth(needleWidth),
495 m_arrowLength(arrowLength),
496 m_arrowWidth(arrowWidth),
497 m_needleDropShadow(needleDropShadow),
498 m_dropDistance(dropDistance)
510 deleteAndZero(
m_img);
516 deleteAndZero(
m_img);
519 int w = getWidth() -
m_inset*2;
520 int h = getHeight() -
m_inset*2;
521 if ((w == 0) || (h == 0))
524 m_img =
new juce::Image(juce::Image::RGB, w, h,
false);
525 juce::Graphics g(*
m_img);
528 g.setGradientFill(brLower);
529 g.fillRect(0, 0,
int(w * m_threshold), h);
532 g.setGradientFill(brUpper);
533 g.fillRect(
int(w * m_threshold), 0, w, h);
545 m_img =
new juce::Image(juce::Image::RGB, w, h,
false);
546 juce::Graphics g(*
m_img);
550 g.setGradientFill(brLower);
551 g.fillRect(0, h - hSize, w, hSize);
554 g.setGradientFill(brUpper);
555 g.fillRect(0, 0, w, h - hSize);
568 m_img =
new juce::Image(juce::Image::RGB, w, h,
false);
569 juce::Graphics g(*
m_img);
572 g.fillRect(0, 0, w, h);
574 const double left = 4.71238898;
575 const double right = 1.57079633;
581 float radius =
csl_max (w/2, h/2) - strokeWidth/2;
588 for (pos = startPos; pos < endPos; pos += .02) {
589 angle = left + pos * (right - left);
590 x = sin(angle)*radius + w/2;
593 p.startNewSubPath(x, y);
597 angle = left + pos * (right - left);
598 p.lineTo(sin(angle)*radius + w/2, cos(angle)*radius + h -
m_segments);
601 juce::Image img(juce::Image::RGB, w, h,
false);
602 juce::Graphics g2(img);
605 g2.setGradientFill(brLower);
606 g2.fillRect(0, 0,
int(w * m_threshold), h);
609 g2.setGradientFill(brUpper);
610 g2.fillRect(
int(w * m_threshold), 0, w, h);
612 g.setTiledImageFill(img, 0, 0, 1.0);
615 g.strokePath(p, juce::PathStrokeType(strokeWidth));
620 Component::setBounds(x, y, width, height);
640 if (
m_skew != 1.0 && val > 0.0)
641 val = exp (log (val) /
m_skew);
691 int h = getHeight() -
m_inset*2;
692 int w = getWidth() -
m_inset*2;
702 juce::LookAndFeel_V1::drawBevel(g, 0, 0, getWidth(), getHeight(),
704 m_raised ? juce::Colours::white.withAlpha(0.9f) : juce::Colours::black.withAlpha(0.9f),
705 m_raised ? juce::Colours::black.withAlpha(0.9f) : juce::Colours::white.withAlpha(0.9f));
741 int dropX, dropY, dropPointX, dropPointY;
763 g.setColour(juce::Colours::black.withAlpha(0.2f));
794 int totalNumInputChannels,
795 float** outputChannelData,
796 int totalNumOutputChannels,
800 float * sampPtr = outputChannelData[
m_channel];
801 for (
int j = 0; j < numSamples; j++) {
802 samp = fabs(*sampPtr++);
void audioDeviceIOCallback(const float **inputChannelData, int totalNumInputChannels, float **outputChannelData, int totalNumOutputChannels, int numSamples)
void setDecay(int decay, int hold, float percent=0.707f)
juce::Colour m_needleColour
virtual void audioDeviceIOCallback(const float **inputChannelData, int totalNumInputChannels, float **outputChannelData, int totalNumOutputChannels, int numSamples)
void paint(juce::Graphics &g)
virtual void timerCallback()
#define CSL_mMaxBufferFrames
max block size (set large for zooming scopes)
juce::Image * m_background
float sample
(could be changed to int, or double)
void setBounds(int x, int y, int width, int height)
virtual void paint(juce::Graphics &g)
juce::Colour m_thresholdColour
juce::Colour m_backgroundColour
juce::Point< int > m_needleCenter
void setColours(juce::Colour &min, juce::Colour &threshold, juce::Colour &max, juce::Colour &back)
void setFrame(int inset, bool raised=false)