This repository contains a step-by-step tutorial for learning the Web Audio API and music generation in the browser.
This project demonstrates how to create browser-based music generation applications using different approaches:
- Step 1: Basic audio generation using Web Audio API oscillators
- Step 2: Enhanced music generator with customizable parameters
- Step 3: AI-powered music generation using Magenta.js
A simple introduction to Web Audio API with:
- AudioContext creation
- Oscillator and gain node usage
- Basic note generation with random pitches from a C major scale
Building on Step 1 with:
- UI controls for all audio parameters
- Multiple oscillator types (sine, square, sawtooth, triangle)
- Adjustable duration, volume, interval, and note count
- Option to play individual notes or generate sequences
An introduction to machine learning-based music generation:
- Using Google's Magenta.js library
- Loading pre-trained MusicVAE models
- Generating and playing musical sequences
Each step is contained in its own directory with all necessary files:
- Open any of the
step0X/index.html
files in a modern web browser - Click the "Generate" button to create music
- Experiment with different parameters (in Step 2)
This tutorial requires a modern browser with Web Audio API support, such as:
- Chrome
- Firefox
- Safari
- Edge