palette/pitch-seq-palette [ Classes ]

[ Top ] [ palette ] [ Classes ]

NAME

 pitch-seq-palette

 File:             pitch-seq-palette.lsp

 Class Hierarchy:  named-object -> linked-named-object -> sclist -> 
                   circular-sclist -> assoc-list -> recursive-assoc-list ->
                   palette -> pitch-seq-palette

 Version:          1.0.12

 Project:          slippery chicken (algorithmic composition)

 Purpose:          Implementation of the pitch-seq-palette class.

 Author:           Michael Edwards: m@michael-edwards.org

 Creation date:    19th February 2001

 $$ Last modified:  08:10:53 Thu Feb  1 2024 CET

 SVN ID: $Id$

pitch-seq-palette/add-inversions [ Methods ]

[ Top ] [ pitch-seq-palette ] [ Methods ]

DESCRIPTION

 Add inversions of the existing pitch-seq objects in a given
 pitch-seq-palette object to the end of that pitch-seq-palette object. (See
 pitch-seq::invert for more details on slippery-chicken inversions.)

ARGUMENTS

 - A pitch-seq-palette object.

RETURN VALUE

 Always returns T.

EXAMPLE

;; Create a pitch-seq-palette object and print the DATA of the pitch-seq
;; objects it contains; then apply the add-inversions method and print the same
;; DATA to see the changes
(let ((mpsp (make-psp 'mpsp 5 '((2 5 3 1 4)
                                (1 4 2 5 3)
                                (5 1 3 2 4)
                                (2 3 4 5 1)
                                (3 2 4 1 5)))))
  (print (loop for ps in (data mpsp)
            collect (data ps)))
  (add-inversions mpsp)
  (print (loop for ps in (data mpsp)
            collect (data ps))))

=>
((2 5 3 1 4) (1 4 2 5 3) (5 1 3 2 4) (2 3 4 5 1) (3 2 4 1 5)) 

((2 5 3 1 4) (1 4 2 5 3) (5 1 3 2 4) (2 3 4 5 1) (3 2 4 1 5) (4 1 3 5 2)
 (5 2 4 1 3) (1 5 3 4 2) (4 3 2 1 5) (3 4 2 5 1))

SYNOPSIS

(defmethod add-inversions ((psp pitch-seq-palette))

pitch-seq-palette/combine [ Methods ]

[ Top ] [ pitch-seq-palette ] [ Methods ]

DESCRIPTION

 Create a new pitch-seq-palette object by combining the pitch-seq lists from
 one pitch-seq-palette object with those of another.

 The method combines the contents of the two given rthm-seq-palette objects
 consecutively; i.e., the first pitch-seq object of the first
 pitch-seq-palette is combined with the first pitch-seq object of the other,
 then the second with the second, the third with the third etc. 

 If one pitch-seq-palette object contains more pitch-seq objects than the
 other, the method cycles through the shorter one until all of the members
 of the longer one have been handled. The new pitch-seq-palette object will
 therefore contain the same number of pitch-seq objects as is in the longest
 of the two starting pitch-seq-palette objects.

 It is not necessary for the lengths of the pitch-seq objects in the two
 starting pitch-seq-palette objects to be the same.

 NB Both pitch-seq-palettes are reset by this method.

ARGUMENTS

 - A first pitch-seq-palette object.
 - A second pitch-seq-palette object.

RETURN VALUE

 A pitch-seq-palette object.

EXAMPLE

;;; Combine two pitch-seq-palette objects of the same length, each of whose
;;; pitch-seqs are the same length
(let ((mpsp1 (make-psp 'mpsp1 5 '((2 5 3 1 4) (1 4 2 5 3) (5 1 3 2 4))))
      (mpsp2 (make-psp 'mpsp2 5 '((2 3 4 5 1) (3 2 4 1 5) (3 2 1 5 4)))))
  (combine mpsp1 mpsp2))

=>
PITCH-SEQ-PALETTE: num-notes: 10, instruments: NIL
PALETTE: 
RECURSIVE-ASSOC-LIST: recurse-simple-data: T
                      num-data: 3
                      linked: NIL
                      full-ref: NIL
ASSOC-LIST: warn-not-found T
CIRCULAR-SCLIST: current 0
SCLIST: sclist-length: 3, bounds-alert: T, copy: T
LINKED-NAMED-OBJECT: previous: NIL, this: NIL, next: NIL
NAMED-OBJECT: id: "MPSP1-MPSP2", tag: NIL, 
data: (
PITCH-SEQ: notes: NIL
[...]
data: (2 5 3 1 4 2 3 4 5 1)
PITCH-SEQ: notes: NIL
[...]
data: (1 4 2 5 3 3 2 4 1 5)
[...]       
PITCH-SEQ: notes: NIL
[...]
data: (5 1 3 2 4 3 2 1 5 4)
)

;; When combining pitch-seq-palette objects of different lengths, the method
;; cyles through the shorter of the two
(let ((mpsp1 (make-psp 'mpsp1 5 '((2 5 3 1 4) (1 4 2 5 3) (5 1 3 2 4))))
      (mpsp2 (make-psp 'mpsp2 5 '((2 3 4 5 1) (3 2 4 1 5)))))
  (loop for ps in (data (combine mpsp1 mpsp2)) 
       collect (data ps)))

=> ((2 5 3 1 4 2 3 4 5 1) (1 4 2 5 3 3 2 4 1 5) (5 1 3 2 4 2 3 4 5 1))

;; The two starting pitch-seq-palette objects are not required to have
;; pitch-seq objects of the same length
(let ((mpsp1 (make-psp 'mpsp1 5 '((2 5 3 1 4) (1 4 2 5 3) (5 1 3 2 4))))
      (mpsp2 (make-psp 'mpsp2 3 '((2 3 4) (3 2 4)))))
  (loop for ps in (data (combine mpsp1 mpsp2)) 
       collect (data ps)))

=> ((2 5 3 1 4 2 3 4) (1 4 2 5 3 3 2 4) (5 1 3 2 4 2 3 4))

SYNOPSIS

(defmethod combine ((psp1 pitch-seq-palette) (psp2 pitch-seq-palette))

pitch-seq-palette/make-psp [ Functions ]

[ Top ] [ pitch-seq-palette ] [ Functions ]

DESCRIPTION

 Create a pitch-seq-palette object from an ID, a specified number of notes,
 and a list of lists of numbers representing the pitch curve of the intended
 pitch-seq objects.

ARGUMENTS

 - A symbol that is to be the ID of the pitch-seq-palette to be created. 
 - An integer that is the number of notes there are to be in each pitch-seq
   object created.
 - A list of lists, each of which contained list is a list of numbers
   representing the pitch curve of the intended pitch-seq object.

RETURN VALUE

 A pitch-seq-palette object.

EXAMPLE

;; Returns a pitch-seq-palette object
(make-psp 'mpsp 5 '((2 5 3 1 4)
                    (1 4 2 5 3)
                    (5 1 3 2 4)
                    (2 3 4 5 1)
                    (3 2 4 1 5)))

=> 
PITCH-SEQ-PALETTE: num-notes: 5, instruments: NIL
PALETTE: 
RECURSIVE-ASSOC-LIST: recurse-simple-data: T
                      num-data: 5
                      linked: NIL
                      full-ref: NIL
ASSOC-LIST: warn-not-found T
CIRCULAR-SCLIST: current 0
SCLIST: sclist-length: 5, bounds-alert: T, copy: T
LINKED-NAMED-OBJECT: previous: NIL, this: NIL, next: NIL
NAMED-OBJECT: id: MPSP, tag: NIL, 
data: (
PITCH-SEQ: notes: NIL
[...]
data: (2 5 3 1 4)
PITCH-SEQ: notes: NIL
[...]
data: (1 4 2 5 3)
PITCH-SEQ: notes: NIL
[...]
data: (5 1 3 2 4)
PITCH-SEQ: notes: NIL
[...]
data: (2 3 4 5 1)
PITCH-SEQ: notes: NIL
[...]
data: (3 2 4 1 5)
)

;; Interrupts with an error if any of the <pitch-seqs> lists is not of the
;; length specified by <num-notes>
(make-psp 'mpsp 5 '((1 2 1 1 3)
                    (1 3 2 1 5)
                    (1 3 5 6 7 8)))

=>
pitch-seq-palette::verify-and-store: 
In pitch-seq MPSP-ps-3 from palette MPSP:
Each pitch sequence must have 5 notes (you have 6): 
[...]
 (1 3 5 6 7 8))
   [Condition of type SIMPLE-ERROR]

;; We can also assign instruments to specific pitch-seqs by passing their names
;; (not player names, but instrument names) e.g.
(make-psp 'mpsp 5 '((1 2 1 1 3)
                    ((1 3 2 1 5) violin flute)
                    (1 3 5 6 7)))

SYNOPSIS

(defun make-psp (id num-notes pitch-seqs)

rthm-seq-palette/create-psps-default [ Functions ]

[ Top ] [ rthm-seq-palette ] [ Functions ]

ARGUMENTS

 - An integer that is the number of notes for which a pitch-seq-palette
   object is needed.
 - the pitch-seq data (see documentation for create psps method).  Ideally
   this would only be passed the first time the function is called.

RETURN VALUE

 A list of numbers suitable for use in creating a pitch-seq object.

SYNOPSIS

  (defun create-psps-default (num-notes data-lists)