How jberg/butterchurn works
Project Type and Purpose
• Purpose: Butterchurn is a client-side audio visualizer that uses WebGL to implement a MilkDrop-style effect. The README shows how to integrate the visualizer into web applications, load presets, and connect audio nodes.
• Main Use Case: Being a library for music visualization, it processes audio input, applies visual effects (using shaders and WebGL) and supports numerous customizable presets.
Analyzing the File Structure
• Top-Level Files:
– Configuration files (.eslintrc, .gitignore, webpack.config.js) and package management files indicate a well-structured JavaScript project.
• Directories:
– “src”: Contains the core application code. Subdirectories like “audio”, “rendering”, “equations”, “noise”, “image”, and “visualizer.js” indicate separation of concerns.
▪ The “audio” directory includes modules for audio processing (audioLevels, fft, audioProcessor) that process the audio signal.
▪ “equations” and “presetBase” point to the management and execution of presets, possibly involving both JavaScript and WASM (see presetEquationRunnerWASM.js).
▪ “assemblyscript” under both src and loaders indicate usage of AssemblyScript (WASM code) for performance-critical functions.
– “experiments”: Contains subprojects like “wasm-eel” with numerous preset files. This shows active experimentation with new presets and WASM-based functionality, as well as performance tests (e.g., the “speed” subdirectory).
– “loaders”: Contains custom loader scripts (e.g., assemblyscript.js) that probably handle dynamic imports or WASM module initialization.
– “config” and “netlify.toml”: Provide settings for building and deployment.
• Observed Patterns:
– Separation between audio processing, visual rendering (WebGL and shaders), equations/preset management, and experimental presets.
– Use of experiments to maintain various presets and blending techniques, the layering of visual effects using WebGL shader pipelines, and integration with different external Web APIs and frameworks.
Additional Details
• Be very detailed in capturing the entire flow: how presets can be loaded, blended (the visualizer.loadPreset function), and how the renderer resizes and renders new frames.
• Integration with external tools (the README lists integrations with Webamp, browser extension, etc.), though not part of the core library, they provide context for ecosystem use.