Gin
Loading...
Searching...
No Matches
WaveformComponent Class Reference

Visual component for displaying audio waveforms with zoom and scroll. More...

#include <gin_waveformcomponent.h>

Inherits juce::Component.

Public Types

enum  ColourIds { lineColourId = 0x1231e10 , backgroundColourId = 0x1231e11 , traceColourId = 0x1231e12 , envelopeColourId = 0x1231f13 }

Public Member Functions

 WaveformComponent ()
 ~WaveformComponent () override
 Destructor.
void setHorizontalZoom (float zoom)
void setHorizontalOffset (float offset)
void setBuffer (juce::AudioSampleBuffer &buffer)
void paint (juce::Graphics &g) override
void resized () override

Detailed Description

Visual component for displaying audio waveforms with zoom and scroll.

WaveformComponent renders multi-channel audio waveforms with support for horizontal zooming and panning. It efficiently displays large audio buffers by downsampling to min/max envelopes at the current zoom level, providing smooth visualization even for long audio files.

Key Features:

  • Multi-channel waveform display
  • Horizontal zoom and scroll
  • Efficient downsampling for display
  • Min/max envelope rendering
  • Customizable colors via ColourIds
  • Automatic updates on resize
  • Optimized for real-time display

Color Customization:

  • lineColourId: Color for zero-crossing line
  • backgroundColourId: Background color
  • traceColourId: Waveform trace color
  • envelopeColourId: Waveform envelope fill color

The component automatically processes the audio buffer into min/max pairs for efficient rendering at any zoom level, avoiding the need to draw individual samples when zoomed out.

Usage:

waveform.setBounds(0, 0, 800, 200);
// Set audio to display
AudioBuffer<float> audioData(2, 44100); // 2 channels, 1 second
// ... fill with audio data ...
waveform.setBuffer(audioData);
// Customize colors
waveform.setColour(WaveformComponent::traceColourId, Colours::blue);
Colours::lightblue.withAlpha(0.3f));
// Zoom and scroll
waveform.setHorizontalZoom(2.0f); // 2x zoom
waveform.setHorizontalOffset(0.25f); // Start at 25% through buffer
@ envelopeColourId
Definition gin_waveformcomponent.h:69
@ traceColourId
Definition gin_waveformcomponent.h:68
void setHorizontalZoom(float zoom)
void setHorizontalOffset(float offset)
void setBuffer(juce::AudioSampleBuffer &buffer)
See also
juce::AudioSampleBuffer, juce::Component

Member Enumeration Documentation

◆ ColourIds

Enumerator
lineColourId 
backgroundColourId 
traceColourId 
envelopeColourId 

Constructor & Destructor Documentation

◆ WaveformComponent()

WaveformComponent::WaveformComponent ( )

◆ ~WaveformComponent()

WaveformComponent::~WaveformComponent ( )
override

Destructor.

Member Function Documentation

◆ setHorizontalZoom()

void WaveformComponent::setHorizontalZoom ( float zoom)

◆ setHorizontalOffset()

void WaveformComponent::setHorizontalOffset ( float offset)

◆ setBuffer()

void WaveformComponent::setBuffer ( juce::AudioSampleBuffer & buffer)

◆ paint()

void WaveformComponent::paint ( juce::Graphics & g)
override

◆ resized()

void WaveformComponent::resized ( )
override

The documentation for this class was generated from the following file: