# Shuffle Elements

## Recommended Posts

Dear, All

I need a function for shuffle elements. A function similar to URN in Pure Data.

The scenario:

1) I have a list of durations:

s s -s s s -s -s -s e -s s -s s -e e -e -e s -s

2) The lenghts together form a 6/4 timesignature or a 12/8.

3) Just repeating the rhythm is BORING !

4) I need variations, but I want to still sum 12/8 or 6/4.

5) So, I need to shuffle this elements, without changing the total of the sum of lenghts.

TWO APPROACHES:

1) RANDOM - How to randomize, not like the random sample, but, using each element JUST ONCE,

like an Hamiltonian Path ?

(Actually I don't like to random things, because I feel like I'm not composing...) I'm a control Freak ! Sorry !

2) RANDOM2 - How can I sort from sublists of the same rhtyhm EACH LIST MUST APPEAR JUST ONCE !

This approach sounds more controled

3) MY PREFERED ! How to split the lenght list, and make up combinations of sublists (absolutely controlled) ?

Like this:

COMPLETE LIST - (s s -s s s -s -s -s e -s s -s s -e e -e -e s -s)

SUB LISTS 1 (s s -s)

SUB LISTS 2 (s s -s -s )

SUB LISTS 4 (-s e -s s -s)

SUB LISTS 5 (s -e e -e)

SUB LISTS 6 (-e s -s)

Maybe I can Initialize each one as a setf

Brute force method...

(setf subleng1 ' (s s -s))

(setf subleng2  '(s s -s -s ))

(setf subleng3 '(-s e -s s -s))

(setf subleng4 '(s -e e -e))

ETC....

And after that use assemble-seq to the lenghts ?

Or assemble-seq is just for joining sections of the composition ?

Any help ?

Thank you all !!!

Best,

Julio

##### Share on other sites

Maybe Sort-series ?

Getting closer

```(sort-series '(a d) '((4 6 2 3) (8 6 9 2) (4 6 3 7) (6 4 7 1))
:section '(0 2 3))
=> ((2 3 4 6) (8 6 9 2) (3 4 6 7) (7 6 4 1))```

##### Share on other sites

rnd-order !!!

oh yeah !

7 minutes ago, JulioHerrlein said:

rnd-order !!!

oh yeah !

rnd-unique

yes

S.

##### Share on other sites

I'm trying this now...

Workout from Nigel Morgan book

But need some help..

Rhythm list

```(setf r1 '(s s -s)
r2 '(s s -s)
r3 '(-s -s e -s)
r4 '(s -s s -e)
r5 '(e -e -e s -s))

;; shuffling 10 times
(let ((r-lis nil))
(dotimes (i 10)
(push (rnd-unique 5'(1 2 3 4 5)) r-lis))
r-lis)

;; Here is the problem: no succes to assemble
(setf r-list (assemble-section 'r r-lis))

> Error: "3" doesn't match array element type of "r
While executing: ccl::concat-to-simple*, in process Listener-1(6).```

Best,

Julio

##### Share on other sites

```(setf r1 '(s s -s)
r2 '(s s -s)
r3 '(-s -s e -s)
r4 '(s -s s -e)
r5 '(e -e -e s -s))

You need to flatten the list first:

(setf seq
(flatten
(let ((r-lis nil))
(dotimes (i 10)
(push (rnd-unique 5 '(1 2 3 4 5)) r-lis))
r-lis)))

(setf r-list (assemble-section 'r seq))```

You could do that:

```(setf r1 '(s s -s)
r2 '(s s -s)
r3 '(-s -s e -s)
r4 '(s -s s -e)
r5 '(e -e -e s -s))

(setf seq (flatten (gen-eval 10 '(rnd-unique 5 '(1 2 3 4 5)))))
(setf r-list (assemble-section 'r seq))```

##### Share on other sites

6 minutes ago, opmo said:

(setf r1 '(s s -s) r2 '(s s -s) r3 '(-s -s e -s) r4 '(s -s s -e) r5 '(e -e -e s -s)) You need to flatten the list first: (setf seq (flatten (let ((r-lis nil)) (dotimes (i 10) (push (rnd-unique 5 '(1 2 3 4 5)) r-lis)) r-lis))) (setf r-list (assemble-section 'r seq))

PERFECT !!!

9 minutes ago, opmo said:
```
(setf r1 '(s s -s)
r2 '(s s -s)
r3 '(-s -s e -s)
r4 '(s -s s -e)
r5 '(e -e -e s -s))

You need to flatten the list first:

(setf seq
(flatten
(let ((r-lis nil))
(dotimes (i 10)
(push (rnd-unique 5 '(1 2 3 4 5)) r-lis))
r-lis)))

(setf r-list (assemble-section 'r seq))```

You could do that:

```
(setf r1 '(s s -s)
r2 '(s s -s)
r3 '(-s -s e -s)
r4 '(s -s s -e)
r5 '(e -e -e s -s))

(setf seq (flatten (gen-eval 10 '(rnd-unique 5 '(1 2 3 4 5)))))
(setf r-list (assemble-section 'r seq))```

More Elegant !

8 minutes ago, opmo said:
```
(setf r1 '(s s -s)
r2 '(s s -s)
r3 '(-s -s e -s)
r4 '(s -s s -e)
r5 '(e -e -e s -s))

You need to flatten the list first:

(setf seq
(flatten
(let ((r-lis nil))
(dotimes (i 10)
(push (rnd-unique 5 '(1 2 3 4 5)) r-lis))
r-lis)))

(setf r-list (assemble-section 'r seq))```

You could do that:

```
(setf r1 '(s s -s)
r2 '(s s -s)
r3 '(-s -s e -s)
r4 '(s -s s -e)
r5 '(e -e -e s -s))

(setf seq (flatten (gen-eval 10 '(rnd-unique 5 '(1 2 3 4 5)))))
(setf r-list (assemble-section 'r seq))```

Thanks a lot, Janusz !

## 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.

×
×

• Lessons