pointillistic to pattern

Recommended Posts

Hi, I'am looking for a method to pick more and more elements from a list (that are more or less equally distributed):

```(1/4 -1/4 1/4 -3/8 1/4 -1/4 1/4 -3/8)
(1   0    1   0    1   0    1   0   )
1.pass--> (-1/4 -1/4 -1/4 -3/8 1/4 -1/4 -1/4 -3/8)
(0    0    0    0    1   0    0    0   )
2.pass--> (-1/4 -1/4 1/4 -3/8 -1/4 -1/4 1/4 -3/8)
(0    0    1   0    0   0     1   0   )
3.pass--> (1/4 -1/4 -1/4 -3/8 1/4 -1/4 1/4 -3/8)
(1   0    0    0    1   0    1   0   )
4.--> see orginal list```

thanks for any hints

best

ole

Share on other sites

sorry, but i don't understand what you are looking for...

you want to pick all elements > 0?

or change rests into lengths and lengths into rests? like a kind of a filter?

Share on other sites

Thank you for the quick reply!

My material is this pattern:

`(1/4 -1/4 1/4 -3/8 1/4 -1/4 1/4 -3/8)`

now I want to create  all variations of this pattern ranging from one beat:

```(-1/4 -1/4 -1/4 -3/8 1/4 -1/4 -1/4 -3/8)
(0    0    0    0    1   0    0    0   )```

to four beats (orginal pattern)

Share on other sites

```(progn

;; your list with EVEN-length!!! (necessary for length/rest-structure) -> starting with all values as rests
(setf seq '(-1/4 -1/4 -1/4 -3/8 -1/4 -1/4 -1/4 -3/8))

;; produces all combinations of 0/1 with length of (/ (length seq) 2) => the number of your ON/OFF-vals (switching values, not the rests!)
(setf all-basic-binary-combinations (loop for i from 0 to (binary-to-decimal (loop repeat (/ (length seq) 2) collect 1))
with val = '()
do (setf val (decimal-to-binary i))
collect (append (loop repeat (- (/ (length seq) 2) (length val))
collect 0) ;; necessary "to fill" the seq-length
val)))

;; combines the 1/0-list with 0 (for the unchanging rests)
(setf binary-seq-completed (loop for x in all-basic-binary-combinations
collect (loop for y in x
append (list y 0))))

;; maps the "binary-seq-completed" on your values
(loop for k in binary-seq-completed
collect (loop
for l in k
for value in seq
when (= l 1)
collect (abs value)
else collect value)))```

...is perhaps a way to get the output?

...evaluate...

...or press CMD2 -> so you see the rhythm-structure...

...in this version the gen-structure is based on the "BINARY-incf", if you want a RND-version, just "RND-ORDER" the list...

packed in a function:

```
(defun all-variants (seq)

(let ((all-basic-binary-combinations)
(binary-seq-completed))

;; produces all combinations of 0/1 with length of (/ (length seq) 2) => your ON/OFF (switching values)
(setf all-basic-binary-combinations (loop for i from 0 to (binary-to-decimal (loop repeat (/ (length seq) 2) collect 1))
with val = '()
do (setf val (decimal-to-binary i))
collect (append (loop repeat (- (/ (length seq) 2) (length val))
collect 0)
val)))

;; combines the 1/0-list with 0 (for the unchanging rests)
(setf binary-seq-completed (loop for x in all-basic-binary-combinations
collect (loop for y in x
append (list y 0))))

;; maps the "binary-seq-completed" on your values
(loop for k in binary-seq-completed
collect (loop
for l in k
for value in seq
when (= l 1)
collect (abs value)
else collect value))))

(all-variants '(-1/4 -1/4 -1/4 -3/8 -1/4 -1/4 -1/4 -3/8))```

Share on other sites

ALL-VARIANTS2

**********************

"extended version" -> if you want to have pairs of rest/length or if EVERY value could be changed

```(defun all-variants2 (seq &key (length/rest 'nil))

(let ((all-basic-binary-combinations)
(binary-seq-completed))

;;;decides if should work with pairs of length/rests
(if (equal length/rest 't)
;; produces all combinations of 0/1 with length of (/ (length seq) 2) => your ON/OFF (switching values)
(progn
(setf all-basic-binary-combinations (loop for i from 0 to (binary-to-decimal (loop repeat (/ (length seq) 2) collect 1))
with val = '()
do (setf val (decimal-to-binary i))
collect (append (loop repeat (- (/ (length seq) 2) (length val))
collect 0)
val)))

;; combines the 1/0-list with 0 (for the unchanging rests)
(setf binary-seq-completed (loop for x in all-basic-binary-combinations
collect (loop for y in x
append (list y 0)))))

;;;EVERY val will be switched
(setf binary-seq-completed (loop for i from 0 to (binary-to-decimal (loop repeat (length seq) collect 1))
with val = '()
do (setf val (decimal-to-binary i))
collect (append (loop repeat (- (length seq) (length val))
collect 0)
val))))

;; maps the "binary-seq-completed" on your values
(loop for k in binary-seq-completed
collect (loop
for l in k
for value in seq
when (= l 1)
collect (abs value)
else collect value))))

(all-variants2 '(-1/4 -1/4 -1/4 -3/8 -1/4 -1/4) :length/rest 't)
(all-variants2 '(-1/4 -1/4 -1/4 -3/8 -1/4 -1/4) :length/rest 'nil)```

Share on other sites

Thank you so much for your bunch of solutions! I'll have to chew a while examine them, than I'll get back..

best

ole

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
• Browser

• Video Gallery

• Lessons