Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add loop option to Sampler #1207

Open
andreasplan8 opened this issue Sep 13, 2023 · 1 comment
Open

Add loop option to Sampler #1207

andreasplan8 opened this issue Sep 13, 2023 · 1 comment

Comments

@andreasplan8
Copy link

It would be nice to be able to have the sources of the sampler looping. That would allow the sampler to be used for instruments like pads, organs etc.

It's a simple change allowing a loop property to be passed in the constructor options and then set that property for each source when triggering notes.

@joeqj
Copy link

joeqj commented May 13, 2024

Just came across this limitation as well, thanks for suggesting it. Figured out a good workaround for your pads - if you set the sampler attack and release to a slow enough value and then send it through enough reverb and/or delay then you can trigger the synth with a setInterval function and it sounds endless, here's my code that works well:

const reverb2 = new Tone.Reverb({
    decay: 1,
    wet: 1,
  }).toDestination();

  const filter = new Tone.Filter({
    type: "bandpass",
    frequency: params.cutoff,
    rolloff: -12,
  });

  const reverb = new Tone.Reverb({
    decay: 1,
    wet: 1,
  });

  const sampler = new Tone.Sampler({
    urls: {
      C3: "pad.wav",
    },
    baseUrl: "/",
    volume: 0,
    attack: 4,
    release: 4,

    onload: () => {
      setInterval(() => {
        sampler.triggerAttackRelease(padKeys, Infinity);
      }, 2000);
    },
  });

  sampler.chain(reverb, filter, reverb2);

I've set the interval every 2 seconds here as my pad sample is around 4 seconds.

Don't know how this would sound with an organ so let me know if you figure it out :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants