Interval Modus

The Interval Modus library functions are outcome of my latest work on String Quartet No.2 “Primo Giardino Parlante”. The library is not well documented now, but the examples should explain the method a bit.

Functions

i-row»
i-row-dir»
i-row-scale»
i-row-series»
i-row-matrix»
i-row-transpose»
i-row-invert»
i-mod»
i-invert-assoc»
i-invert-dir»
i-remove»

Free update to current MRAC-Library 2.0 users.

Downloads


i-row (seed n)

Generate n random unique intervals.

(i-row nil 12)
--> each time random list
 
(i-row 0.62 12)
--> (10 5 -2 -8 11 -6 9 -1 7 -12 -3 -4 0)
 
(i-row 0.62 14)
--> (-12 -6 3 -9 13 -8 10 -1 -7 -14 -4 -5 -2 0 11)


i-row-dir (seed row)

Generate interval direction from interval list.

(i-row-dir 0.45 '(8 7 6 10 3 4 0 5 9 2 11 1))
--> (8 -7 6 -10 -3 -4 0 -5 9 2 11 -1)


i-row-scale (percent interval-list)

This function scale the interval size according
to the percent number.

(i-row-scale 30 '(-11 -7 6 -12 9 -4 8))
--> (-3 -2 2 -4 3 -1 2)
 
(i-row-scale '(50 150)
             '((-11 -7 6 -12 9 -4 8)  (-2 -3 5 -10 13 0 -1 14)))
 
--> ((-6 -4 3 -6 4 -2 4) (-3 -4 8 -15 20 0 -2 21))


i-row-series (seed mod output-type transposition variant set &key (remove nil) (array nil) (assoc nil))

; variant: p = prime, r = retrograde,
; i = inversion, ri = retrograde-inversion
; 4 = 4th, 5 = 5th, r4 = retrograde-4th
; r5 = retrograde-5th
;
; output-type: :symbol :integer :interval :pitch :tonality
;
; key: :remove :array :assoc

(setq set-12 '(9 5 -4 10 -7 2 -6 0 1 -3 8 -11))
 
(i-row-series nil 11 :interval 9 'p set-12)
--> (9 5 -4 10 -7 2 -6 0 1 -3 8 -11)
 
(i-row-series nil 11 :interval 0 'p set-12)
--> (0 -8 7 1 10 -5 9 -3 -4 6 -11 -2)
 
(i-row-series nil 11 :interval 0 'r set-12)
--> (-2 -11 6 -4 -3 9 -5 10 1 7 -8 0)
 
(i-row-series nil 11 :interval 0 'i set-12)
--> (0 3 -4 -10 -1 6 -2 8 7 -5 0 9)
 
(i-row-series nil 11 :interval 0 'ri set-12)
--> (9 0 -5 7 8 -2 6 -1 -10 -4 3 0)
 
(i-row-series nil 11 :symbol 0 '4 set-12 :remove 'oct :assoc 12)
--> (a -e h m o n w t l r k a)
 
(i-row-series nil 11 :pitch 0 '5 set-12 :remove 'oct :assoc 12)
--> (c4 e3 f3 c4 a\#4 b3 d4 f3 c\#3 g3 d3 c3)

; with transposition 9

(i-row-series nil 11 :tonality 9 'r4 set-12 :remove 'oct :assoc 12)
--> (f 3 a\# 2 d 3 b 2 e 3 a\# 2 g\# 3 a 2 b 2 d\# 2 e 2 c\# 3)

; 8 variants with transposition 0

(setq transpose (gen-repeat 8 '(0)))
(setq variant '(p r i ri 4 5 r4 r5))
 
(i-row-series nil 11 :interval transpose variant set-12 :assoc 12)
--> ((  0  -8  7   1  10 -5  9  -3  -4  6 -11  -2)
     ( -2 -11  6  -4  -3  9 -5  10   1  7  -8   0)
     (  0   3 -4 -10  -1  6 -2   8   7 -5   0   9)
     (  9   0 -5   7   8 -2  6  -1 -10 -4   3   0)
     (  0  -7  2   5   6 -3  1  -4  -9  8   0 -10)
     (  0  -1  5   7   4 -2  8 -10  -6  9   0  -3)
     (-10   0  8  -9  -4  1 -3   6   5  2  -7   0)
     ( -3   0  9  -6 -10  8 -2   4   7  5  -1   0))

; with 12 transpositions and 12 variants

(setq transp1 (pick-rnd 0.34 :content 12 (g-integer 0 11)))
--> (11 9 5 2 6 8 0 0 0 11 10 8)
 
(setq variant1 (pick-rnd 0.34 :content 12 '(p r i ri)))
--> (ri ri r p i i p p p ri ri i)
 
(i-row-series nil 11 :interval transp1 variant1 set-12 :assoc 12)
--> ((-11 -2 7 -9 -10 4 -8 3 0 6 -5 -1)
     (1 -4 9 -11 0 6 -10 5 -2 8 -7 -3)
     (-7 4 11 -9 -8 -2 -10 -3 6 0 1 5)
     (2 -10 9 3 0 -7 11 -5 -6 8 1 -4)
     (-6 -10 11 -5 8 1 9 3 2 0 -7 4)
     (-4 -8 9 -3 6 -11 7 1 0 10 -5 2)
     (0 -8 7 1 10 -5 9 -3 -4 6 -11 -2)
     (0 -8 7 1 10 -5 9 -3 -4 6 -11 -2)
     (0 -8 7 1 10 -5 9 -3 -4 6 -11 -2)
     (-11 -2 7 -9 -10 4 -8 3 0 6 -5 -1)
     (0 -3 8 -10 -11 5 -9 4 -1 7 -6 -2)
     (-4 -8 9 -3 6 -11 7 1 0 10 -5 2))

Example with 14 interval row, 14 transpositions,
14 variants and 14 variants for each interval in the set.

(setq set-14 '(-9 5 -4 10 -7 2 -6 0 1 -3 8 -11 13 -14 12))
(setq variant2 (g-eval 0.34 14 '(pick-rnd nil :content 14 '(p r i ri))))
 
(i-row-series 0.34 14 :symbol transp1 variant2 set-14 :remove 'oct :assoc 12)
--> ((c e r o w _ ] z \b _ ^ \k ^)
     (n k r j i m p o i w ^ \i \j \q)
     (a -i -j -s -x -\\ -o -d -b -p -h -n a f)
     (-m -r -e -k -n a n w _ \h ] \a \g \\ ^)
     (-d -m -z |-d| |-k| |-s| |-f| |-o| |-q| |-j| |-n| |-x| |-j| |-d|)
     (i e -h -q -n -t -u -\\ |-f| |-m| |-w| -} |-z| |-m| -\`)
     (i l g -c m l p u [ x w l v k)
     (-c f -j f -j -r -l -t |-b| |-a| |-o| |-z| |-w|)
     (-d a n x y x \\ \b \g \k \j \k ] r)
     (i -f -m -g h j o w u r w m g t v)
     (-d -c -i -p -t -k -p -e g -c -g -u -o -])
     (-b m b -b -i -s -e -l -v -\\ |-e| |-p| |-t|))


i-row-matrix (seed mod output-type list &key (remove nil) (array nil) (assoc nil))

; &key: :array t, :remove ‘oct or :remove ‘(12 0)) :assoc 12
; output-type: :symbol :integer :interval :pitch :tonality

Matrix with 11 intervals.

(setq set '(0 1 -3 8 -11 9 -5 4 10 -7 2 6))
(i-row-matrix nil 11 :interval set :assoc 12)
 
                            I
 
--> ((  0   1  -3   8 -11   9  -5   4 10 -7   2   6)
     (-11   0  -2   7 -10   8  -4   3  9 -6   1   5)
     (  9  10   0  -5   8  -6   2  -1 -7  4  11  -3)
     ( -4  -5   7   0  -3   1   9  -8  2 11  -6 -10)
     (  1   2  -4   9   0  10  -6   5 11 -8   3   7)
 P   ( -3  -4   6 -11  -2   0   8  -7  1 10  -5  -9)   R
     (  7   8 -10  -3   6  -4   0  11 -5  2   9  -1)
     ( -8  -9  11   4  -7   5  -1   0  6 -3 -10   2)
     ( -2  -3   5 -10  -1 -11   7  -6  0  9  -4  -8)
     (  5   6  -8  -1   4  -2 -10   9 -3  0   7  11)
     (-10 -11  -1   6  -9   7  -3   2  8 -5   0   4)
     ( -6  -7   9   2  -5   3  11 -10  4 -1  -8   0))
 
                            RI

Example with :array key (build-array) and pick-array function

(setq array
      (i-row-matrix nil 11 :symbol set :remove 'oct :array t :assoc 12))

The following goes right from row 11 and column 7.
The length is 6 and the direction is right.

(pick-array 11 7 6 array :right)
--> (n d h g -c g)

Example with 14 intervals, mod 14 and key :assoc 12

(setq set-14 '(9 5 -4 10 -7 2 -6 0 1 -3 8 -11 13 -14 12))
 
(i-row-matrix nil 14 :interval set-14 :assoc 12)
--> ((9 5 -4 10 -7 2 -6 0 1 -3 8 -11 13 -14 12)
     (13 9 -8 14 -11 6 -10 4 5 -7 12 0 -2 3 -1)
     (-14 -10 9 0 12 -7 11 -5 -6 8 -13 -1 3 -4 2)
     (-5 -1 0 -6 3 13 2 11 12 -14 -4 7 -9 10 -8)
     (-11 -7 6 -12 9 -4 8 -2 -3 5 -10 13 0 -1 -14)
     (-5 -1 0 -6 3 13 2 11 12 -14 -4 7 -9 10 -8)
     (-12 -8 7 -13 10 -5 9 -3 -4 6 -11 14 1 -2 0)
     (-6 -2 1 -7 4 14 3 12 13 0 -5 8 -10 11 -9)
     (-2 13 -12 -3 0 10 -14 8 9 -11 -1 4 -6 7 -5)
     (0 -11 10 1 13 -8 12 -6 -7 9 -14 -2 4 -5 3)
     (10 6 -5 11 -8 3 -7 1 2 -4 9 -12 14 0 13)
     (-7 -3 2 -8 5 0 4 13 14 1 -6 9 -11 12 -10)
     (7 3 -2 8 -5 0 -4 -13 -14 -1 6 -9 11 -12 10)
     (-8 -4 3 -9 6 -1 5 14 0 2 -7 10 -12 13 -11)
     (-6 -2 1 -7 4 14 3 12 13 0 -5 8 -10 11 -9))

You can remove the octaves (0 and 12) with :remove ‘oct key.

(i-row-matrix nil 14 :interval set-14 :remove 'oct :assoc 12)
--> ((9 5 -4 10 -7 2 -6 1 -3 8 -11 13 -14)
     (13 9 -8 14 -11 6 -10 4 5 -7 -2 3 -1)
     (-14 -10 9 -7 11 -5 -6 8 -13 -1 3 -4 2)
     (8 4 -3 9 -6 1 -5 -14 -2 7 -10 -13 11)
     (-11 -7 6 9 -4 8 -2 -3 5 -10 13 -1 -14)
     (-1 -11 -2 -14 9 -13 7 8 -10 3 -5 6 -4)
     (-8 7 -13 10 -5 9 -3 -4 6 -11 14 1 -2)
     (-6 -2 1 -7 4 14 3 13 -5 8 -10 11 -9)
     (-2 13 -3 10 -14 8 9 -11 -1 4 -6 7 -5)
     (-11 10 1 13 -8 -6 -7 9 -14 -2 4 -5 3)
     (10 6 -5 11 -8 3 -7 1 2 -4 9 14 13)
     (4 14 5 -2 -1 -10 -11 13 3 -6 8 -9 7)
     (-2 13 -3 10 -14 8 9 -11 -1 4 -6 7 -5)
     (1 11 2 14 -9 13 -7 -8 10 -3 5 -6 4)
     (-6 -2 1 -7 4 14 3 13 -5 8 -10 11 -9)) 
 
(i-row-matrix nil 14 :symbol set-14 :remove 'oct :assoc 12)
--> ((j s x t ^ w y s t q y n [ m)
     (f s \\ t \b w ] s w \\ u s v u)
     (-e -s -] -t -[ -p -u -[ -s -\` |-a| -^ |-b| -\`)
     (k f e -c b o q \\ n j q h r j)
     (-h -s -z -t -k -o -g -i -l -g -q -d -e -s)
     (c b -k -m -[ -r -_ -x -p -z -w -\\ -v -z)
     (-g -o -h -u -k -p -g -j -n -h -s -e -d -f)
     (a -g -i -h -o -k e h u p x n y p)
     (b -b m j t f n w l k o i p k)
     (-d -o -e -d k c -e -l -c -q -s -o -t -q)
     (i s y t _ w z s t v r [ \i \v)
     (-l -h h m k j -b -m b e -c g -d e)
     (n u x v ^ y u h -h -i -c -l a k)
     (-o -w -[ -x |-a| -[ -\\ -w -i -g -n -d k -b)
     (m g e f -c c q t \a \\ \d z \e \\))

Example with mod 6 with same list set-14
and with out :assoc key

(i-row-matrix nil 6 :interval set-14 :remove 'oct)
--> ((-2 5 -4 -3 2 -6 1 -3 -1 4 -6 -5)
     (-3 2 1 5 4 -5 -6 1 -6 -2 4 -5 3)
     (1 -4 3 2 6 -1 5 -6 2 -3 5 -6 4)
     (-1 4 -3 -2 -6 1 -5 6 -2 3 -5 6 -4)
     (4 6 5 -2 -4 -1 -2 -3 5 3 -6 -1 2)
     (-3 6 -5 -4 1 3 1 2 -4 -2 5 -1 -6)
     (-6 -2 1 4 6 3 4 5 -5 -1 3 -4 2)
     (-6 -2 1 4 6 3 4 5 -5 -1 3 -4 2)
     (-4 -6 -5 2 4 1 2 3 -5 -3 6 1 -2)
     (2 -5 4 3 -2 6 -1 3 1 -4 6 5)
     (-1 4 -3 -2 -6 1 -5 6 -2 3 -5 6 -4)
     (4 6 5 -2 -4 -1 -2 -3 5 3 -6 -1 2)
     (-3 2 1 5 4 -5 -6 1 -6 -2 4 -5 3)
     (1 -4 3 2 6 -1 5 -6 2 -3 5 -6 4)
     (-5 -1 -6 3 5 2 3 4 -6 -4 2 -3 1))


i-row-transpose (mod interval-list)

Interval row transposition with relation to the mod number.

(i-row-transpose 11 0 '(9 5 -4 10 -7 2 -6 0 1 -3 8 -11))
--> (0 -8 7 1 10 -5 9 -3 -4 6 -11 -2)
 
(i-row-transpose 11 -11 '(-9 5 -4 10 -7 2 -6 0 1 -3 8 -11))
--> (-11 7 -6 0 -9 4 -8 2 3 -5 10 1)
 
(i-row-transpose 11 -11 '(9 5 -4 10 -7 2 -6 0 1 -3 8 -11))
--> (-11 -7 6 0 9 -4 8 -2 -3 5 -10 -1)
 
(i-row-transpose 14 0 '(9 5 -4 10 -7 2 -6 0 1 -3 8 -11 13 -14 12))
--> (0 -11 10 1 13 -8 12 -6 -7 9 -14 -2 4 -5 3)
 
(i-row-transpose 14 11 '(-9 5 -4 10 -7 2 -6 0 1 -3 8 -11 13 -14 12))
--> (11 -7 6 -12 9 -4 8 -2 -3 5 -10 13 0 -1 -14)


i-row-invert (seed mod interval-list &key (assoc nil))

(i-row-invert nil 12 10)
--> -2
 
(i-row-invert nil 14 10)
--> -4
 
(i-row-invert nil 12 -11)
--> 1
 
(i-row-invert nil 14 -11)
--> 3
 
(i-row-invert nil 24 -11)
--> 13

; with :assoc key

(i-row-invert nil 14 -11 :assoc 12)
--> 1 or 13

Mod 14 interval 13 – posibile inversions are -1 and -11.

(i-row-invert nil 14 13 :assoc 12)
--> -1 or -11

In mod 14 the inversion of interval -2 is 10 or 14.
In mod 12 the inversion of -2 is 10 only.

; The seed is used to look the selection

(i-row-invert 0.67 14 '(19 5 -4 10 -7 2 -6 1 -3 8 -11) :assoc 12)
--> (-5 -7 8 -14 5 -14 6 -11 9 -4 1)
 
(i-row-invert 0.23 11
 '((1 -13 8 -11 19 -5 14 10 -7 2 16)
   (19 5 -4 10 -7 2 -6 1 -3 8 -11)) :assoc 12)
 
--> ((-11 1 -4 1 -5 7 -2 -2 5 -10 -4)
     (-5 -7 8 -2 5 -10 6 -11 9 -4 1))

; inversion of direction

(i-row-invert nil nil '(19 5 -4 10 -7 2 -6 1 -3 8 -11) :direction t)
--> (-19 -5 4 -10 7 -2 6 -1 3 -8 11)

; To see all posibile assoc inversion of given interval use
; i-invert-assoc function.

(i-invert-assoc 28 11 :assoc 12)
--> (-1 -23 -13 -25)


i-mod (mod intervals &key (assoc nil))

(i-mod 14 3909)
--> 3
 
(i-mod 14 3909 :assoc 12)
--> 9
 
(setq intervals '(0 1 6 8 -12 14 -32 35 -43 50 -60 -66))
 
(i-mod 12 intervals)
--> (0 1 6 8 0 2 -8 11 -7 2 0 -6)
 
(i-mod 14 intervals)
--> (0 1 6 8 -12 0 -4 7 -1 8 -4 -10)
 
(i-mod 15 intervals :assoc 12)
--> (0 1 6 8 -12 14 -8 11 -7 2 0 -6)


i-invert-assoc (mod n &key (assoc nil))

(i-invert-assoc 14 10)
--> (-4)
 
(i-invert-assoc 14 10 :assoc 12)
--> (-2 -14)
 
(i-invert-assoc 12 14 :assoc 12)
--> (-2 -10)
 
(i-invert-assoc 14 -1 :assoc 12)
--> (11 13)
 
(i-invert-assoc 24 21 :assoc 12)
--> (-9 -3 -15)
 
(i-invert-assoc 14 11 :assoc 12)
--> (-1 -13)
 
(i-invert-assoc 28 11 :assoc 12)
--> (-1 -23 -13 -25)
 
(i-invert-assoc 28 11)
--> (-17)

; List of the entire group of assoc inversions.

(i-invert-assoc 14 10 :assoc 12 :group t)
--> (-2 -14 2 14 -10 10)
 
(i-invert-assoc 24 5 :assoc 12 :group t)
--> (-7 -17 -19 7 17 19 -5 5)


i-invert-dir (intervals)

(i-invert-dir 5)
--> -5
 
(i-invert-dir '(1 -13 8 -11 19 -5 14 10 -7 2 16))
--> (-1 13 -8 11 -19 5 -14 -10 7 -2 -16)
 
(i-invert-dir '((1 -13 8 -11 19 -5 14 10 -7 2 16)
                (9 5 -4 10 -7 2 -6 0 1 -3 8 -11 12 -13 14)))
 
--> ((-1 13 -8 11 -19 5 -14 -10 7 -2 -16)
     (-9 -5 4 -10 7 -2 6 0 -1 3 -8 11 -12 13 -14))


i-remove (n intervals)

; n: ‘oct or number

This function remove any given interval from the list.
Number 12 interval will remove 12 and -12 interval.

The key ‘oct will remove all octave intervals from the list
(0 12 -12 24 -24) etc…

(i-remove '(0) '(9 5 -4 10 -7 2 -6 0 1 -3 8 -11))
--> '(9 5 -4 10 -7 2 -6 1 -3 8 -11)
 
(i-remove 'oct '(9 5 -4 10 -7 2 -6 0 1 -3 14 8 -11 12 -13))
--> (9 5 -4 10 -7 2 -6 1 -3 14 8 -11 -13)

with sublists

(i-remove '(0 12 7) '((9 5 -4 10 -7 2 -6) (0 1 -3 14 8 -11 12 -13)))
--> ((9 5 -4 10 2 -6) (1 -3 14 8 -11 -13))