EZ Web Audio / createFont
Function: createFont()
createFont(
url):Promise<Font>
Defined in: index.ts:407
Create a Font from a soundfont file.
A Font is a collection of sampled notes (like a piano or organ) that can be played by note name. Soundfont files contain base64-encoded audio samples for each note.
Parameters
url
string
URL to the soundfont JavaScript file
Returns
Promise<Font>
Promise resolving to a Font instance
Throws
If the soundfont cannot be loaded or decoded
Example
typescript
import { createFont } from 'ez-web-audio'
// Load a piano soundfont
const piano = await createFont('acoustic_grand_piano-mp3.js')
// Play notes by name
piano.play('C4') // Middle C
piano.play('E4') // E above middle C
piano.play('G4') // G above middle C