Open eddydong opened 7 months ago
Or let me ask this way: can we feed the new Sampler() function a set of buffered audio files, instead of the url every time? If that's possible, we can load the audio files in the buffer first and then anytime when we need a new instance of this instrument, we just new it from the buffer.
I am pretty sure Tone does this already: https://github.com/Tonejs/Tone.js/blob/c313bc6/Tone/instrument/Sampler.ts#L14 but I personally didn't try it yet.
I am pretty sure Tone does this already: https://github.com/Tonejs/Tone.js/blob/c313bc6/Tone/instrument/Sampler.ts#L14 but I personally didn't try it yet.
Thanks for the info! Unfortunately I don't know much about the TS code... Can you please help write a few lines in JS illustrating how to do 1) load audio files into a whatever buffer, and 2) new Samplers from the buffer? Thanks very much!!!
I could, but what you are doing is most likely 'premature optimization'. Bandwidth is cheap and the browser cache will take care of all of this for you - this is what it's for. So: if this type of optimization is still very important to you, then your project is of professional nature, and in this case you are welcome to email me for a quote.
Say I have 2 tracks of the same piano instrument. I new-ed 2 Sampler( url:{xxx}, function(){} ), each for a track, with the same "url:{xxx}" parameter since they are the same instrument.
The issue is: each time it will download the audio files (referred to by the "url:{xxx}" parameter) from the server. I believe this is a waste of server bandwidth - since the 2 set of audio files are identical, isn't there a way that we just download one set of the audio files and let the 2 sampler instances share it?