# Opusmodus 1.1.18827

## Recommended Posts

New function:

motif-map map sequence &key otherwise swallow

[Function]

Arguments and Values:

map                    a list. (<old><new>).

sequence        a proper sequence.

otherwise       NIL or an argument. The default is NIL.

swallow         NIL or T. The default is NIL.

Description:

MOTIF-MAP returns a copy of sequence in which each motif that has been mapped is replaced with a new motif.

Examples:

The argument (((0 1 2) (a b c))) means motif (0 1 2) will be replace with new motif (a b c).

(motif-map '(((0 1 2) (a b c)))

'(0 1 2 3 4 5 6 7 8 9 10 11))

=> (a b c 3 4 5 6 7 8 9 10 11)

The otherwise with an argument 'x replaces all items in the sequence with 'x which are not mapped.

(motif-map '(((0 1 2) (a b c)))

'(0 1 2 3 4 5 6 7 8 9 10 11) :otherwise 'x)

=> (a b c x x x x x x x x x)

Example with many mappings.

(motif-map '(((0 1 2) (a b c))

((3 4 5) (a a a))

((6 7) (b b))

((8 9 10) (c c c))

(11 d))

'(0 1 2 3 4 5 6 7 8 9 10 11))

=> (a b c a a a b b c c c d)

Mapping length:

(setf length

'((1/16 1/16 1/8 1/8 1/8 1/16 1/16 1/8 1/8 1/8)

(1/16 1/16 1/8 1/8 1/16 1/16 1/4 1/16 1/16 1/8)

(1/16 1/16 1/8 1/8 1/8 1/16 1/16 1/8 1/8 1/8)

(1/16 1/16 1/8 1/8 1/8 1/16 1/16 3/8)

(1/16 1/16 1/16 1/16 1/16 1/16 1/8 1/8 1/8 1/8 1/8)

(1/8 1/8 1/8 1/8 1/8 1/8 1/8 1/16 1/16)))

(setf lmap

'(((1/16 1/16 1/8) (1/4))

((1/16 1/16 1/4) (3/8))

((1/16 1/16 1/16 1/16 1/16 1/16 1/16 1/16) (1/2))

((1/8 1/8 1/8 1/8) (3/8 1/8))))

(motif-map lmap length)

=> ((1/4 1/8 1/8 1/4 1/8 1/8)

(1/4 1/8 3/8 1/4)

(1/4 1/8 1/8 1/4 1/8 1/8)

(1/4 1/8 1/8 1/16 1/16 3/8)

(1/16 1/16 3/8 3/8 1/8)

(3/8 1/8 1/8 1/8 1/8 1/16 1/16))

Mapping interval:

(setf pitch

'((g5 fs5 g5 c5 ds5 g5 fs5 g5 a5 d5)

(g5 fs5 g5 a5 c5 d5 ds5 d5 c5 as4)

(ds5 d5 ds5 g4 gs4 f5 ds5 f5 a4 as4)

(g5 f5 g5 b4 c5 d5 ds5 f5)

(ds5 d5 c5 as4 gs4 g4 f4 gs5 g5 f5 ds5)

(d5 ds5 f5 b4 c5 d5 b4 c5 g5)))

(setf intervals (pitch-to-interval pitch))

=> ((-1 1 -7 3 4 -1 1 2 -7) (5 -1 1 2 -9 2 1 -1 -2 -2)

(5 -1 1 -8 1 9 -2 2 -8 1) (9 -2 2 -8 1 2 1 2)

(-2 -1 -2 -2 -2 -1 -2 15 -1 -2 -2) (-1 1 2 -6 1 2 -3 1 7))

