Arbitrary envelopes

I’d like to do the following:

  1. play first 0.1s of sample A from t=0 to t=0.1
  2. play first 0.1s of sample B from t=0.1 to t=0.2
  3. now continue sample A eg. from t=0.2 to t=0.3 of the sample.

In other words , I’d like to have an envelope for sample A where its on for t=0-0.1 , off for t=0.1-0.2, on for t=0.2-0.3 etc and similar for sample B.

I see that there’s an ADSR envelope - is there something more general , e.g. where I modulate sample by an arbitrary envelope, or equivalently multiply sample A by a square wave that’s 1 for 0-0.1s, 0 for 0.1-0.2s, etc.

I would like to avoid breaking the original samples into 0.1s fragments , which I blv. would be an alternative way to accomplish this .

By ‘avoid breaking the original samples’, do you mean avoid creating new samples by saving smaller parts of them as entire new ones?

If you’re happy with just telling Sonic Pi to play smaller segments of the samples directly, there are two opts you can use to specify where in the sample to play: start: and finish:. See Chapter 3.5 of the Sonic Pi tutorial (Or the version in the app itself) for more details :slight_smile:

1 Like

As far as arbitrary envelopes - there is no simple built-in way to do this with Sonic Pi commands. On the wishlist is a way to provide a custom wave shape and apply that as an envelope to any of the sample’s modulatable opts. If and when we get to that point is not certain yet though :sweat_smile:

1 Like

Yes start and finish solves it, many thanks . I just ran across an explanation here