Parse SoundFont
These examples mainly focus on extracting data.
SoundFont3
constructor expects a Uint8Array
binary.
With Node.js
typescript
import { readFileSync } from 'fs'
import { SoundFont3 } from 'SoundFont3'
// Do not specify any encoding
const soundFontBuffer = readFileSync('soundFontFile.sf3')
const soundFont3 = new SoundFont3(soundFontBuffer)
With fetch
typescript
import { SoundFont3 } from 'SoundFont3'
fetch('https://example.com/my-soundfont.sf3')
.then((body) => body.arrayBuffer())
.then((arrayBuffer) => {
// Typecast ArrayBuffer to Uint8Array
const soundFontBuffer = new Uint8Array(arrayBuffer)
const soundFont3 = new SoundFont3(soundFontBuffer)
})
Read metadata
TypeScript
const metaData = soundFont3.metaData
Example output:
{
version: '2.1',
soundEngine: 'EMU8000',
name: 'Yamaha-Grand-Lite',
rom: undefined,
romVersion: undefined,
creationDate: undefined,
author: undefined,
product: undefined,
copyright: 'Creative Commons',
comments: undefined,
createdBy: 'Polyphone'
}