Skip to content

Core

The core functions and variables that load at launch.

Type: AliasAlias: i64 Value: Pointer Size (on 32 bit systems it is 32, on 64 bit it will be 64 bit)

This should only be necessary if you’re calling foreign functions.

Type: Macro

  1. type : type name
  • i64 : bytesize of this type.

Extempore’s version of size_of (C/C++ function). How much memory is taken up by a particular type. For tuples, and other types built upon memory references, the size takes into account pointer sizes, and not the size of memory pointed to.

($ (size_of i64))

Type: Macro

  1. x : Variable to be incremented. This must be a type that supports basic math functions.
  2. y : Amount to increment x. This must the same type as x.
  • Returns the result. The return value will be the same type as x.

Increments x by y.

($ (let ((x 5)) (inc x 1))) ;; returns 6

Type: Macro

  1. x : Variable to be decremented. This must be a type that supports basic math functions.
  2. y : Amount to decrement x. This must the same type as x.
  • Returns the result. The return value will be the same type as x.

Decrements x by y.

($ (let ((x 5)) (dec x 1))) ;; returns 4

Type: Macro

  1. x : Variable to be compared. This must be a type that supports less than/equal.
  2. y : Variable to be compared. This must the same type as x.
  • Returns the smallest value. The return value will be the same type as x.

Minimum of x and y.

($ (min 3 7)) ;; returns 3

Type: Macro

  1. x : Variable to be compared. This must be a type that supports less than/equal.
  2. y : Variable to be compared. This must the same type as x.
  • Returns the largest value. The return value will be the same type as x.

Returns the largest of the two values.

($ (max 3 7)) ;; returns 7

Type: Macro

  1. x : Input value. Must be a type that supports <>=.
  2. minval : Minimum value in range. Must be same type as x.
  3. maxval : Maximum value in range. Must be same type as x.
  • The return value is the same type as x.

Clamp input value to range. If x < minval it will return minval, if x > maxval it will return maxval. Otherwise it returns x.

($ (clamp 12 0 10)) ;; returns 10

Type: Closure

  • log:[float,float]
  • log:[double,double]

returns the natural logarithm (ln)

Type: Macro

  • float
  • double
  1. x : x value
  2. base : base of the logarithm

Returns log of x with base base

($ (log 100, 10)) ;; log10 of 100 (returns 2)

Type: Macro

  • float
  • double
  1. degrees : x value in degrees
  • Same type as degrees

Converts a value in degrees to radians.

($ (deg2rad 180.0)) ;; returns 3.141593 (pi)

Type: Macro

  • float
  • double
  1. radians : x value in radians
  • Same type as radians

Converts a value in radians to degrees.

($ (rad2deg PI)) ;; returns 180.0

Type: Macro

  • i8
  • i16
  • i32
  1. x - the value that you are testing. Must be an integer of some kind.
  • i1 : 1 if x is even, 0 otherwise

Checks to see if a value is even. Returns a C boolean (i1).

Type: Macro

  • i8
  • i16
  • i32
  1. x - the value that you are testing. Must be an integer of some kind.
  • i1 : 1 if x is odd, 0 otherwise

Checks to see if a value is even. Returns a C boolean (i1).

Constant Type: float Value: Single precision not-a-number

Constant Type: double Value: Double precision not a number

Constant Type: float Value: pi (3.14159…)

Constant Type: float Value: 2 * pi (6.2831…)

Constant Type: float Value: e (base of natural log)

Constant Type: double Value: pi (3.14159…)

Constant Type: double Value: 2 * pi (6.2831…)

Constant Type: double Value: e (base of natural log)

Type: Polymorphic Closure

  • [float]*
  • [double]*
  • [i32,i32]*
  • [i64,i64]*
  • [float,float]*
  • [double,double]*
  • [i32,i32,i32]*
  • [i64,i64,i64]*
  • [float,float,float]*
  • [double,double,double]*

If called with 0 arguments it will return a pseudo random value between 0.0 and 1.0

If called with 1 argument, arg1 it will return a pseudo random value x where 0 <= x < arg1.

If called with 2 arguments, arg1 and arg2 it will return pseudo random values x where arg1 <= x < arg2.

Type: Polymorphic Closure

  • [float,float]*
  • [double,double]*
  1. x : Angle in radians.

Returns tan(x)

Type: Polymorphic Closure

  • [float,float]*
  • [double,double]*
  1. x
  • Angle of x in radians.

Inverse tangent. Returns atan(x)

Type: Polymorphic Closure

  • [float,float]*
  • [double,double]*
  1. x : Angle in radians

Hyperbolic tangent. It returns tanh(x)

Type: Polymorphic Closure

  • [float,float]*
  • [double,double]*
  1. x : Angle in radians.

Returns sin(x)

Type: Polymorphic Closure

  • [float,float]*
  • [double,double]*
  1. x
  • Angle of x in radians.

Inverse sine. Returns atan(x)

Type: Polymorphic Closure

  • [float,float]*
  • [double,double]*
  1. x : Angle in radians

Hyperbolic sine. It returns sinh(x)

Type: Polymorphic Closure

  • [float,float]*
  • [double,double]*
  1. x : Angle in radians.

Returns cosine(x)

