ensemble/add-player [ Methods ]

[ Top ] [ ensemble ] [ Methods ]

DESCRIPTION

 Add a player to an existing ensemble. It will be added at the end of the
 list. 

ARGUMENTS

 - The ensemble object.
 - The new player, either as a player object or symbol.  If the latter this
   becomes the id of the player we'll create. 

OPTIONAL ARGUMENTS

 keyword arguments:
 - :instrument. The id of the instrument in the already existing
   instrument-palette. This is required if the player argument is a symbol.
   Default NIL. 
 - :instrument-palette. An instrument-palette object.  Default =
   +slippery-chicken-standard-instrument-palette+.
 - :midi-channel the midi-channel for the new player
 - :microtones-midi-channel the microtones-midi-channel for the new player

RETURN VALUE

 The player object added.

SYNOPSIS

(defmethod add-player ((e ensemble) player 
                       &key
                         instrument
                         (instrument-palette
                          +slippery-chicken-standard-instrument-palette+)
                         ;; MDE Tue Jul 14 19:08:15 2020, Heidhausen
                         (midi-channel 1)
                         (microtones-midi-channel -1))

ensemble/balanced-load? [ Methods ]

[ Top ] [ ensemble ] [ Methods ]

DATE

 28th August 2014

DESCRIPTION

 Determine whether the playing load is balanced across the players of the
 ensemble. By default, if the least active player is playing 80% of the time
 that the most active player is playing, we'll return T.

ARGUMENTS

 - an ensemble instance

OPTIONAL ARGUMENTS

 keyword arguments:
 - :threshold. A number between 0.0 and 1.0 which represents the lowest
   ratio between the most and least active players.  
 - :stats-fun. One of the player methods which tots up statistics,
   i.e. total-notes, total-degrees, total-duration, or total-bars
 - :ignore. A list of players (symbols) not to count in the sorting.

RETURN VALUE

 T or NIL

SYNOPSIS

(defmethod balanced-load? ((e ensemble) &key (threshold .8) 
                                             (stats-fun #'total-duration)
                                             ignore)

ensemble/get-instrument [ Methods ]

[ Top ] [ ensemble ] [ Methods ]

DATE

 November 2nd 2018, Heidhausen

DESCRIPTION

 Get the instrument object for a player in the ensemble. If the player
 doubles, then the optional <ins> argument is required and should be the ID
 of the instrument as defined in the ensemble's instrument palette
 (e.g. 'flute)  

ARGUMENTS

 - the ensemble object
 - the ID of a player in the ensemble

OPTIONAL ARGUMENTS

 - the ID of an instrument if the given player doubles
 - T or NIL to issue a warning should the instrument not be found.

RETURN VALUE

 The instrument object.

SYNOPSIS

(defmethod get-instrument ((e ensemble) player &optional ins (warn t))

ensemble/get-player [ Methods ]

[ Top ] [ ensemble ] [ Methods ]

DESCRIPTION

 Return a player object from an ensemble, if it exists.

ARGUMENTS

 - An ensemble object.
 - The ID of a player.

RETURN VALUE

 The player object or NIL if there's no such player.

SYNOPSIS

(defmethod get-player ((e ensemble) player)

ensemble/get-players [ Methods ]

[ Top ] [ ensemble ] [ Methods ]

DESCRIPTION

 Return the IDs of the players from a given ensemble object.

ARGUMENTS

 - An ensemble object.

RETURN VALUE

 - A list of symbols that are the player IDs of the given ensemble object. 

EXAMPLE

(let ((ens (make-ensemble 
            'ens
            '((flt ((flute piccolo) :midi-channel 1))
              (clr ((b-flat-clarinet)))
              (tpt ((b-flat-trumpet c-trumpet) :midi-channel 2))
              (vln ((violin))))
            :instrument-palette
            +slippery-chicken-standard-instrument-palette+)))
  (get-players ens))

=> (FLT CLR TPT VLN)

SYNOPSIS

(defmethod get-players ((e ensemble))

ensemble/lotsa-combos [ Methods ]

[ Top ] [ ensemble ] [ Methods ]

DATE

 November 8th 2018, Heidhausen

DESCRIPTION

 Get various permutations of the ensemble players, ranging from a single
 player up to one less than the number of players in the ensemble. This uses
 the shuffle method so is random, but as we use fixed-seed randomness we get
 repeatable results.

 NB This will return groups of players that are mere permutations of each
 others (e.g. (vln vla vc) and (vla vln vc)). As the combo-chord-possible?
 chord method will permutate these to try and find an instrumentation that is
 possible, you might think there's no point accepting permutations in this
 method. However, which combination (i.e. instruments in any given order) is
 first deemed playable for any given chord will determine the voicing
 selected, so different results can be expected.

ARGUMENTS

 - the ensemble object

OPTIONAL ARGUMENTS

 - an integer to determine the number of times we permutate for any given
 number of players. Note that depending on the number of players in the
 ensemble and the number we're looking to put into a combo, we might not
 always be able to hit this target (e.g. there are only 6 possible
 permutations of three values). Default = 7.

RETURN VALUE

 a list of lists of player IDs.

EXAMPLE

(lotsa-combos (make-ensemble 
              'ens
              '((flt ((flute piccolo)))
                (clr ((b-flat-clarinet)))
                (bsn bassoon)
                (tpt ((b-flat-trumpet c-trumpet))) 
                (trb tenor-trombone)
                (tb tuba)
                (vln ((violin))))))
-->
((CLR FLT TRB BSN TB VLN) (TRB FLT CLR BSN TB TPT) (TB TRB FLT VLN TPT BSN)
 (CLR BSN TPT TB TRB FLT) (FLT TPT VLN BSN TRB TB) (FLT TPT BSN VLN TB CLR)
 (TPT FLT VLN CLR TB TRB) (BSN CLR TB TRB FLT) (TB FLT BSN VLN TPT)
 (FLT TPT BSN CLR TB) (FLT TRB CLR VLN TB) (BSN CLR VLN TPT TRB)
 (BSN TRB FLT TB CLR) (FLT CLR TPT TB VLN) (TRB CLR TPT TB) (FLT VLN TB TRB)
 (TRB VLN TB CLR) (TB VLN TRB BSN) (TPT TRB CLR BSN) (CLR FLT TRB VLN)
 (FLT TPT TRB CLR) (TPT CLR FLT) (TB TRB FLT) (TRB VLN FLT) (TB TPT CLR)
 (FLT BSN TPT) (FLT VLN BSN) (TB TPT TRB) (TPT FLT) (CLR TRB) (FLT CLR)
 (TRB CLR) (BSN CLR) (TRB TB) (BSN TPT) (FLT CLR BSN TPT TRB TB VLN) (FLT)
 (CLR) (BSN) (TPT) (TRB) (TB) (VLN))

(lotsa-combos (make-ensemble 
              'ens
              '((flt ((flute piccolo)))
                (clr ((b-flat-clarinet)))
                (bsn bassoon)
                (tpt ((b-flat-trumpet c-trumpet))) 
                (trb tenor-trombone)
                (tb tuba)
                (vln ((violin))))) 
              10) ; <<--- get more combos
-->
((CLR TPT TB FLT TRB VLN) (BSN TRB VLN TB TPT CLR) (TB CLR FLT TRB BSN TPT)
 (TPT CLR BSN FLT VLN TRB) (VLN BSN TPT CLR TB TRB) (TRB BSN VLN TPT TB CLR)
 (TB TRB CLR VLN FLT BSN) (CLR TPT VLN TB FLT TRB) (TRB BSN VLN CLR FLT TPT)
 (TPT FLT CLR TB TRB VLN) (TPT TRB VLN BSN CLR) (BSN TB VLN TPT FLT)
 (BSN FLT TRB CLR TPT) (BSN TPT FLT CLR TB) (VLN TB TRB TPT FLT)
 (FLT TRB BSN TB VLN) (FLT CLR BSN TB TPT) (TRB FLT VLN TPT BSN)
 (BSN TPT TB TRB FLT) (TPT VLN BSN TRB TB) (BSN VLN TB CLR) (VLN CLR TB TRB)
 (CLR TB TRB FLT) (FLT BSN VLN TPT) (TPT BSN CLR TB) (TRB CLR VLN TB)
 (CLR VLN TPT TRB) (TRB FLT TB CLR) (CLR TPT TB VLN) (TRB CLR TPT TB)
 (VLN TB TRB) (VLN TB CLR) (VLN TRB BSN) (TRB CLR BSN) (FLT TRB VLN)
 (TPT TRB CLR) (TPT CLR FLT) (TB TRB FLT) (TRB VLN FLT) (TB TPT CLR) (VLN BSN)
 (TPT TRB) (TPT FLT) (CLR TRB) (FLT CLR) (TRB CLR) (BSN CLR) (TRB TB) (BSN TPT)
 (FLT CLR BSN TPT TRB TB VLN) (FLT) (CLR) (BSN) (TPT) (TRB) (TB) (VLN))

SYNOPSIS

(defmethod lotsa-combos ((e ensemble) &optional (try 7))

ensemble/make-ensemble [ Functions ]

[ Top ] [ ensemble ] [ Functions ]

DESCRIPTION

 Make an ensemble object, specifying the players and associated
 instruments.  

 NB: If you have an ensemble with a player doubling two instruments, be sure
     to indicate some keyword argument or other as 
     (fl1 ((piccolo violin) :midi-channel 1)) works but 
     (fl1 ((piccolo violin))) thinks that piccolo is a nested ensemble!!!

ARGUMENTS

 - An ID consisting of a symbol, string or number.
 - A list of 2-element sublists that define the ensemble. See the above
   comment on adding a keyword argument for doubling players. An existing
   ensemble object can be passed here whereupon it will be cloned and the ID
   will be changed to the (new) given ID if it's not NIll. In this case
   however the keyword arguments will be ignored.

OPTIONAL ARGUMENTS

 keyword arguments:
 - :instrument-palette. An instrument palette object. Default = 
    +slippery-chicken-standard-instrument-palette+
 - :bar-line-writers. Obsolete as no longer used.

RETURN VALUE

 An ensemble object.

EXAMPLE

(let ((ens (make-ensemble 
              'ens
              '((flt ((flute piccolo) :midi-channel 1))
                (clr ((b-flat-clarinet))))
              :instrument-palette
              +slippery-chicken-standard-instrument-palette+)))
  (print ens))

=>

ENSEMBLE: bar-line-writers: NIL
          players: (FLT CLR)
          (id instrument-palette): SLIPPERY-CHICKEN-STANDARD-INSTRUMENT-PALETTE
RECURSIVE-ASSOC-LIST: recurse-simple-data: T
                      num-data: 2
                      linked: T
                      full-ref: NIL
ASSOC-LIST: warn-not-found T
CIRCULAR-SCLIST: current 0
SCLIST: sclist-length: 2, bounds-alert: T, copy: T
LINKED-NAMED-OBJECT: previous: NIL, this: NIL, next: NIL
NAMED-OBJECT: id: ENS, tag: NIL, 
data: (
PLAYER: (id instrument-palette): SLIPPERY-CHICKEN-STANDARD-INSTRUMENT-PALETTE 
doubles: T, cmn-staff-args: NIL
LINKED-NAMED-OBJECT: previous: NIL, this: (FLT), next: (CLR)
NAMED-OBJECT: id: FLT, tag: NIL, 
data: 
[...]
data: (
INSTRUMENT: lowest-written: 
[...]
NAMED-OBJECT: id: FLUTE, tag: NIL, 
[...]
INSTRUMENT: lowest-written: 
[...]
NAMED-OBJECT: id: PICCOLO, tag: NIL, 
[...]
PLAYER: (id instrument-palette): SLIPPERY-CHICKEN-STANDARD-INSTRUMENT-PALETTE 
doubles: NIL, cmn-staff-args: NIL
LINKED-NAMED-OBJECT: previous: (FLT), this: (CLR), next: NIL
NAMED-OBJECT: id: CLR, tag: NIL, 
data: 
INSTRUMENT: lowest-written: 
[...]
NAMED-OBJECT: id: B-FLAT-CLARINET, tag: NIL, 
)

SYNOPSIS

(defun make-ensemble (id ensemble
                      &key bar-line-writers
                        (instrument-palette 
                         +slippery-chicken-standard-instrument-palette+))

ensemble/num-notes [ Methods ]

[ Top ] [ ensemble ] [ Methods ]

DESCRIPTION

 Get the number of attacked notes in a given slippery-chicken object. This
 method accesses the ensemble object within the given slippery-chicken
 object to perform this task.

ARGUMENTS

 - An ensemble object.

RETURN VALUE

 An integer that is the total number of attacked notes in the given
 slippery-chicken object.

EXAMPLE

(let ((mini
       (make-slippery-chicken
        '+mini+
        :ensemble '(((vn (violin :midi-channel 1))
                     (vc (cello :midi-channel 2))))
        :set-palette '((1 ((f3 g3 a3 b3 c4 d4 e4 f4))))
        :set-map '((1 (1 1 1 1 1)))
        :rthm-seq-palette '((1 ((((2 4) e e e e))
                                :pitch-seq-palette ((1 2 3 4)))))
        :rthm-seq-map '((1 ((vn (1 1 1 1 1))
                            (vc (1 1 1 1 1))))))))
  (num-notes (ensemble mini)))

