Tonejs / Tone.js

A Web Audio framework for making interactive music in the browser.
https://tonejs.github.io
MIT License
13.52k stars 983 forks source link

Unable to access Player by name #916

Closed firelex closed 3 years ago

firelex commented 3 years ago

Issue no. 1: The documentation says that individual players within Tone.Players() can be accessed by the name "as defined in the constructor object". But it's not possible to set a name using the constructor.

Issue no. 2: When I try to add players individually using Tone.Players().add() and specify a name, the moment I add a second player, I get A buffer with that name already exists on this object.

To reproduce issue no. 2:

a = new Tone.Players(); a.add({name: '1', url: '2'}); a.add({name: '2', url: '3'});

Can you please help?

Thanks.

tambien commented 3 years ago

Players.add does not take an object like you're passing in.

Building off of your example, the API should be:

a = new Tone.Players();
a.add('1', '2')
a.add('2', '3')

I'll add an additional example to make that more clear.