Type: Polymorphic Closure

  • [float,float]*
  • [double,double]*
  1. x
  • Angle of x in radians.

Inverse cosine. Returns acos(x)

Type: Polymorphic Closure

  • [float,float]*
  • [double,double]*
  1. x : Angle in radians

Hyperbolic cosine. It returns cosh(x)

Type Alias Type: float Value Audio I/O sample type in the dsp processing chain

Type Alias : [SAMPLE,SAMPLE,i64,i64,SAMPLE*]*

  1. in:SAMPLE : input sample from the sound card
  2. time:i64 : the current time, in samples (the audio sample clock)
  3. chan:i64 : the channel that the current sample comes from, and the corresponding channel that the current sample will go to.
  4. dat:SAMPLE* : pointer to user data passed through to the callback.
  • SAMPLE : output sample. This will be sent to chan

Audio callback function that is single sample and single threaded. A dsp closure has the signature (lambda (in time chan dat) ...).

(bind-func dsp:DSP
(lambda (in time chan dat)
(* 0.1 (random))))

Type Alias : [SAMPLE,SAMPLE*,i64,i64,SAMPLE*]*

  1. in:SAMPLE* : pointer to the block of input samples (one per input channel).
  2. time:i64 : the current time, in samples (the audio sample clock)
  3. chan:i64 : the channel that the current sample comes from, and the corresponding channel that the current sample will go to.
  4. dat:SAMPLE* : pointer to user data passed through to the callback.
  • SAMPLE : output sample. This will be sent to channel ‘chan’

The multithreaded variant of DSP: the in argument is a pointer to the block of input samples rather than a single sample.

(bind-func dsp:DSPMT
(lambda (in time chan dat)
(* 0.1 (random))))

Constant Type: SAMPLE Value: PI (3.1415…)

Constant Type: SAMPLE Value: 2 * PI (6.2831…)

Constant Type: SAMPLE Value: e (base of natural log)

Constant Type: i32 Value: Audio sound card sample rate

Constant Type: SAMPLE Value: Audio sound card sample rate

Constant Type: SAMPLE Value: Audio sound card sample rate.

Constant Type: float Value: Audio sound card sample rate

Constant Type: double Value: Audio sound card sample rate

Constant Type: i64 Value: Audio sound card sample rate

Constant Type: i32 Value: Number of audio output channels on sound card.

Constant Type: i32 Value: Number of audio input channels on sound card.

Constant Type: i32 Value: Audio signal block size

Constant Type: i64 Value: Audio signal block size

print_return::[void]*

Prints a line return to the output buffer (e.g. where extempore is running).

print_space::[void]*

Prints a space to the output buffer (e.g. where extempore is running).

print type: overloaded

  • [void,i1]*
  • [void,i8]*
  • [void,i16]*
  • [void,i32]*
  • [void,i64]*
  • [void,float]*
  • [void,double]*
  • [void,!a]*
  • [void,mzone*]*
  • [void,Symbol*]*

Prints the value to the terminal.

For generic types, the generic type must be one of the following:

  • An array containing a type that can be printed
  • A pointer to a type that can be printed
  • A tuple of length 1->6 containing types that can be printed.
  • A user defined type that provides a print function.
  • A memory zone
  • A symbol (empty symbols will print a zero length symbol)

Overloads and should be used via the println function If the symbol is empty will print a zero length symbol

Prints a line return to the output buffer (e.g. where extempore is running).

TODO Type?

  1. size:i64 : Size in bytes TODO Is this correct?
  • TODO?

TODO

TODO Need a type

  1. TODO
  • TODO?

TODO

TODO Need a type

  1. TODO
  • TODO?

TODO

TODO Need a type

  1. TODO
  • TODO?

TODO What does this do?

TODO Need a type

  1. TODO
  • TODO?

Frees the memory in the zone.

TODO Need a type

  1. TODO
  • TODO?

TODO

Type: Polymorphic Closure

  1. x : size of memory area to be copied (the units are the size of the type. e.g. if the memzones are in i64s, and x is 4, then it will be 4 * sizeof(i64)
  2. fromz : a pointer to the zone to be copied
  3. toz : a pointer to the destination memory zone

This function should support all built in types and user defined types.

A function to copy data from one memory zone to another.

Type: Macro

A ‘thread-first’ macro.

This macro can help make code more readable by removing nesting. Threads the first expr passed to the macro into the first position in the second sexp. Recursively continues to thread the resultant sexp into any further sexp arguments.

($ (-> 5 (+ 3) (* 2))) ;; (* (+ 5 3) 2), returns 16

Type: Macro

A ‘thread-last’ macro.

This macro can help make code more readable by removing nesting. Threads the first expr passed to the macro into the last position in the second sexp. Recursively continues to thread the resultant sexp into any further sexp arguments.

($ (->> 5 (- 10))) ;; (- 10 5), returns 5

type: scheme macro

  1. closure-name : Extempore closure name
  • A string that can be used in Scheme to call this closure.

See Extempore-Scheme interop description in the tutorial.

type: macro

  1. closure-name : Extempore closure name
  • A a pointer to the function that can be used by other languages (e.g. C) for callbacks, etc.

See FFI description in the tutorial.