# code gen-sieves

## Recommended Posts

have fun!

andré

;;; TWO SIEVE-generators
;;; simple and multiple (the simple-function is part of multiple)

;;;;;;;;;;;;;;;;;;;;;;;;;

(defun gen-sieve (ambitus.omn intervals)
(midi-to-pitch
(loop
with ambitus.midi = (pitch-to-midi ambitus.omn)
with interval.cnt = -1
for pitch = (first ambitus.midi) then (setq pitch (+ (nth interval.cnt intervals) pitch))
when (<= pitch (second ambitus.midi))
collect pitch into bag
else return bag

do (incf interval.cnt)
when (= interval.cnt (length intervals))
do (setq interval.cnt 0))))

(gen-sieve '(c4 g7) '(2 1))

;;;;;;;;;;;;;;;;;;;;;;;;;

(defun gen-multiple-sieve (sieve-rules)
;sieve-rules => '((ambitus.omn intervals) (ambitus.omn intervals) (ambitus.omn intervals))
(midi-to-pitch
(sort (remove-duplicates
(loop for i in sieve-rules
append (pitch-to-midi (gen-sieve (first i) (second i)))))
#'<)))

(gen-multiple-sieve '(((c4 g7) (2 1 12))
((c1 g7) (3 5))))

##### Share on other sites
(make-scale 'c4 29 :alt '(2 1))

JP

##### Share on other sites

of course...i knew that... but:

yours is not with AMBITUS and not with complex-sieves, and not in ONE function.

and, as all the time, i wanted to do it for myself.

##### Share on other sites

I truly love your contribution to the Forum and Opusmodus.

Two of your functions will be part of the next release.

GEN-SYMMETRICAL

(gen-symmetrical 24 '(1 2 3 4 5 6))
=> (5 2 6 2 3 2 1 5 2 3 5 4 4 5 3 2 5 1 2 3 2 6 2 5)

(gen-symmetrical 24 '(1 2 3 4 5 6) :repeat t)
=> (1 1 3 1 1 2 4 6 4 5 5 2 2 5 5 4 6 4 2 1 1 3 1 1)

(gen-symmetrical '(6 8 12) '(1/16 1/32 1/8))
=> ((1/8 1/32 1/8 1/8 1/32 1/8)
(1/16 1/8 1/16 1/32 1/32 1/16 1/8 1/16)
(1/8 1/32 1/16 1/32 1/16 1/32 1/32
1/16 1/32 1/16 1/32 1/8))

GEN-MULTISYMMETRICAL

(gen-multisymmetrical 8 '(1 2 3 4 5 6))
=> (2 3 2 1 1 2 3 2 4 5 2 5 5 2 5 4 1 5 4 6 6 4
5 1 6 5 3 1 1 3 5 6 6 5 3 1 1 3 5 6 1 5 4 6
6 4 5 1 4 5 2 5 5 2 5 4 2 3 2 1 1 2 3 2)

(gen-multisymmetrical 8 '(1 2 3 4 5 6) :repeat t)
=> (1 1 2 4 4 2 1 1 6 4 5 5 5 5 4 6 2 2 2 5 5 2
2 2 5 5 5 3 3 5 5 5 5 5 5 3 3 5 5 5 2 2 2 5
5 2 2 2 6 4 5 5 5 5 4 6 1 1 2 4 4 2 1 1)

(gen-multisymmetrical '(6 8 12) '(1/16 1/32 1/8))
=> ((1/8 1/32 1/16 1/16 1/32 1/8 1/16 1/32 1/8 1/8
1/32 1/16 1/16 1/32 1/8 1/8 1/32 1/16 1/16 1/32
1/8 1/8 1/32 1/16 1/16 1/32 1/8 1/8 1/32 1/16
1/8 1/32 1/16 1/16 1/32 1/8)
(1/32 1/8 1/32 1/16 1/16 1/32 1/8 1/32 1/16 1/32
1/8 1/16 1/16 1/8 1/32 1/16 1/32 1/8 1/16
1/8 1/8 1/16 1/8 1/32 1/8 1/32 1/8 1/32 1/32
1/8 1/32 1/8 1/8 1/32 1/8 1/32 1/32 1/8 1/32
1/8 1/32 1/8 1/16 1/8 1/8 1/16 1/8 1/32 1/16
1/32 1/8 1/16 1/16 1/8 1/32 1/16 1/32 1/8
1/32 1/16 1/16 1/32 1/8 1/32)
(1/32 1/8 1/16 1/32 1/16 1/32 1/32 1/16 1/32 1/16
1/8 1/32 1/8 1/16 1/32 1/8 1/16 1/32 1/32
1/16 1/8 1/32 1/16 1/8 1/16 1/8 1/32 1/16
1/32 1/16 1/16 1/32 1/16 1/32 1/8 1/16 1/16
1/8 1/16 1/32 1/8 1/32 1/32 1/8 1/32 1/16
1/8 1/16 1/8 1/32 1/8 1/16 1/32 1/8 1/8 1/32
1/16 1/8 1/32 1/8 1/16 1/8 1/16 1/8 1/32 1/16
1/16 1/32 1/8 1/16 1/8 1/16 1/16 1/8 1/16 1/8
1/32 1/16 1/16 1/32 1/8 1/16 1/8 1/16 1/8 1/32
1/8 1/16 1/32 1/8 1/8 1/32 1/16 1/8 1/32 1/8
1/16 1/8 1/16 1/32 1/8 1/32 1/32 1/8 1/32 1/16
1/8 1/16 1/16 1/8 1/32 1/16 1/32 1/16 1/16
1/32 1/16 1/32 1/8 1/16 1/8 1/16 1/32 1/8 1/16
1/32 1/32 1/16 1/8 1/32 1/16 1/8 1/32 1/8 1/16
1/32 1/16 1/32 1/32 1/16 1/32 1/16 1/8 1/32))

##### Share on other sites

nice :-) i have a lot of extra function on SYMMETRIES in my USER-library, it's a part of my momentary project

- chained-symmetries

- symmetries based on markov

- shifted symmetries

..................................................

##### Share on other sites

One function with few changes:

(defun gen-sieve (ambitus interval)
(do-verbose ("gen-sieve")
(flet ((gen-sieve* (ambitus interval)
(integer-to-pitch
(loop
with integer = (pitch-to-integer ambitus)
with cnt = -1
for int = (first integer) then (setf int (+ (nth cnt interval) int))
when (<= int (second integer))
collect int into bag
else return bag
do (incf cnt)
when (= cnt (length interval))
do (setf cnt 0)))))

(if (listsp ambitus)
(sort-asc
(find-unique
(loop for a in ambitus for i in interval
append (gen-sieve* a i))))
(gen-sieve* ambitus interval)))))

(gen-sieve '(c4 g7) '(2 1))
=> (c4 d4 eb4 f4 fs4 gs4 a4 b4 c5 d5 eb5 f5 fs5 gs5
a5 b5 c6 d6 eb6 f6 fs6 gs6 a6 b6 c7 d7 eb7 f7 fs7)

(gen-sieve '((c4 g7) (c1 g7)) '((2 1 12) (3 5)))
=> (c1 eb1 gs1 b1 e2 g2 c3 eb3 gs3 b3 c4 d4 eb4 e4 g4
c5 eb5 f5 fs5 gs5 b5 e6 fs6 g6 gs6 a6 c7 eb7)

##### Share on other sites

Wonderful !

Many beautiful things here !

Stéphane

##### Share on other sites

further XENAKIS-sieve-functions could be with the AND/OR/NOT inside... see: "formalized-music" or:

##### Share on other sites

With AMBITUS-FORM function:

(defun gen-sieve (ambitus interval)
(do-verbose ("gen-sieve")
(flet ((gen-sieve* (ambitus interval)
(integer-to-pitch
(loop
with cnt = -1
for int = (first ambitus) then (setf int (+ (nth cnt interval) int))
when (<= int (second ambitus))
collect int into bag
else return bag
do (incf cnt)
when (= cnt (length interval))
do (setf cnt 0)))))

(let ((ambitus (ambitus-form ambitus)))
(if (listsp ambitus)
(sort-asc
(find-unique
(loop for a in ambitus for i in interval
append (gen-sieve* a i))))
(gen-sieve* ambitus interval))))))

(gen-sieve '(c4 g7) '(2 1))
=> (c4 d4 eb4 f4 fs4 gs4 a4 b4 c5 d5 eb5 f5 fs5 gs5
a5 b5 c6 d6 eb6 f6 fs6 gs6 a6 b6 c7 d7 eb7 f7 fs7)

(gen-sieve '((c4 g7) (c1 g7)) '((2 1 12) (3 5)))
=> (c1 eb1 gs1 b1 e2 g2 c3 eb3 gs3 b3 c4 d4 eb4 e4 g4
c5 eb5 f5 fs5 gs5 b5 e6 fs6 g6 gs6 a6 c7 eb7)

(gen-sieve 'violin '(2 1))
=> (g3 a3 bb3 c4 cs4 eb4 e4 fs4 g4 a4 bb4 c5 cs5 eb5 e5 fs5 g5
a5 bb5 c6 cs6 eb6 e6 fs6 g6 a6 bb6 c7 cs7 eb7 e7 fs7 g7)

(gen-sieve '(violin (c1 g6) piccolo) '((2 1 12) (3 5) (3 6)))
=> (c1 eb1 gs1 b1 e2 g2 c3 eb3 g3 gs3 a3 bb3 b3 e4 g4 bb4 c5
cs5 eb5 gs5 a5 b5 c6 cs6 eb6 e6 fs6 g6 a6 eb7 e7 fs7 g7 c8)

AMBITUS-FORM is embedded in many ambitus functions:

(ambitus-form 'violin)
(ambitus-form '(2 34))
(ambitus-form '(violin))
(ambitus-form '(violin (2 34)))
(ambitus-form '((2 34) midi))
(ambitus-form '((2 34) (2 34)))
(ambitus-form '(violin cello))

##### Share on other sites

Part of the next release, thanks to Andre:

(gen-sieve '(c4 g7) '(2 1))
=> (0 2 3 5 6 8 9 11 12 14 15 17 18 20 21 23
24 26 27 29 30 32 33 35 36 38 39 41 42)

(gen-sieve '(c4 g7) '(2 1) :type :pitch)
=> (c4 d4 eb4 f4 fs4 gs4 a4 b4 c5 d5 eb5 f5 fs5 gs5
a5 b5 c6 d6 eb6 f6 fs6 gs6 a6 b6 c7 d7 eb7 f7 fs7)

(gen-sieve '((c4 g7) (c1 g7)) '((2 1 12) (3 5)))
=> (-36 -33 -28 -25 -20 -17 -12 -9 -4 -1 0 2 3 4
7 12 15 17 18 20 23 28 30 31 32 33 36 39)

(gen-sieve '((c4 g7) (c1 g7)) '((2 1 12) (3 5)) :type :pitch)
=> (c1 eb1 gs1 b1 e2 g2 c3 eb3 gs3 b3 c4 d4 eb4 e4 g4
c5 eb5 f5 fs5 gs5 b5 e6 fs6 g6 gs6 a6 c7 eb7)

(gen-sieve '(violin (c1 g6) piccolo) '((2 1 12) (3 5) (3 6))
:type :interval)
=> (3 5 3 5 3 5 3 4 1 1 1 1 5 3 3 2 1 2 5 1 2 1 1 2 1 2 1 2 6 1 2 1 5)

##### Share on other sites

looking forward to next release!

## Join the conversation

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

Reply to this topic...

×   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