(setf imap '(((-1 1) 3) ((1 -2) 2) ((1 1) (3 3))))

(setf new-intervals (motif-map imap intervals))

=> ((3 -7 3 4 3 2 -7) (5 3 2 -9 2 1 -1 -2 -2)

(5 3 -8 1 9 -2 2 -8 1) (9 -2 2 -8 1 2 1 2)

(-2 -1 -2 -2 -2 -1 -2 15 -1 -2 -2) (3 2 -6 1 2 -3 1 7))

(interval-to-pitch new-intervals :start 'g5)

=> ((g5 bb5 eb5 fs5 bb5 cs6 eb6 gs5)

(cs6 e6 fs6 a5 b5 c6 b5 a5 g5)

(c6 eb6 g5 gs5 f6 eb6 f6 a5 bb5)

(g6 f6 g6 b5 c6 d6 eb6 f6)

(eb6 d6 c6 bb5 gs5 g5 f5 gs6 g6 f6 eb6)

(fs6 gs6 d6 eb6 f6 d6 eb6 bb6))

Mapping articulation to length:

(setf lengths

'((-11/16 1/16 -1/4)

(-3/4 1/12 -1/12 1/12)

(1/16 1/8 1/16 1/16 1/16 1/8)

(1/20 -1/20 1/20 -1/20 1/20 1/20 1/20 1/20 1/20 1/20)

(-1/16 1/16 1/16 1/16 1/16 1/16 1/8)

(1/16 1/16 -1/8 1/16 1/16 1/16 1/16)))

(motif-map

'(((1/8 1/4) leg)

((1/16 1/16 1/16 1/16) (leg leg leg))

(1/12 stacc)

((1/20 1/20) (stacc stacc)))

lengths :otherwise '-)

=> ((- - -) (- stacc - stacc) (- - - - - -)

(- - - - stacc stacc stacc stacc stacc stacc)

(- leg leg leg - -) (- - - leg leg leg))

The swallow keyword t (true) swallows items that align with rest-length values. This keyword can be used if a sequence contain lengths.

(motif-map

'(((1/8 1/4) leg)

((1/16 1/16 1/16 1/16) (leg leg leg))

(1/12 stacc)

((1/20 1/20) (stacc stacc)))

lengths :swallow t :otherwise '-)

=> ((-) (stacc stacc) (- - - - - -)

(- - stacc stacc stacc stacc stacc stacc)

(leg leg leg - - -) (- - leg leg leg -))

;;;---------------------------------------------------------

;;; SCORE EXAMPLE

;;;---------------------------------------------------------

(progn

(setf lengths

(binary-rhythm

(gen-repeat 4 '(16 12 8 10 8 8 12))

(gen-repeat 4 '( 8  5 7  5 6 6  6))

(gen-repeat 4 '( s 3q s 5q s s 3e))

:type '? :variant '?

:rotate (rnd-sample 24 '(-2 -1 1 0 1 2))))

(setf articulations

(motif-map

'(((1/8 1/4) leg)

((1/16 1/8) leg)

((1/12 1/12 1/12) (leg leg))

((1/16 1/16 1/16 1/16 1/16)

(stacc stacc stacc stacc stacc))

((1/20 1/20 1/20 1/20 1/20) (leg leg leg leg))

((1/20 1/20) (stacc stacc))

((3/8 5/16 5/16) (leg leg)))

lengths :swallow t :otherwise '-))

(setf pitches

(randomize-octaves

'(g3 c7)

(interval-to-pitch

(rnd-sample 128 '(0 -1 1 6 -6))

:start 'a3)))

(setf omn

(make-omn

:pitch pitches

:length lengths

:velocity '(f)

:articulation articulations))

(def-score solo-violin

(:title "Violin Solo"

:composer "OPMO"

:key-signature 'chromatic

:time-signature (get-time-signature omn)

:tempo 96

:layout (violin-layout 'vln))

(vln :omn omn

:channel 1

:sound 'gm

:program 'violin))

(display-midi 'solo-violin)

)

--------------------------------------------------------------------------------------

length-chordize-map map pitch length &key unique otherwise seed

[Function]

Arguments and Values:

map                      a list (<old><new>).

pitch                 a list or lists of pitches

length               a list or lists of length.

unique               NIL or T (unique pitches in a chord). The default is T.

otherwise       an integer (chord size). The default is 1.

seed        NIL or an integer. The default is NIL.

Description:

LENGTH-CHORDIZE-MAP creates chords from a pitch series from a set of maps (<length> <chord-size>).

(length-chordize-map

'(1/8 2)

'(c4 d4 e4 f4 g4 a4 b4)

'(1/4 1/8 -1/8 1/16 1/16 1/16 -1/16 1/8 1/8 1/2))

=> (c4 d4e4 f4 g4 a4 b4c4 d4e4 f4)

Any length in a sequence that has not been mapped, a single note is used (default otherwise).

Examples:

In the preliminary examples the contents of a chromatic scale are chordized in a variety of different ways.

Here the chord size 2 is activated to 1/8:

(length-chordize-map

'(1/8 2)

'(c4 cs4 d4 ds4 e4 f4 fs4 g4 gs4 a4 bb4 b4 c5)

'(1/8 1/16 1/16 -1/16 1/16 1/4 1/4 1/2))

=> (c4cs4 d4 ds4 e4 f4 fs4 g4)

Notice that the output is trimmed to the length of the rhythm.

(length-chordize-map

'((1/16 1) (1/8 (1 2)))

'(c4 cs4 d4 ds4 e4 f4 fs4 g4 gs4 a4 bb4 b4 c5)

'(1/8 1/16 1/16 -1/16 1/16 1/4 1/4 1/2))

=> (c4cs4 d4 ds4 e4 f4 fs4 g4)

Examples with length symbols:

Here, otherwise is activated with chord size 3 on lengths that have not been mapped:

(length-chordize-map

'((s 1) (e (1 2)))

'(c4 cs4 d4 ds4 e4 f4 fs4 g4 gs4 a4 bb4 b4 c5)

(1/8 1/16 1/16 -1/16 1/16 1/4 1/4 1/2) :otherwise 3)

=> (c4cs4 d4 ds4 e4 f4fs4g4 gs4a4bb4 b4c5c4)

In the following example the otherwise value is chosen at random:

(length-chordize-map

'((s 1) (e (1 2)))

'(c4 cs4 d4 ds4 e4 f4 fs4 g4 gs4 a4 bb4 b4 c5)

'(1/8 1/16 1/16 -1/16 1/16 1/4 1/4 1/2) :otherwise '(2 3))

=> (c4cs4 d4 ds4 e4 f4fs4 g4gs4 a4bb4b4)

Example with sublists:

(setf pitches

'((ds5 d5 g5 fs5 g5 g5 g5 c5 a5 fs5)

(c5 g5 ds5 d5 fs5 a5 g5 as4 c5 d5)

(ds5 as4 d5 a4 f5 ds5 f5 gs4 ds5 g4)

(d5 g5 b4 f5 g5 ds5 f5 c5)

(c5 ds5 as4 gs5 d5 f5 ds5 g4 gs4 f4 g5)

(f5 c5 d5 b4 b4 ds5 g5 d5 c5)))

(setf lengths

'((s = e) (q) (s = q) (q.)

(s = = = = = = =) (h)

(e = q) (q. e)))

(length-chordize-map

'((s 1) (e 2)) pitches lengths :otherwise '(2 3))

=> ((ds5 d5 g5fs5) (g5c5a5) (c5 a5 fs5c5g5)

(ds5d5fs5) (a5 g5 as4 c5 d5 ds5 as4 d5)

(a4f5ds5) (f5gs4 ds5g4 d5g5b4) (f5g5 ds5f5))

--------------------------------------------------------------------------------------
REVISED:

length-map map length otherwise &key type seed

[Function]

Arguments and Values:

map                    a list (<old><new>).

sequence        a proper sequence.

otherwise       an item, selected at random.

swallow         NIL or T. The default is NIL.

type                           'repeat or '? (at random).  The default is '?.

seed                            NIL or an integer. The default is NIL.

Description:

LENGTH-MAP returns a copy of sequence in which each element that has been mapped (<length><item>) is replaced with a new item, if not, an otherwise item is chosen at random.

(length-map

'((s c4fs4) (e f6g6 c6d6) (q (fs6g6 c6ds6)))

'((q q h -s s s) (s e -q -q -e e -e s s h))

'(c4 cs4 fs4 g4))

=> ((c6ds6 c6ds6 g4 c4fs4 c4fs4)

(c4fs4 c6d6 c6d6 c4fs4 c4fs4 cs4))

Examples:

(length-map

'((e (spicc trem))

(s (pizz stacc))

(q (non-vib leg)))

'(s = e h -s = e -q h q)

'(harm tasto)

:type 'repeat :seed 34)

=> (stacc stacc spicc tasto stacc spicc tasto non-vib)

The swallow t (true) swallows items that align with rest-length values:

(length-map

'((e (spicc trem))

(s (pizz stacc))

(q (non-vib leg)))

'(s = e h -s = e -q h q)

'(harm tasto)

:type 'repeat :seed 34 :swallow t)

=> (stacc stacc spicc tasto spicc tasto stacc stacc)

Example with sublists:

Mapping articulation to length.

(setf length

'((1/2 4/5 1/5 3/10 1/10)

(5/16 1/16 1/2 3/16 1/8)

(4/5 1/2 3/10 1/5 1/10)

(1/2 5/16 3/16 1/8 1/16)

(1/16 1/2 5/16 1/8 3/16 1/8 5/16 1/2 1/16 1/16 1/2)

(1/2 5/16 3/16 1/16 1/8 1/16 3/16 5/16 1/2)

(1/10 1/5 3/10 1/2 4/5 3/10 1/2 4/5 1/2 3/10 1/5)

(1/8 5/16 1/16 1/2 3/16)

(1/8 3/16 1/2 1/16 5/16)

(1/2 4/5 1/10 3/10 1/5 1/5 3/10)))

(length-map

'(((1/40 1/10)  (tas-stacc detache-short stacc))

((3/20 1/3)   (tas-detache detache-long))

((7/20 13/20) (tas-sus dyn-me-novib-1.5s tas-trem))

((2/3 7/6)    (tas-sus pfp-vib-4s dyn-me-novib-3s))

((5/4 7/4)    (tas-sus sus-novib)))

length '(tas-sus sus-novib) :type 'repeat)

=> ((tas-sus dyn-me-novib-3s detache-long detache-long stacc)

(tas-detache detache-short tas-sus tas-detache sus-novib)

(pfp-vib-4s tas-trem tas-detache tas-detache detache-short)

(dyn-me-novib-1.5s detache-long detache-long sus-novib tas-stacc)

(detache-short tas-sus detache-long sus-novib detache-long

sus-novib detache-long tas-sus detache-short detache-short tas-sus)

(tas-trem detache-long detache-long detache-short tas-sus

detache-short detache-long detache-long tas-trem)

(detache-short detache-long detache-long dyn-me-novib-1.5s

pfp-vib-4s detache-long dyn-me-novib-1.5s pfp-vib-4s

dyn-me-novib-1.5s detache-long detache-long)

(tas-sus tas-detache tas-stacc tas-trem tas-detache)

(tas-sus detache-long tas-sus stacc detache-long)

(tas-trem dyn-me-novib-3s detache-short detache-long

detache-long detache-long detache-long))

See MOTIF-MAP

--------------------------------------------------------------------------------------

replace-map map sequence &key otherwise

[Function]

Arguments and Values:

map                a list. (<old><new>).

sequence               a proper sequence.

otherwise          NIL or an argument. The default is NIL.

Description:

REPLACE-MAP returns a copy of sequence in which each element that has been mapped is replaced with a new item.

(replace-map '((1 a) (2 b) (3 c)) '(1 2 3 4 5 4 5 3 2 3))

=> (a b c 4 5 4 5 c b c)

(replace-map '((1 a) (2 b) (3 c)) '(1 2 3 4 5 4 5 3 2 3)

:otherwise 'd)

=> (a b c d d d d c b c)

Examples:

The argument ((1 2) a) means number 1 and 2 will be replaced with a.

(replace-map '(((1 2) a) ((3 4 5) b)) '(1 2 3 4 5 4 5 3 2 3))

=> (a a b b b b b b a b)

The otherwise keyword with an argument 'd replaces all items in the sequence with 'd which are not mapped.

(replace-map '(((1 2) a)

((3 4 5) b)

((6 11) c))

'(( 1 2 3 4 5) (6 7 8 9 10 11))

:otherwise 'd)

=> ((d a a b b b) (c d d d d c))

See SUBSTITUTE-MAP

--------------------------------------------------------------------------------------

The LENGTH-CHORDIZE-MAP replaced the chordize-to-length and chordize-to-length2 function.

##### Share on other sites

• opmo featured this topic
• opmo unfeatured this topic
×
• #### Browser

• Video Gallery

• Lessons