Skip to content

Advanced Rendering

Extend and customize waveform visualization with custom renderers and render hooks

Waveform Renderer provides two main mechanisms for customizing visualization beyond the standard options: Custom Renderers and Render Hooks.

Complete control over waveform visualization

Use custom renderers when you need to fully redefine how the waveform is drawn. Ideal for creating entirely new visualization styles or implementing complex rendering algorithms.

  • Replace the entire rendering pipeline
  • Full control over canvas operations
  • Advanced caching and optimization
  • Support for complex visual effects

📖 Learn about Custom Renderers →

Best for:

  • Line-based waveforms instead of bars
  • Circular or radial waveforms
  • 3D visualizations
  • Custom drawing algorithms

Lightweight extensions to the default rendering

Use render hooks when you want to add extra elements on top of the standard waveform rendering. Perfect for overlays, annotations, and visual effects.

  • Extend the default rendering pipeline
  • Hook into specific rendering phases
  • Minimal performance impact
  • Easy to implement and maintain

📖 Learn about Render Hooks →

Best for:

  • Progress indicators and markers
  • Beat markers and time scales
  • Overlays and watermarks
  • Real-time frequency analysis
  • Debug visualizations

FeatureCustom RenderersRender Hooks
ComplexityHighLow
ControlCompleteTargeted
PerformanceCan optimizeMinimal impact
Use CaseNew visualization stylesEnhance existing style
MaintenanceFull responsibilityLibrary handles core

If you want to fundamentally change how waveforms are visualized:

import { WaveformRenderer } from "waveform-renderer";
import { MyCustomRenderer } from "./my-custom-renderer";
const customRenderer = new MyCustomRenderer();
const waveform = new WaveformRenderer(canvas, peaks);
waveform.setCustomRenderer(customRenderer);

📖 Full Custom Renderer Guide →

If you want to add elements on top of the standard waveform:

import { WaveformRenderer } from "waveform-renderer";
const waveform = new WaveformRenderer(canvas, peaks);
waveform.setRenderHooks({
afterComplete: (ctx, cache, options) => {
// Add custom overlay
ctx.fillStyle = "rgba(255, 0, 0, 0.3)";
ctx.fillRect(0, 0, 100, 20);
},
});

📖 Full Render Hooks Guide →

  1. Choose your approach based on your customization needs
  2. Follow the detailed guides for implementation examples
  3. Experiment with the interactive demo to explore techniques
  4. Combine approaches – use both custom renderers and hooks together