=> 40

SYNOPSIS

(defmethod num-notes ((e ensemble))

ensemble/num-players [ Methods ]

[ Top ] [ ensemble ] [ Methods ]

DESCRIPTION

 Get the number of players in a given ensemble object.

ARGUMENTS

 - An ensemble object.

RETURN VALUE

 - An integer.

EXAMPLE

(let ((ens (make-ensemble 
            'ens
            '((flt ((flute piccolo) :midi-channel 1))
              (clr ((b-flat-clarinet)))
              (tpt ((b-flat-trumpet c-trumpet) :midi-channel 2))
              (vln ((violin))))
            :instrument-palette
            +slippery-chicken-standard-instrument-palette+)))
  (num-players ens))

=> 4

SYNOPSIS

(defmethod num-players ((e ensemble))

ensemble/players-exist [ Methods ]

[ Top ] [ ensemble ] [ Methods ]

DESCRIPTION

 Produce an error message and drop into the debugger if the specified
 player IDs are not found within the given ensemble object.

ARGUMENTS

 - An ensemble object.
 - A list of symbols that are the IDs of the players sought.

RETURN VALUE

 T if the specified player IDs are present within the given ensemble object,
 otherwise drops into the debugger with an error.

EXAMPLE

;;; Returns NIL if a player with the specified ID is found in the given
;;; ensemble object.
(let ((ens (make-ensemble 
            'ens
            '((flt ((flute piccolo) :midi-channel 1))
              (clr ((b-flat-clarinet)))
              (tpt ((b-flat-trumpet c-trumpet) :midi-channel 2))
              (vln ((violin))))
            :instrument-palette
            +slippery-chicken-standard-instrument-palette+)))
  (players-exist ens '(vln)))

=> T

;; Drops into the debugger with an error if no player with the specified ID is
;; found in the given ensemble object.
(let ((ens (make-ensemble 
            'ens
            '((flt ((flute piccolo) :midi-channel 1))
              (clr ((b-flat-clarinet)))
              (tpt ((b-flat-trumpet c-trumpet) :midi-channel 2))
              (vln ((violin))))
            :instrument-palette
            +slippery-chicken-standard-instrument-palette+)))
  (players-exist ens '(vla)))

=>
ensemble::players-exist: VLA is not a member of the ensemble
   [Condition of type SIMPLE-ERROR]

SYNOPSIS

(defmethod players-exist ((e ensemble) players)

ensemble/set-staff-names [ Methods ]

[ Top ] [ ensemble ] [ Methods ]

DATE

 November 27th 2021, Heidhausen

DESCRIPTION

 Set the staff-names slot of players in the ensemble. These will be used
 instead of the instruments' staff-names slot when writing the score. In fact
 the new names will be passed down to the instrument objects.

ARGUMENTS

 - the ensemble object

OPTIONAL ARGUMENTS

 - names: can be nil, whereup all the player names will be passed down to the
   instrument objects as the staff-name (as a downcased string). Or can be a
   list of player (symbols) whereupon the same will happen. Or it can be a
   list of (player staff-name) pairs where the staff-name will be downcased,
   if a symbol, or used directly if a string. If the player is
   multi-instrumental the staff-name can itself be a list whereupon the
   symbol/string will be handled similarly but the order should be the same
   as the list of instruments passed when initialising the player

RETURN VALUE

 T

SYNOPSIS

(defmethod set-staff-names ((e ensemble) &optional names short-names)

ensemble/sort-players [ Methods ]

[ Top ] [ ensemble ] [ Methods ]

DATE

 27th August 2013

DESCRIPTION

 Return a hierarchical list of players sorted by e.g. how much they're
 playing. 

ARGUMENTS

 - An ensemble object

OPTIONAL ARGUMENTS

 keyword arguments:
 - :stats-fun. One of the player methods which tots up statistics,
    i.e. total-notes, total-degrees, total-duration, or total-bars
 - :ignore. A list of players (symbols) not to count in the sorting.

RETURN VALUE

 A list of all the players in the ensemble ordered by its statistics.

SYNOPSIS

(defmethod sort-players ((e ensemble) &key (stats-fun #'total-duration)
                                        ignore print)

ensemble/tessitura [ Methods ]

[ Top ] [ ensemble ] [ Methods ]

DESCRIPTION

 Get the average pitch of a given slippery-chicken object. This method
 accesses the ensemble object within the given slippery-chicken object to
 perform this task.

 NB: This method processes data in relationship to degrees of the current
     tuning system (scale), which is quarter-tone by default. It is
     therefore possible, when generating a piece using only chromatic
     pitches but within a non-chromatic tuning to get microtonal results.

ARGUMENTS

 - An ensemble object.

RETURN VALUE

 An integer that is the average pitch of the given slippery-chicken object
 in degrees.

EXAMPLE

;;; Change the tuning to chromatic first to get an accurate result:
(in-scale :chromatic)

=> #<tuning "chromatic-scale">

(let ((mini
       (make-slippery-chicken
        '+mini+
        :ensemble '(((vn (violin :midi-channel 1))
                     (vc (cello :midi-channel 2))))
        :set-palette '((1 ((f3 g3 a3 b3 c4 d4 e4 f4))))
        :set-map '((1 (1 1 1 1 1)))
        :rthm-seq-palette '((1 ((((2 4) e e e e))
                                :pitch-seq-palette ((1 2 3 4)))))
        :rthm-seq-map '((1 ((vn (1 1 1 1 1))
                            (vc (1 1 1 1 1))))))))
  (tessitura (ensemble mini)))

=> C4

SYNOPSIS

(defmethod tessitura ((e ensemble))

recursive-assoc-list/ensemble [ Classes ]

[ Top ] [ recursive-assoc-list ] [ Classes ]

NAME

 ensemble

 File:             ensemble.lsp

 Class Hierarchy:  named-object -> linked-named-object -> sclist -> 
                   circular-sclist -> assoc-list -> recursive-assoc-list ->
                   ensemble

 Version:          1.0.12

 Project:          slippery chicken (algorithmic composition)

 Purpose:          Implementation of the ensemble class.

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

 Creation date:    4th September 2001

 $$ Last modified:  15:30:40 Sat Jan 27 2024 CET

 SVN ID: $Id$