Vagibeats API
AI-powered procedural music generation for the web. Create terrible, wonderful 8-bit background music with consistent seed-based generation. Perfect for adding ambiance to any Vagibond application.
What you can build
- Retro websites - Add 90s-style background music to your Vagipages
- Game prototypes - Procedural soundtracks that never repeat
- Sound effects - Jingles for success, error, and notification events
- Ambiance - Background music for any occasion (sad, epic, spooky, cheesy)
Quickstart
Get up and running with Vagibeats in under a minute.
1. Include the script
<script src="https://vagibeats.vagibond.com/vagibeats-core.js"></script>
2. Start playing music
// Play music with a seed and style Vagibeats.play({ seed: 'my-page', // Consistent music per seed style: 'cheesy' // cheesy | spooky | epic | sad | lofi | circus }); // Stop playing Vagibeats.stop(); // Toggle on/off Vagibeats.toggle({ seed: 'my-page', style: 'epic' });
Music Styles
Vagibeats offers 6 distinct musical styles, each with its own scale and chord progression:
| Style | Description | Tempo | Best For |
|---|---|---|---|
cheesy |
Happy elevator music (C major) | 800ms | Default, corporate parody |
spooky |
Haunted house vibes (C minor/dim) | 1000ms | Horror, magic shows |
epic |
Action movie intensity (pentatonic) | 600ms | Dramatic moments |
sad |
Melodramatic despair (natural minor) | 1200ms | Tragic content |
lofi |
Chill beats to code to (jazz scale) | 900ms | Relaxed browsing |
circus |
Whimsical chaos (whole tone) | 500ms | Comedy, absurdist |
play(options)
Start playing procedurally generated music.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
seed | string | 'vagibeats' | Seed for consistent random music |
style | string | 'cheesy' | Music style (see table above) |
Returns
boolean - true if music started successfully, false if already playing or audio not supported.
stop()
Stop playing music and clean up audio resources.
toggle(options)
Toggle music on or off. If stopped, starts with the provided options. If playing, stops.
Returns
boolean - The new playing state (true if now playing, false if stopped).
playJingle(type)
Play a short sound effect jingle.
Available Jingles
| Type | Description |
|---|---|
'success' | Ascending happy notes (form submitted, action complete) |
'error' | Descending sad notes (error occurred) |
'notification' | Two-note ping (new message) |
'levelup' | Triumphant fanfare (achievement unlocked) |
// Play success jingle when form is submitted form.addEventListener('submit', () => { Vagibeats.playJingle('success'); }); // Play error jingle on validation failure if (!isValid) { Vagibeats.playJingle('error'); }
playNote(freq, options)
Play a single note at a specific frequency.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
freq | number | - | Frequency in Hz (e.g., 440 for A4) |
options.waveform | string | 'square' | Oscillator type: square, sine, triangle, sawtooth |
options.volume | number | 0.15 | Volume level (0-1) |
options.duration | number | 0.3 | Duration in seconds |
Examples
Vagipage with Background Music
<button id="music-btn">🎵</button> <script src="https://vagibeats.vagibond.com/vagibeats-core.js"></script> <script> // Autoplay on first interaction (required by browsers) document.addEventListener('click', () => { Vagibeats.play({ seed: 'tarbaj-magician', style: 'spooky' }); }, { once: true }); // Toggle button document.getElementById('music-btn').onclick = () => Vagibeats.toggle(); </script>
Create a Music Button Automatically
// Creates a styled button with autoplay behavior const btn = Vagibeats.createMusicButton({ seed: 'my-page', style: 'epic', autoplay: true }); document.body.appendChild(btn);
Changelog
- 6 music styles: cheesy, spooky, epic, sad, lofi, circus
- Seed-based procedural generation for consistent awful music
- Jingle system for sound effects
- Single-note playback for custom sounds
- Utility function to create styled music buttons