Tone.js
Tone.js copied to clipboard
extend Sampler urlMap with parameters for loopStart, loopEnd and transpose
I am working on a library to easily transfer Ableton Live data to Tone.Js and Web Audio. If some extra parameters are added to the Sampler file mapping, this would make things a lot easier to transport data from Ableton Drum Racks, Simplers and Samplers.
As a first step, I have an Ableton Drum Rack in mind. I assign different samples to different notes next to each other, C1 is kick, C#1 is a stick, D1 a snare drum, etc. But then I want to pitch up my snare sample, for instance: the snare is always on the D1, but I want the original sample to sound 3 semitones higher, every time, and of course I might have a tom sample on the F1, which has nothing to do with the fact that the snare on D1 is pitched up 3 semitones. It is a technique that I use a lot in Ableton, cut out short samples from another track and transpose it to another pitch, to make completely new sounds with it. It would be nice to transfer it very easily to Web Audio with something like this:
Tone.Sampler.new('C1': {file: 'kick.wav'}, 'D1': {file: 'snare.wav', transpose: '+3'}, 'F1': {file: 'example.wav, transpose: '-14', start_position: '1.235', end_position: '2.34'} )
As far as I understand your code, it would be rewriting the the urlMap definition in Sampler.js on lines 31ff to accept 3 extra parameters(not only url, but also loopStart, loopEnd and transpose). And extend the Tone.BufferSource on lines 122ff with the parameters for loopStart and loopEnd and recalculate the playBackRate taking into account the transpose parameter.
However, I am not proficient enough in Javascript to write this myself.
Here is the preliminary Ruby library around Tone.js, where I parse Ableton data to be played with Tone.js
https://github.com/hilkeros/raudio-test
Thanks!
Thanks for the feature request. translating from Ableton to Tone sounds awesome.
i think that having the ability to add loopable points to Sampler would be good in situations like importing soundfont-style instruments into Sampler. giving it the ability to support infinite sustained notes through well-placed loop points.
it sounds like your situation is slightly different and Tone.Players might be a better fit since you aren’t using the auto repitching the Sampler provides to fill in missing notes for mulitsampled instruments. Player already has the ability to set loop points and you can adjust the pitch of the sample by changing the playbackRate property.
PRs welcome if you start a patch which adds looping and loop points to Sampler! also excited to see how Raudio progresses
I looked at the Tone.Players, but I miss the tone triggerAttackRelease method over there to make it work with the midi clips that I translated into Tone.Parts.
Currently I am trying to transform the urlMap of Tone.Sampler into a hash, also containing the loopStart and loopEnd values and passing those extra values into the Tone.BufferSource, but at this moment I am indeed a bit stuck at the repitching part where
var buffer = this._buffers.get(closestNote); also references to the Tone.Buffers class, which can only take the urls as an argument. I'll see if I can find a solution today. Otherwise I will have to postpone it to after the Web Audio Conference ...
Player uses start and stop instead of triggerAttack/triggerRelease. Try that out
Given this issue is open - I assume that loopPoints within the audio is not yet supported ? Interested in adding it in.