EZ Web Audio / createBeatTrack
Function: createBeatTrack()
createBeatTrack(
urls,opts?):Promise<BeatTrack>
Defined in: index.ts:284
Create a BeatTrack for drum machine-style rhythmic patterns.
A BeatTrack manages a sequence of Beats, where each Beat can be active (plays sound) or inactive (rest). Sounds are played in round-robin fashion to prevent overlapping.
Parameters
urls
string[]
Array of audio file URLs to load as sound sources
opts?
BeatTrackOptions
Optional BeatTrack configuration
Returns
Promise<BeatTrack>
Promise resolving to a BeatTrack instance
Throws
If any audio file cannot be loaded or decoded
Example
typescript
import { createBeatTrack } from 'ez-web-audio'
// Create a kick drum track with 3 sounds for round-robin
const kick = await createBeatTrack(['kick1.mp3', 'kick2.mp3', 'kick3.mp3'])
// Set up a 4/4 beat pattern (kick on 1 and 3)
kick.beats[0].active = true // Beat 1
kick.beats[2].active = true // Beat 3
// Play the pattern
kick.play()