EZ Web Audio / createBeatTrack
Function: createBeatTrack()
Call Signature
createBeatTrack(
inputs,opts?):Promise<BeatTrack>
Defined in: packages/core/src/index.ts:658
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
inputs
Array of audio file URLs, ArrayBuffers, Blobs, or Files to load as sound sources
opts?
Optional BeatTrack configuration
Returns
Promise<BeatTrack>
Promise resolving to a BeatTrack instance
Throws
If any audio file cannot be loaded or decoded
Example
import { createBeatTrack } from 'ez-web-audio'
// From URLs
const kick = await createBeatTrack(['kick1.mp3', 'kick2.mp3', 'kick3.mp3'])
// From mixed inputs (URLs, ArrayBuffers, Files)
const snare = await createBeatTrack([snareUrl, snareBuffer, snareFile])
// 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()Call Signature
createBeatTrack(
audioContext,inputs,opts?):Promise<BeatTrack>
Defined in: packages/core/src/index.ts:659
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
audioContext
BaseAudioContext
inputs
Array of audio file URLs, ArrayBuffers, Blobs, or Files to load as sound sources
opts?
Optional BeatTrack configuration
Returns
Promise<BeatTrack>
Promise resolving to a BeatTrack instance
Throws
If any audio file cannot be loaded or decoded
Example
import { createBeatTrack } from 'ez-web-audio'
// From URLs
const kick = await createBeatTrack(['kick1.mp3', 'kick2.mp3', 'kick3.mp3'])
// From mixed inputs (URLs, ArrayBuffers, Files)
const snare = await createBeatTrack([snareUrl, snareBuffer, snareFile])
// 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()