Core
The core functions and variables that load at launch.
Memory
Section titled “Memory”size_t
Section titled “size_t”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.
size_of_type
Section titled “size_of_type”Type: Macro
Parameters
Section titled “Parameters”- type : type name
Returns
Section titled “Returns”- i64 : bytesize of this type.
Description
Section titled “Description”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.
Example
Section titled “Example”($ (size_of i64))
Type: Macro
Parameters
Section titled “Parameters”x: Variable to be incremented. This must be a type that supports basic math functions.y: Amount to incrementx. This must the same type asx.
Returns
Section titled “Returns”- Returns the result. The return value will be the same type as
x.
Description
Section titled “Description”Increments x by y.
Example
Section titled “Example”($ (let ((x 5)) (inc x 1))) ;; returns 6
Type: Macro
Parameters
Section titled “Parameters”x: Variable to be decremented. This must be a type that supports basic math functions.y: Amount to decrementx. This must the same type asx.
Returns
Section titled “Returns”- Returns the result. The return value will be the same type as
x.
Description
Section titled “Description”Decrements x by y.
Example
Section titled “Example”($ (let ((x 5)) (dec x 1))) ;; returns 4
Type: Macro
Parameters
Section titled “Parameters”x: Variable to be compared. This must be a type that supports less than/equal.y: Variable to be compared. This must the same type asx.
Returns
Section titled “Returns”- Returns the smallest value. The return value will be the same type as
x.
Description
Section titled “Description”Minimum of x and y.
Example
Section titled “Example”($ (min 3 7)) ;; returns 3
Type: Macro
Parameters
Section titled “Parameters”x: Variable to be compared. This must be a type that supports less than/equal.y: Variable to be compared. This must the same type asx.
Returns
Section titled “Returns”- Returns the largest value. The return value will be the same type as
x.
Description
Section titled “Description”Returns the largest of the two values.
Example
Section titled “Example”($ (max 3 7)) ;; returns 7
Type: Macro
Parameters
Section titled “Parameters”x: Input value. Must be a type that supports <>=.minval: Minimum value in range. Must be same type asx.maxval: Maximum value in range. Must be same type asx.
Returns
Section titled “Returns”- The return value is the same type as
x.
Description
Section titled “Description”Clamp input value to range. If x < minval it will return minval, if
x > maxval it will return maxval. Otherwise it returns x.
Example
Section titled “Example”($ (clamp 12 0 10)) ;; returns 10
Type: Closure
- log:[float,float]
- log:[double,double]
Description
Section titled “Description”returns the natural logarithm (ln)
Type: Macro
floatdouble
Parameters
Section titled “Parameters”x: x valuebase: base of the logarithm
Description
Section titled “Description”Returns log of x with base base
Example
Section titled “Example”($ (log 100, 10)) ;; log10 of 100 (returns 2)
deg2rad
Section titled “deg2rad”Type: Macro
Supported Types
Section titled “Supported Types”floatdouble
Parameters
Section titled “Parameters”degrees: x value in degrees
Returns
Section titled “Returns”- Same type as
degrees
Description
Section titled “Description”Converts a value in degrees to radians.
Example
Section titled “Example”($ (deg2rad 180.0)) ;; returns 3.141593 (pi)
rad2deg
Section titled “rad2deg”Type: Macro
Supported Types
Section titled “Supported Types”floatdouble
Parameters
Section titled “Parameters”radians: x value in radians
Returns
Section titled “Returns”- Same type as
radians
Description
Section titled “Description”Converts a value in radians to degrees.
Example
Section titled “Example”($ (rad2deg PI)) ;; returns 180.0
Type: Macro
Supported Types
Section titled “Supported Types”- i8
- i16
- i32
Parameters
Section titled “Parameters”- x - the value that you are testing. Must be an integer of some kind.
Return Value Type
Section titled “Return Value Type”i1: 1 ifxis even, 0 otherwise
Description
Section titled “Description”Checks to see if a value is even. Returns a C boolean (i1).
Type: Macro
Supported Types
Section titled “Supported Types”- i8
- i16
- i32
Parameters
Section titled “Parameters”- x - the value that you are testing. Must be an integer of some kind.
Return Value Type
Section titled “Return Value Type”i1: 1 ifxis odd, 0 otherwise
Description
Section titled “Description”Checks to see if a value is even. Returns a C boolean (i1).
Math Constants
Section titled “Math Constants”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…)
TWOPIf
Section titled “TWOPIf”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)
Math Functions
Section titled “Math Functions”random
Section titled “random”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]*
Description
Section titled “Description”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]*
Parameters
Section titled “Parameters”x: Angle in radians.
Description
Section titled “Description”Returns tan(x)
Type: Polymorphic Closure
- [float,float]*
- [double,double]*
Parameters
Section titled “Parameters”x
Returns
Section titled “Returns”- Angle of x in radians.
Description
Section titled “Description”Inverse tangent. Returns atan(x)
Type: Polymorphic Closure
- [float,float]*
- [double,double]*
Parameter
Section titled “Parameter”x: Angle in radians
Description
Section titled “Description”Hyperbolic tangent. It returns tanh(x)
Type: Polymorphic Closure
- [float,float]*
- [double,double]*
Parameters
Section titled “Parameters”x: Angle in radians.
Description
Section titled “Description”Returns sin(x)
Type: Polymorphic Closure
- [float,float]*
- [double,double]*
Parameters
Section titled “Parameters”x
Returns
Section titled “Returns”- Angle of x in radians.
Description
Section titled “Description”Inverse sine. Returns atan(x)
Type: Polymorphic Closure
- [float,float]*
- [double,double]*
Parameter
Section titled “Parameter”x: Angle in radians
Description
Section titled “Description”Hyperbolic sine. It returns sinh(x)
Type: Polymorphic Closure
- [float,float]*
- [double,double]*
Parameters
Section titled “Parameters”x: Angle in radians.
Description
Section titled “Description”Returns cosine(x)
Type: Polymorphic Closure
- [float,float]*
- [double,double]*
Parameters
Section titled “Parameters”x
Returns
Section titled “Returns”- Angle of x in radians.
Description
Section titled “Description”Inverse cosine. Returns acos(x)
Type: Polymorphic Closure
- [float,float]*
- [double,double]*
Parameter
Section titled “Parameter”x: Angle in radians
Description
Section titled “Description”Hyperbolic cosine. It returns cosh(x)
Audio Constants and Types
Section titled “Audio Constants and Types”SAMPLE
Section titled “SAMPLE”Type Alias Type: float Value Audio I/O sample type in the dsp processing chain
Type Alias : [SAMPLE,SAMPLE,i64,i64,SAMPLE*]*
Parameters
Section titled “Parameters”- in:SAMPLE : input sample from the sound card
- time:i64 : the current time, in samples (the audio sample clock)
- chan:i64 : the channel that the current sample comes from, and the corresponding channel that the current sample will go to.
- dat:SAMPLE* : pointer to user data passed through to the callback.
Returns
Section titled “Returns”- SAMPLE : output sample. This will be sent to chan
Description
Section titled “Description”Audio callback function that is single sample and single threaded. A dsp closure
has the signature (lambda (in time chan dat) ...).
Example
Section titled “Example”(bind-func dsp:DSP (lambda (in time chan dat) (* 0.1 (random))))Type Alias : [SAMPLE,SAMPLE*,i64,i64,SAMPLE*]*
Parameters
Section titled “Parameters”- in:SAMPLE* : pointer to the block of input samples (one per input channel).
- time:i64 : the current time, in samples (the audio sample clock)
- chan:i64 : the channel that the current sample comes from, and the corresponding channel that the current sample will go to.
- dat:SAMPLE* : pointer to user data passed through to the callback.
Returns
Section titled “Returns”- SAMPLE : output sample. This will be sent to channel ‘chan’
Description
Section titled “Description”The multithreaded variant of DSP: the in argument is a pointer to the
block of input samples rather than a single sample.
Example
Section titled “Example”(bind-func dsp:DSPMT (lambda (in time chan dat) (* 0.1 (random))))Constant Type: SAMPLE Value: PI (3.1415…)
STWOPI
Section titled “STWOPI”Constant Type: SAMPLE Value: 2 * PI (6.2831…)
Constant Type: SAMPLE Value: e (base of natural log)
SAMPLE_RATE
Section titled “SAMPLE_RATE”Constant Type: i32 Value: Audio sound card sample rate
SAMPLERATE
Section titled “SAMPLERATE”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
CHANNELS
Section titled “CHANNELS”Constant Type: i32 Value: Number of audio output channels on sound card.
IN_CHANNELS
Section titled “IN_CHANNELS”Constant Type: i32 Value: Number of audio input channels on sound card.
NUM_FRAMES
Section titled “NUM_FRAMES”Constant Type: i32 Value: Audio signal block size
FRAMES
Section titled “FRAMES”Constant Type: i64 Value: Audio signal block size
print_return
Section titled “print_return”print_return::[void]*
Description
Section titled “Description”Prints a line return to the output buffer (e.g. where extempore is running).
print_space
Section titled “print_space”print_space::[void]*
Description
Section titled “Description”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*]*
Description
Section titled “Description”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
printfunction. - 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
Description
Section titled “Description”Prints a line return to the output buffer (e.g. where extempore is running).
Memory
Section titled “Memory”TODO Type?
Parameters
Section titled “Parameters”size:i64: Size in bytes TODO Is this correct?
Returns
Section titled “Returns”- TODO?
Description
Section titled “Description”TODO
push_zone
Section titled “push_zone”TODO Need a type
Parameters
Section titled “Parameters”- TODO
Returns
Section titled “Returns”- TODO?
Description
Section titled “Description”TODO
pop_zone
Section titled “pop_zone”TODO Need a type
Parameters
Section titled “Parameters”- TODO
Returns
Section titled “Returns”- TODO?
Description
Section titled “Description”TODO
reset_zone
Section titled “reset_zone”TODO Need a type
Parameters
Section titled “Parameters”- TODO
Returns
Section titled “Returns”- TODO?
Description
Section titled “Description”TODO What does this do?
destroy_zone
Section titled “destroy_zone”TODO Need a type
Parameters
Section titled “Parameters”- TODO
Returns
Section titled “Returns”- TODO?
Description
Section titled “Description”Frees the memory in the zone.
peek_zone
Section titled “peek_zone”TODO Need a type
Parameters
Section titled “Parameters”- TODO
Returns
Section titled “Returns”- TODO?
Description
Section titled “Description”TODO
Type: Polymorphic Closure
Parameters
Section titled “Parameters”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)fromz: a pointer to the zone to be copiedtoz: a pointer to the destination memory zone
This function should support all built in types and user defined types.
Description
Section titled “Description”A function to copy data from one memory zone to another.
Control Flow
Section titled “Control Flow”Type: Macro
Description
Section titled “Description”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.
Examples
Section titled “Examples”($ (-> 5 (+ 3) (* 2))) ;; (* (+ 5 3) 2), returns 16
Type: Macro
Description
Section titled “Description”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.
Examples
Section titled “Examples”($ (->> 5 (- 10))) ;; (- 10 5), returns 5
Interop
Section titled “Interop”get_native_name
Section titled “get_native_name”type: scheme macro
Parameters
Section titled “Parameters”closure-name: Extempore closure name
Returns
Section titled “Returns”- A string that can be used in Scheme to call this closure.
Description
Section titled “Description”See Extempore-Scheme interop description in the tutorial.
get_native_fptr
Section titled “get_native_fptr”type: macro
Parameters
Section titled “Parameters”closure-name: Extempore closure name
Returns
Section titled “Returns”- A a pointer to the function that can be used by other languages (e.g. C) for callbacks, etc.
Description
Section titled “Description”See FFI description in the tutorial.