activity-levels/active [ Methods ]

[ Top ] [ activity-levels ] [ Methods ]

DESCRIPTION

 Returns t or nil depending on whether we're active at this point.  The
 object remembers where we were last time; this means if we change level
 before getting to the end of a ten-list, we'll pick up where we left off
 next time we return to that level.  <level> can be a floating point number:
 in this case it will be rounded. But <level> must be between 0 and 10,
 where 0 is always inactive, 10 is always active, and anything inbetween
 will use the data lists circularly.

ARGUMENTS

 - the activity-levels object

OPTIONAL ARGUMENTS

 - the activity-level number we want to test. Although optional, it's
   expected that this argument will usually be defined.  Between 0 and 10.
   Default = 5.

RETURN VALUE

 T or NIL

EXAMPLE

(let ((al (make-al)))
  (print (loop for i below 15 collect (active al 0)))
  (print (loop for i below 15 collect (active al 5)))
  (print (loop for i below 15 collect (active al 1)))
  (print (loop for i below 15 collect (active al 9)))
  (loop for i below 15 collect (active al 10)))

=>
(NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL) 
(T T NIL NIL T NIL T T NIL NIL NIL T NIL T NIL) 
(T NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL T NIL) 
(T T NIL T T T T T T T T T T T NIL) 
(T T T T T T T T T T T T T T T)

SYNOPSIS

(defmethod active ((al activity-levels) &optional level)

activity-levels/flicker-round [ Methods ]

[ Top ] [ activity-levels ] [ Methods ]

DATE

 January 19th 2021

DESCRIPTION

 Rounding is a cut-and-dry operation, usually. The part after the floating
 point determines whether we round up or down: 0.5 or above goes up,
 otherwise down. In some circumstances it might be preferable to have an area
 in the middle that alternates between up and down. This method uses the
 range between the two optional threshold arguments to select rounding up or
 down: closer to the lower threshold will mean rounding down takes place more
 often than up, but up will still happen occasionally. Similarly as we
 approach the high threshold, rounding up will occur more often. All
 deterministically of course. On the other hand, values outside the
 thresholds will merely round as usual. So if you always want to
 'flicker-round' then set the thresholds to 0 and 1. If you never want to
 round, call round (!) or set the tresholds to 0.5 and 0.5.

ARGUMENTS

 - the activity-levels object
 - the floating point number to 'flicker-round'

OPTIONAL ARGUMENTS

 the low and high threshold values: floating point numbers between 0.0 and
 1.0, where the first optional argument should be less than the second, of
 course. 

RETURN VALUE

 An integer 

EXAMPLE

(let ((al (make-al)))
  (loop for i from 1010 to 1011 by 0.01 collect (flicker-round al i)))
-->
(1010 1010 1010 1010 1010 1010 1010 1010 1010 1010 1010 1010 1010 1010 1010
 1010 1010 1010 1010 1010 1010 1010 1010 1010 1010 1010 1010 1010 1010 1010
 1011 1010 1010 1011 1010 1010 1010 1010 1011 1010 1010 1010 1011 1011 1010
 1010 1010 1011 1011 1011 1010 1010 1011 1011 1011 1010 1011 1011 1011 1011
 1010 1011 1011 1011 1011 1010 1011 1011 1011 1011 1011 1011 1011 1011 1011
 1011 1011 1011 1011 1011 1011 1011 1011 1011 1011 1011 1011 1011 1011 1011
 1011 1011 1011 1011 1011 1011 1011 1011 1011 1011)

SYNOPSIS

(defmethod flicker-round ((al activity-levels) float
                          &optional (threshold-low 0.3) (threshold-high 0.7))

activity-levels/make-al [ Functions ]

[ Top ] [ activity-levels ] [ Functions ]

DESCRIPTION

 Make an activities-level object for determining (deterministically) on a
 call-by-call basis whether a process is active or not (boolean).  This is
 determined by nine 10-element lists (actually three versions of each) of
 hand-coded 1s and 0s, each list representing an 'activity-level' (how
 active the process should be).  The first three 10-element lists have only
 one 1 in them, the rest being zeros.  The second three have two 1s,
 etc. Activity-levels of 0 and 10 would return never active and always
 active respectively.

ARGUMENTS

 None required.

OPTIONAL ARGUMENTS

 start-at (default NIL): which of the three 10-element lists to start with
 (reset to).  Should be 0, 1, or 2 though if NIL will default to 0.

RETURN VALUE

 The activities-level object.

SYNOPSIS

(defun make-al (&optional start-at id)

activity-levels/reset [ Methods ]

[ Top ] [ activity-levels ] [ Methods ]

DESCRIPTION

 Reset the activity-levels object to restart at the first element of the 1st
 (or user-specificed) 10-element list. 

ARGUMENTS

 The activity-levels object. 

OPTIONAL ARGUMENTS

 start-at: should be between 0 and 2; it indicates which of the 10-lists
 we're going to start with.  Default = 0.

RETURN VALUE

 T

SYNOPSIS

(defmethod reset ((al activity-levels) &optional (start-at 0) ignore)

named-object/activity-levels [ Classes ]

[ Top ] [ named-object ] [ Classes ]

NAME

 activity-levels

 File:             activity-levels.lsp

 Class Hierarchy:  named-object -> activity-levels

 Version:          1.1.0

 Project:          slippery chicken (algorithmic composition)

 Purpose:          Class used in rthm-chain.  Used on a call-by-call basis
                   to determine (deterministically) whether a process is
                   active or not (boolean).

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

 Creation date:    4th February 2010

 $$ Last modified:  10:55:22 Fri Mar  1 2024 CET

 SVN ID: $Id$