danigb / smplr

A web audio sampler instrument
https://danigb.github.io/smplr/
186 stars 19 forks source link

loading mp3 file #59

Closed shahraship closed 9 months ago

shahraship commented 9 months ago

This example doesn't seem right: const sampler = new Sampler(audioContext, { duh: "duh-duh-ah.mp3" }); sampler.start({ note: "duh" loop: true loopStart: 1.0, loopEnd: 9.0, });

It's throwing this error: Object literal may only specify known properties, and 'duh' does not exist in type 'Partial'.ts(2353)

I've an MP3 file I would like to know how I can load it.

danigb commented 9 months ago

I think is a problem with the documentation: you need to pass the file url inside a buffers object:

// this works
const sampler = new Sampler(audioContext, { buffers: { duh: "duh-duh-ah.mp3" }}); 
// this doesn't work
const sampler = new Sampler(audioContext, { duh: "duh-duh-ah.mp3" });