musicality.compose

as-coll

(as-coll val-or-coll)
returns val-or-coll if coll, or [val-or-coll] if not

bin->rhy

(bin->rhy note-or-notes vel-or-vels dur-or-durs bin-seq)(bin->rhy n-or-ns v-or-vs bin-seq)(bin->rhy n-or-ns bin-seq)
Converts a seq of '.'s and 'x's to seq of notes and []s.
Replaces 'x's with successive notes in n-or-ns, likewise for vs and ds

chord

(chord dur vel ns)(chord vel ns)(chord ns)
pairs notes with dur and vel and flattens. defaults to whole note (:1|1) and 64 if dur or vel are not supplied

euclid

(euclid k n r)(euclid k n)
Evenly distribute K beats among N subdivisions.
Rotates the seq by r.
Beats are x and .
(euclid 2 6) -> (x . . x . .)
(from https://gist.github.com/virtualtam/9d1df5fc6d38c6fc5c3d)

expand

(expand mult rhy)

fill

(fill n v coll)(fill n v)(fill n)
returns a coll of length n filled with v, leaving existing values untouched

int->pc

(int->pc x)
returns pitch-class keyword corresponsing to int

map-if-not-empty

(map-if-not-empty fn coll)
Applies fn to each member of coll that is not empty.

map-if-num

(map-if-num fn coll)
Applies fn to each member of coll that is a number. Leaves non-numbers unchanged.

map-if-one

(map-if-one fn coll)
Applies fn to each member of coll that == 1

merge-seqs

(merge-seqs max-len & seqs)
merges the beats and sub-beats of each sequence, using the length of the longest sequence or max-len.
seqs can be lazy/infinite but sub-beats cannot (yet?)

pc->int

returns int corresponding to pitch-class keyword

pc-rotate

(pc-rotate pc rot)
rotates pc in pitch-class-space by rot

pcs

pitch-class keywords

pcs-cycle-dn

a lazy cycle of pitch-classes in descending order

pcs-cycle-up

a lazy cycle of pitch-classes in ascending order

pcs-ordered

pitch-class keywords in order

repeat

(repeat reps x)

rotate-seq

(rotate-seq n s)
rotates sequence by n. given n=2 and s=[a b c d e] return [c d e a b]. given n=-2 return [d e a b c]

with-vel

(with-vel dur vel ns)(with-vel vel ns)(with-vel ns)
pairs notes with vel and dur. if note is not a number, it is left unchanged. vel defaults to 64