# Permute Function Question

## Recommended Posts

I need a function to filter the Permutations.

For example:

`(gen-divide 2 (flatten (permute (pcs '4-1))))`

Will result in:

```((0 1) (2 3) (0 1) (3 2) (0 2) (1 3) (0 2) (3 1) (0 3) (1 2) (0 3) (2 1) (1 0)
(2 3) (1 0) (3 2) (1 2) (0 3) (1 2) (3 0) (1 3) (0 2) (1 3) (2 0) (2 0) (1 3)
(2 0) (3 1) (2 1) (0 3) (2 1) (3 0) (2 3) (0 1) (2 3) (1 0) (3 0) (1 2) (3 0)
(2 1) (3 1) (0 2) (3 1) (2 0) (3 2) (0 1) (3 2) (1 0))```

But I don't mind with the order, since I'll make chords out of it, so

((0 1) (2 3) or (0 1) (3 2) or (1 0) (2 3)  will result in the same chord.

How to filter the list onto a list where the order does not matter ?

Best,

Julio

##### Share on other sites

Possible workaround:

`(remove-duplicates (sort-asc (combination 3 (pcs '6-1))) :test #'equal)`

##### Share on other sites

as well:

`(find-unique (sort-asc (combination 3 (pcs '6-1))))`

Thanks, 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.

×

• ### Similar Topics

• By spuki
Hallo,
newbie here 🙂
I'm just starting with OM and playing around with the tutorials.
I slightly changed tutorial #4 and run into something strange.

If i run the script as posted below, all works as expected. But when i change the function reverse to nreverse (and nreverse is the oficially documented name of the function)
the omn result will leave the right hand empty. Why ist that?  And why does reverse work as i expect it to work?

And, another thing: i dont understand what the term seed will do. Will it make random functions behave always the same as long as the seed is the same?
...and what does the number following the seed mean?

Thank you !!
Best,
Sebasian
(setf pitches (gen-repeat 5 '(c4 cs4 fs4 g4 c5 cs5))) (setf transposed-pitches (gen-repeat 5 (pitch-transpose -24 pitches))) (setf lengths (span pitches '(e))) (setf lengths-rests (length-weight lengths :weight '(2 1) :seed 12)) (setf left-lengths (reverse lengths-rests)) (setf piano-righthand       (make-omn        :length lengths-rests        :pitch pitches        :velocity'(mp))) (setf piano-lefthand       (make-omn        :length left-lengths        :pitch transposed-pitches        :velocity '(f))) (setf timesigs (get-time-signature left-lengths)) (def-score lesson-4            (:key-signature 'chromatic             :time-signature '( 5 8 )             :tempo 190             :layout (piano-layout 'piano-rh 'piano-lh))     (piano-rh    :omn piano-righthand    :channel 1    :sound 'gm    :program 'acoustic-grand-piano)     (piano-lh    :omn piano-lefthand)   )
• By Deb76
Hello,
Somewhat stupid question but I do not find a function that would allow me to reorder a sequence of pitches.
Let me explain, on a forum where Messiaen's limited transposition modes are discussed, I wanted to show that with Opumodus we could very easily analyze the modes and recreate them. I have no problem with those who are in total symmetry and divisible by two, but if I take the mode 3: (c4 d4 eb4 e4 gb4 g4 ab4 bb4 b4), using the function pitch-transpose-start I get in the end the mode but according to the postponement of the intervallic structure on c4 d4 ab4 is => ((c4 e4 gs4) (d4 fs4 bb4) (eb4 g4 b4)). I tried to reorder with the function pcs-normal-order the mode is reordered but with however the c4 in last position: (d4 eb4 e4 fs4 g4 gs4 bb4 b4 c4). Now, I suppose there is a function that makes it possible to obtain the right disposition. What is it ?
(setf modmessiaen3 '(c4 d4 eb4 e4 gb4 g4 ab4 bb4 b4)) (setf SIMessiaenMod3 (pitch-to-interval modmessiaen3)) ; =>  (2 1 1 2 1 1 2 1) (setf mod3divide (gen-divide 3 modmessiaen3)) (setf firstmodmessiaen3 (filter-first 3 modmessiaen3)) (setf report3 '(c4 e4 ab4)) (setf rep3 (gen-repeat 3 (list report3))) (setf pch3 (modus (flatten (pitch-transpose-start firstmodmessiaen3 rep3)))) (setf MessiaenMod3 (pcs-normal-order pch3 :pitch)) (setf SIMessiaenMod3a (pitch-to-interval MessiaenMod3)) ; => (1 1 2 1 1 2 1 -11) (setf mod3chordsM (melodize '((c4eb4gb4) (d4gb4bb4) (eb4gb4bb4) (e4g4b4) (gb4bb4db5) (g4b4d5) (ab4b4d5) (bb4gb5) (b4d5gb5)))) (setf analysechords3 (pcs-analysis (integer-to-pitch (modus mod3chordsM))))
In particular, this distorts the analysis of the interstellar structure of mode 3:
of (2 1 1 2 1 1 2 1) I get (1 1 2 1 1 2 1 -11)
Besides, there is probably a more efficient script than the one I tried?
Best.
Didier

PS : In fact, I realize that the function pcs-normal-order is not adapted at all according to the modes.

• Dear All,

Stephane did this amazing and clear example (code below) of how to spread an harmonic progression over a predefined texture.
This can be altered to any harmonic idiom. I did some test, using a chorale texture originated from a 12-tone row and also
a more jazz-oriented chorale.

THE QUESTION IS (For Stephane Boussuge)

1) How the harmonic rhythm is controlled here? In the example, the chord changes every half note.
2) How can I make the harmony changes at every quarter note ?
3) Can I use different rates of harmonic rhythms ?

Best,
Julio

;;; Classical Accompaniment Exemple ;;;--------------------------------------------------------- ;;; Parameters ;;;--------------------------------------------------------- ;;; Motif definition (setf mtf1 '((s c5 leg g5 leg e6 leg g5 c5 leg g5 leg e6 leg g5))) (setf mtf2 (pitch-transpose 4 mtf1)) (setf mtf3 '((-q e5))) (setf mtf4 '((-q g4c5))) (setf mtf5 '((q c2 -))) ;;; Chords definition (setf chords (library 'harmoprog1 'minor-4vx 'prog1)) ;;; Ostinati (setf ost1 (gen-repeat (length chords) mtf1)) (setf ost2 (gen-repeat (length chords) mtf2)) (setf ost3 (gen-repeat (length chords) mtf3)) (setf ost4 (gen-repeat (length chords) mtf4)) (setf ost5 (gen-repeat (length chords) mtf5)) ;;; Tonality-map series (setf tm-path (tonality-series chords)) ;;; Here we apply the map 'tm-path' into arpegio sequence. (setf ost1.map (tonality-map tm-path ost1)) (setf ost2.map (tonality-map tm-path ost2)) ;;; Here we apply our library chords into chord sequence. ;;; The harmonic-path preserves the voice leading. (setf ost3.map (harmonic-path chords ost3)) (setf ost4.map (harmonic-path chords ost4)) (setf ost5.map (harmonic-path chords ost5)) (setf violin1 (ambitus '(g3 c7) ost2.map)) (setf violin2 (ambitus '(g3 c6) ost1.map)) (setf viola (ambitus '(c3 e4) ost3.map)) (setf violoncello (ambitus-chord 12 (pitch-transpose -12 ost4.map))) (setf bass ost5.map) ;;;--------------------------------------------------------- ;;; Score and Layout ;;;--------------------------------------------------------- (def-score Classical-accomp (:title "Classical accompaniment example" :composer "S.Boussuge" :copyright "Copyright © 2018 s.boussuge" :key-signature 'chromatic :time-signature '((1 1 1 1) 4) :tempo 80 :layout (bracket-group (violin-layout 'violin1 :name "Violin-1") (violin-layout 'violin2 :name "Violin-2") (viola-layout 'viola) (violoncello-layout 'violoncello) (contrabass-layout 'bass) ) ) (violin1 :omn violin1 :channel 1 :sound 'gm :program 'String-Ensemble-1 :volume 100 :pan 48 :controllers (91 '(68)) ) (violin2 :omn violin2 :channel 2 :sound 'gm :program 'String-Ensemble-1 :volume 100 :pan 48 :controllers (91 '(68)) ) (viola :omn viola :channel 3 :sound 'gm :program 'String-Ensemble-1 :volume 90 :pan 64 :controllers (91 '(68)) ) (violoncello :omn violoncello :channel 4 :sound 'gm :program 'String-Ensemble-1 :volume 90 :pan 80 :controllers (91 '(68)) ) (bass :omn bass :channel 5 :sound 'gm :program 'String-Ensemble-1 :volume 90 :pan 80 :controllers (91 '(68)) ) )
×

• Lessons