defaultxr / cl-patterns

Library for writing patterns to generate or process (a)musical sequences of mathematically (un)related (non-)compound values in Lisp.

Home Page:https://w.struct.ws/cl-patterns

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

stretch doesn't work

TatriX opened this issue · comments

Hi!
Consider the following example:

Pdef(\stretch, Pbind(\midinote, 60, \stretch, 1/2)).play;

This works as expected and generates events twice per beat.

Similar example doesn't seem to be working:

(play
 (pb :stretch
   :instrument :default
   :midinote 60
   :stretch 1/2))

stretch value does nothing.

The stretch special key documentation that you linked to is for one of pmeta's special keys, meaning it only works when used inside a pmeta. stretch is not implemented as a special key for a regular pbind because the same effect is achievable simply by doing

(pbind
 ...
 :dur (p* (pk :dur) 1/2)
 ...)

or similar, and to be honest, I'm actually not sure what the use of \stretch in regular SuperCollider patterns is. Is it really that useful as a shorthand? SuperCollider's documentation says that the actual sustain of the event is calculated by multiplying dur, legato, and stretch. But I don't really feel like stretch adds anything conceptually that is more clear than (p* (pk :dur) ...) is.

I also think the number of special keys in basic patterns like pbind should probably be kept to a minimum so users are less likely to trigger undesired behavior in patterns without realizing it, especially if they could conceivably want to use those key names as parameter names in synths, for example... Which is certainly conceivable in the case of stretch being as "timestretching" is a common concept in synthesis.

Probably the special keys supported by SuperCollider should be listed in sc-differences.org so we have a central location documenting the differences between the two systems.

The reason I wanted to use :stretch is because I was recreating one of the Bach's preludes and it's easier to reason about durations in musical terms for that task.
For instance, if you have 4/4 time signature then quarter note duration is "1" beat, but I still want to write it as 1/4:

(play
 (pb :stretch
   :stretch 4 ; 4/4 time signature
   :instrument :tri
   :midinote 60
   :dur (pseq (list 1/4 1/8 1/8 1/16 3/16 1/4))))

The solution I've used was to just scale the tempo, but I guess (p* 4 ..) is also fine.

It's not always easy to use p*, but it's not very hard to work it around:

(play
 (pb :stretch
   :instrument :saw
   :embed (pt (:midinote 60 :dur 1/16)
              (60 1/4)
              (64 1/8)
              (67 1/4)
              (71 3/8))
   :dur (p* (pk :dur) 4)))