unit/% [ Units ]
Name
%
File
unit.lsp
Description
Numeric unit representing a percentage-value.
Synopsis
(make-unit % number)
unit/%-> [ Functions ]
[ Top ] [ unit ] [ Functions ]
Name
%->
File
unit.lsp
Description
Takes a value, a range and a unit and outputs the value as a plain number, converted to the unit. The value may be an instance of the %-unit-class, in which case the absolute value will be determined by the given range, another kind of unit, given it can be converted to the target-unit, or a plain number, in which case it will be interpreted as a percentage-value.
Arguments
value: A unit object convertable to unit (may be a %-object) or a number, interpreted as %-value min: the minimum of the target-range max: the maximum of the target-range unit: the unit to convert to.
Optional Arguments
float: Indicates whether to always return a float (default: t). round: Indicates whether to round the result to an integer (default: nil).
Return Value
number
Synopsis
(defun %-> (value min max unit &optional (float t) (round nil))
Example
(%-> 1 0 1 'secs) --> 0.01 (%-> (secs 1) 0 1 'secs) --> 1.0
unit/amp [ Units ]
Name
amp
File
unit.lsp
Description
Numeric unit representing an amplitude. It can e.g. be seen as the relative amplitude of an audio signal.
Synopsis
(make-unit amp number :min 0 :max 1)
unit/apply-with-unit [ Functions ]
[ Top ] [ unit ] [ Functions ]
Name
apply-with-unit
File
unit.lsp
Description
Calls proc with an argument list that may include properties. The returned type equals the type of the first propertie in args.
Arguments
proc: A function args: A list of arguments to proc
Return Value
any
Synopsis
(defun apply-with-unit (proc args) "Calls proc with an argument list that may include properties. The returned type equals the type of the first unit in args."
Example
(apply-with-unit #'+ (list (midinote 69) 1)) --> [70 midinote]
unit/beats [ Units ]
Name
beats
File
unit.lsp
Description
Numeric unit representing a time value in beats. Base unit: secs If no tempo is set, it will default to 60.
Slots
tempo
Synopsis
(make-unit beats number :base-unit secs :direct-slots (tempo) :conversion-to-base (/ (* value 60) (slot-value obj 'tempo)) :conversion-from-base value
unit/cmeter [ Units ]
Name
cmeter
File
unit.lsp
Description
Numeric unit representing a distance in centi-meters.
Synopsis
(make-unit cmeter number :base-unit meter :conversion-to-base (/ value 100) :conversion-from-base (* value 100))
unit/convert [ Functions ]
[ Top ] [ unit ] [ Functions ]
Name
convert
File
unit.lsp
Description
Converts a unit from one type to another. Various methods are defined for different properties. In case a unit is not convertable to the specified type, an error is signaled.
Arguments
name: The object
Return Value
a unit-object
Synopsis
(defgeneric convert (obj unit))
Example
(value 1) -> 1 (value (secs 1)) -> 1 (value (secs 1) 'mins) -> 1/60 (value (make-event :pitch (midinote 60)) 'hz 'pitch) -> 261.62555
unit/dbfs [ Units ]
Name
dbfs
File
unit.lsp
Description
Numeric unit representing an amplitude in db-fullscale. The maximum amplitude is 0, the minimum amplitude is -infinity. Base unit: amp
Synopsis
(make-unit dbfs number :min -18446744073709551616 :max 0 :base-unit amp :conversion-to-base (expt 10 (/ value 20)) :conversion-from-base (if (zerop value) -18446744073709551616 (* 20 (log value 10))))
unit/dmeter [ Units ]
Name
dmeter
File
unit.lsp
Description
Numeric unit representing a distance in deci-meters.
Synopsis
(make-unit dmeter number :base-unit meter :conversion-to-base (/ value 10) :conversion-from-base (* value 10))
unit/dynamic-symbol [ Units ]
Name
amp
File
unit.lsp
Description
Unit representing a dynamic value as a symbol (piano, forte, etc.). It is in some cases possible to use this unit in calculations, as conversions to midivelocities are implemented. But be careful: The conversion has to happen before the calculation, as any procedure like u+, etc. will signal an error when called with a symbol. Base unit: midivelocity
Synopsis
(make-unit dynamic-symbol symbol :base-unit midivelocity :conversion-to-base (case value (fff 127) (ff 112) (f 96) (mf 80) (mp 64) (p 48) (pp 32) (ppp 16)) :conversion-from-base (cond ((> value 112) 'fff) ((> value 96) 'ff) ((> value 80) 'f) ((> value 64) 'mf) ((> value 48) 'mp) ((> value 32) 'p) ((> value 16) 'pp) ((> value 0) 'ppp) ((<= value 0) nil))
unit/funcall-with-unit [ Functions ]
[ Top ] [ unit ] [ Functions ]
Name
funcall-with-unit
File
unit.lsp
Description
See documentation of unit/apply-with-unit for more info.
Synopsis
(defun funcall-with-unit (function &rest arguments)
unit/hours [ Units ]
Name
hours
File
unit.lsp
Description
Numeric unit representing a time value in hours. Base unit: secs
Synopsis
(make-unit hours number :base-unit secs :conversion-to-base (* value 3600) :conversion-from-base (/ value 3600))
unit/hz [ Units ]
Name
hz
File
unit.lsp
Description
Numeric unit representing a frequency value in hz. Base unit: secs
Synopsis
(make-unit hz number :min 0 :base-unit secs :conversion-to-base (if (zerop value) 0 (/ 1 value)) :conversion-from-base (if (zerop value) 0 (/ 1 value)))
unit/inch [ Units ]
Name
inch
File
unit.lsp
Description
Numeric unit representing a distance in inches.
Synopsis
(make-unit inch number :base-unit meter :conversion-to-base (* value 0.0254) :conversion-from-base (/ value 0.0254))
unit/khz [ Units ]
Name
khz
File
unit.lsp
Description
Numeric unit representing a frequency value in khz. Base unit: hz
Synopsis
(make-unit khz number :min 0 :base-unit hz :conversion-to-base (* 1000 value) :conversion-from-base (/ value 1000))
unit/make-unit [ Functions ]
[ Top ] [ unit ] [ Functions ]
Name
make-unit
File
unit.lsp
Description
Define a new unit. Creates a new class (subclass of either unit or numeric-unit, if the value-type is numeric), as well es a function for creating the unit and conversion- methods.
Arguments
name: The object
Return Value
any
Synopsis
(defmacro make-unit (name value-type &key (function-name name) direct-slots make-proc-body base-unit conversion-to-base conversion-from-base min max)
Example
(value 1) -> 1 (value (secs 1)) -> 1 (value (secs 1) 'mins) -> 1/60 (value (make-event :pitch (midinote 60)) 'hz 'pitch) -> 261.62555
unit/meter [ Units ]
Name
meter
File
unit.lsp
Description
Numeric unit representing a distance in meters.
Synopsis
(make-unit meter number)
unit/microsecs [ Units ]
Name
microsecs
File
unit.lsp
Description
Numeric unit representing a time value in microeconds. Base unit: secs
Synopsis
(make-unit microsecs number :base-unit secs :conversion-to-base (/ value 1000000) :conversion-from-base (* value 1000000))
unit/midinote [ Units ]
Name
midinote
File
unit.lsp
Description
Numeric unit representing a frequency value as midinote. Base unit: hz
Synopsis
(make-unit midinote number :min 0 :max 127 :base-unit hz :conversion-to-base (if (zerop value) 0 (* 440 (expt 2 (/ (- value 69) 12)))) :conversion-from-base (if (zerop value) 0 (+ 69 (* 12 (log (/ value 440) 2)))))
unit/midivelocity [ Units ]
Name
midivelocity
File
unit.lsp
Description
Numeric unit representing an amplitude as a midivelocity. Base unit: amp
Synopsis
(make-unit midivelocity number :min 0 :max 127 :base-unit amp :conversion-to-base (/ value 127) :conversion-from-base (* value 127))
unit/mins [ Units ]
Name
mins
File
unit.lsp
Description
Numeric unit representing a time value in minutes. Base unit: secs
Synopsis
(make-unit mins number :base-unit secs :conversion-to-base (* value 60) :conversion-from-base (/ value 60))
unit/mmeter [ Units ]
Name
mmeter
File
unit.lsp
Description
Numeric unit representing a distance in milli-meters.
Synopsis
(make-unit mmeter number :base-unit meter :conversion-to-base (/ value 1000) :conversion-from-base (* value 1000))
unit/msecs [ Units ]
Name
msecs
File
unit.lsp
Description
Numeric unit representing a time value in milliseconds. Base unit: secs
Synopsis
(make-unit msecs number :base-unit secs :conversion-to-base (/ value 1000) :conversion-from-base (* value 1000))
unit/numeric-unit [ Classes ]
Name
numeric-unit
File
unit.lsp
Description
A unit is numeric if its value is a number. If no value is specified for a numeric-unit-object, it will default to 0.
Slots
See superclass unit
Synopsis
(defclass numeric-unit (unit) () (:default-initargs :value 0))
unit/secs [ Units ]
Name
secs
File
unit.lsp
Description
Numeric unit representing a time value in seconds.
Synopsis
(make-unit secs number)
unit/soundfile [ Units ]
Name
soundfile
File
unit.lsp
Description
Unit representing a soundfile. The value is the path to the file.
Slots
start-time: The start-time of the desired excerpt (default: 0). duration: The duration of the desired excerpt (if applicable, may default to the entire duration when the clm-package can be used to detect it). pitch: The pitch of the soundfile (if applicable).
Synopsis
(make-unit soundfile string :function-name make-soundfile :direct-slots (start-time duration pitch)
unit/thz [ Units ]
Name
thz
File
unit.lsp
Description
Numeric unit representing a frequency value in thz. Base unit: hz What? Terahertz? This unit is added to Comic to represent different colors in the visible spectrum of light.
Synopsis
(make-unit thz number :min 0 :base-unit hz :conversion-to-base (* (expt 10 12) value) :conversion-from-base (* (expt 10 -12) value))
unit/u-... [ Functions ]
[ Top ] [ unit ] [ Functions ]
Name
u-... (functions that can handle units)
File
unit.lsp
Description
Comic provides a collection of function that are derived from ANSII-CL equivalents and are able to take unit-objects as arguments. The standard collection focusses on - but is not limited to - arithmetic operations. If needed, additional u-functions can be easily defined using cc-make-u-function. You can also use u-funcall or u-apply to run standard-procedures with unit-objects as arguments. Some standard u-functions are: u+, u-, u*, u/, u-mod, u-round, u-ceiling, u-floor, u=, u>, u< u>=, u<=, u-eq, u-equal, u1+, u1-, u-abs, u-exp, u-expt, u-log, u-float, u-zerop, u-sqrt (See Synopsis for an up-to-date list)
Synopsis
(defmacro cc-make-u-function (u-name function-name) `(defun ,u-name (&rest args) (apply-with-unit #',function-name args))) (cc-make-u-function u+ +) (cc-make-u-function u- -) (cc-make-u-function u* *) (cc-make-u-function u/ /) (cc-make-u-function u-mod mod) (cc-make-u-function u-round round) (cc-make-u-function u-ceiling ceiling) (cc-make-u-function u-floor floor) (cc-make-u-function u-min min) (cc-make-u-function u-max max) (cc-make-u-function u= =) (cc-make-u-function u> >) (cc-make-u-function u< <) (cc-make-u-function u>= >=) (cc-make-u-function u<= <=) (cc-make-u-function u-eq eq) (cc-make-u-function u-equal equal) (cc-make-u-function u1+ 1+) (cc-make-u-function u1- 1-) (cc-make-u-function u-abs abs) (cc-make-u-function u-exp exp) (cc-make-u-function u-expt expt) (cc-make-u-function u-log log) (cc-make-u-function u-float float) (cc-make-u-function u-zerop zerop) (cc-make-u-function u-sqrt sqrt) (cc-make-u-function u-sin sin) (cc-make-u-function u-cos cos) (cc-make-u-function u-random random)
Example
(with-unit (> (mins 3) (secs 2))) --> T (with-unit (concatenate 'string "Hello " "World")) --> "Hello World" N.B.: (with-unit (= (mins 1) 1)) --> T Values with units can be compared with plain numbers. Handle with care...
unit/unit [ Classes ]
Name
unit
File
unit.lsp
Description
A unit is an object with a value slot, holding a certain type of value. The objects type defines the way the value is interpreted. E.g.: <#100 Hz> is an object of type hz with a value of 100. Using unit-objects, values can be used in calculations directly, letting comic handle the conversion if possible. The functions are named u+, u- and so forth (see u-...). Comic does not check, whether the values given can be handled by these functions. The use of them is best suited for - but not restricted to - numeric-units. A unit object can and should be created using make-unit.
Slots
value base-unit value-type min-value max-value
Synopsis
(defclass unit () ((value :initarg :value :initform nil) (base-unit :initarg :base-unit :initform nil :reader base-unit :allocation :class) (value-type :initarg :value-type :initform nil :reader value-type :allocation :class) (min-value :initarg :min-value :initform nil :reader min-value :allocation :class) (max-value :initarg :max-value :initform nil :reader max-value :allocation :class)))
unit/unit-p [ Functions ]
[ Top ] [ unit ] [ Functions ]
Name
unit-p
File
unit.lsp
Description
Tests if an object is a unit.
Arguments
obj: The object
Return Value
boolean
Example
(unit-p (hz 100)) --> t
unit/value [ Methods ]
Name
value
File
unit.lsp
Description
Accesses the value slot of a unit-object. Can access values of events directly when unit-name is set (see event-method). Can convert value to another unit directly when unit is set. For any non-unit, the input is simply returned.
Arguments
object: The object unit: unit to convert to. error is signaled if conversion fails. unit-name: The name of the unit to access. Only used object is an event
Synopsis
(defgeneric value (object &optional unit slot-name))
Example
(value 1) -> 1 (value (secs 1)) -> 1 (value (secs 1) 'mins) -> 1/60
unit/videofile [ Units ]
Name
videofile
File
unit.lsp
Description
Unit representing a videofile. The value is the path to the file.
Slots
start-time: The start-time of the desired excerpt (default: 0). duration: The duration of the desired excerpt (if applicable). frate: frame-rate of the videofile. height / width: pixel dimensions of the videofile.
Synopsis
(make-unit videofile string :function-name make-videofile :direct-slots (start-time duration frate height width)
unit/xsampa [ Units ]
Name
xsampa
File
unit.lsp
Description
Unit representing spoken language in the x-sampa-format. Conversion from any string to x-sampa is implemented, although pretty rough: May be enough to produce language-like sounds with a voice-synthesis-program, but not enough to produce understandable spoken language in any case. The main point here is to exclude all characters that do NOT belong to the x-sampa- system. A list of legal characters is available here: https://en.wikipedia.org/wiki/X-SAMPA
Synopsis
(make-unit xsampa string
unit/yard [ Units ]
Name
yard
File
unit.lsp
Description
Numeric unit representing a distance in yards.
Synopsis
(make-unit yard number :base-unit meter :conversion-to-base (* value 0.9144) :conversion-from-base (/ value 0.9144))