Next: Introduction [Contents][Index]
Incudine is useful to design software synthesizers or sound plugins from scratch, exploiting the expressive power of Common Lisp, without the constraint to use pre-built unit generators. It is also a compositional tool that allows to produce high quality sounds controllable at the sample level, defining and redefining the digital signal processors and the musical structures on-the-fly.
Incudine introduces the Virtual UGen (VUG), a new mechanism for defining primitive unit generators by writing concise and reusable code. The definition of a VUG can contain lisp code, other nested VUGs or “real” unit generators (compiled VUGs), and it is re-arranged (i.e. after the inference of init- and performance-time actions) and compiled efficiently during the creation of a DSP.
Next: Installation, Previous: Introduction, Up: Incudine [Contents][Index]
Next: The Incudine dictionary, Previous: Features, Up: Incudine [Contents][Index]
Next: Download, Up: Installation [Contents][Index]
Incudine works with SBCL, an implementation of ANSI Common Lisp with a high-performance native compiler.
Next: Foreign libraries, Up: Requirements [Contents][Index]
Previous: Common Lisp packages, Up: Requirements [Contents][Index]
Some Linux distributions provide separated devel packages necessary to
compile Incudine, for example jack-audio-connection-kit-devel
,
portaudio-devel
, etc.
Next: Configuration, Previous: Requirements, Up: Installation [Contents][Index]
The latest source code can be obtained via Git:
git clone git://git.code.sf.net/p/incudine/incudine
Mirror:
git clone git://github.com/titola/incudine.git
Previous: Download, Up: Installation [Contents][Index]
Put the incudine directory where ASDF finds your systems, for example:
mv incudine ${HOME}/common-lisp/
If you use Quicklisp:
mv incudine /path/to/quicklisp/local-projects/
Edit and copy the sample configuration file, with particular attention
to the priorities *rt-priority*
, *nrt-priority*
and
*receiver-default-priority*
cp /path/to/incudine/incudinerc-example ${HOME}/.incudinerc
If MMCSS (Multimedia Class Scheduler Service) is available on Windows, the realtime thread is associated with the “Pro Audio” task.
Here is a test:
(require :incudine) (in-package :scratch) (dsp! hello-world () (out (sine 440 .3))) (rt-start) ;; You should hear an oscillation at 440 Hz. (hello-world) (free 0) (rt-stop) ;; It writes a soundfile. (bounce-to-disk ("/tmp/test.wav" :channels 1 :duration 1) (hello-world))
GNU Emacs and Texinfo are required to build the documentation:
cd doc/manual && make info html pdf
This builds the Info, HTML and PDF documentation from the Org and Texinfo sources.
If you want to create and install the incudine
command:
cd src && ./install_executable
The options for the script ‘install_executable’ are:
--prefix=PREFIX install architecture-independent files in PREFIX [/usr/local] --bindir=DIR user executables [PREFIX/bin] --swank-loader=PATH support for Swank server with path to swank-loader.lisp --without-aclrepl do not use Allegro CL-style Read-Eval-Print Loop. --with-clm use cudere-clm, the Incudine version of CLM. --with-linedit support for Linedit, readline-style library in CL. --with-fluidsynth support for FluidSynth SoundFont synthesizer. --with-ladspa support for LADSPA plugins. --with-lv2 support for LV2 plugins. --with-snd support for the sound editor Snd. --with-module=NAME load the module NAME before to create the executable. --save-options=OPTS further arguments for SAVE-LISP-AND-DIE. --sbcl-options=OPTS options for SBCL. --before-save=FORM read and evaluate FORM before to create the executable.
For example:
sh install_executable \ --bindir=/computer/music \ --swank-loader=/path/to/slime/swank-loader.lisp \ --with-linedit \ --with-clm \ --with-snd \ --with-ladspa \ --with-lv2 \ --with-fluidsynth \ --with-module=series \ --with-module=anaphora \ --save-options=":compression t" \ --before-save="(series::install :pkg :scratch :shadow nil)"
Note: the support for LV2 plugins requires Lilv,
a LV2 host library. The option :compression t
works if :sb-core-compression
was
enabled in SBCL at build-time.
There are two major modes for GNU Emacs: incudine-mode
and incudine-rego-mode
for
editing lisp (cudo) and score (rego) files, respectively. If you want to install them,
add the following lines to your .emacs
file:
(push "/path/to/incudine/contrib/editors/emacs" load-path) (require 'incudine) ;; org-babel source code block. (require 'ob-incudine)
Up: Configuration [Contents][Index]
;;; .incudinerc ;;; ;;; Sample configuration file for Incudine ;;; ;;;-------------------------[ C compiler ]-------------------------- (setq *c-compiler* "cc") ;; A list, in which each element is a string, a pathname, or a simple Lisp ;; expression. Used only if the dynamic linker fails to search a library ;; (see CFFI:*FOREIGN-LIBRARY-DIRECTORIES*) (setq *foreign-library-directories* nil) ;; Directories to be searched for header files. A list, in which each ;; element is a string, a pathname, or a simple Lisp expression. (setq *foreign-header-file-directories* nil) ;;;--------------------[ RT and NRT priorities ]-------------------- ;; Thread scheduling algorithm. (setq *sched-policy* #+linux "SCHED_FIFO" #-linux "SCHED_RR") ;; Note: if MMCSS (Multimedia Class Scheduler Service) is available on ;; Windows, the realtime thread is associated with the "Pro Audio" task. ;; Currently the other priority settings are ignored on Windows. ;; Priority of the realtime thread. (setq *rt-priority* 68) ;; Priority of the non-realtime thread. (setq *nrt-priority* 60) ;; Priority for the threads of the receivers (i.e. MIDI input) (setq *receiver-default-priority* 63) ;; Zero-based number of CPU reserved for the realtime thread. ; (setq *rt-cpu* 0) ;;;-----------------------[ Audio settings ]------------------------ ;; Real time audio: ;; ;; :dummy ;; :jack ;; :portaudio ;; :portaudio-jack ;; ;; :portaudio and :portaudio-jack are the same, but with the last ;; it is possible to set the Jack client name. ;; (setq *audio-driver* #+linux :jack #-linux :portaudio) (setq *max-buffer-size* 1024) ;; Realtime block size in frames. (setq *rt-block-size* 1) (setq *sample-rate* 48000) (setq *client-name* "incudine") (setq *max-number-of-channels* 1024) (setq *number-of-input-bus-channels* 2) (setq *number-of-output-bus-channels* 2) (setq *number-of-bus-channels* 4096) ;; Control-string or function of one argument (the port number) to get ;; the short name of a JACK port. The default is "in_~D" for the input ;; ports and "out_~D" for the output ports. If the function doesn't ;; return a string, the port name is the default. ;(setq *audio-input-port-name* "in_~D") ;(setq *audio-output-port-name* "out_~D") ;; Used only with PortAudio. (setq *frames-per-buffer* 512) ;; Recovery of audio cycles suspended during gc by processing the ;; cached audio inputs and MIDI events (audio outputs are ignored). ;; For example, this setting allows HD recording without losing audio ;; inputs during gc if there aren't xruns. ;; Note: if *RECOVER-SUSPENDED-AUDIO-CYCLES-P* is NIL (default), the ;; time is not incremented after gc, therefore the old scheduled ;; functions are delayed by the garbage collection time. ;(setq *recover-suspended-audio-cycles-p* t) ;; PORTAUDIO-DEVICE-INFO prints the list of the devices (-1 = default). ;(setq *portaudio-input-device* -1) ;(setq *portaudio-output-device* -1) ;; Latencies for PortAudio stream: ;; positive value: latency in seconds ;; negative value: the absolute value is the latency in number of periods ;; 0: default latency for interactive performance ;(setq *portaudio-input-latency* 0) ;(setq *portaudio-output-latency* 0) ;;;-----------------------[ MIDI settings ]------------------------- (setq *enable-jack-midi* nil) ;; Timestamp with sample offset for PortMidi output in rt-thread ;; (T by default with PortAudio). ;(setq *enable-portmidi-output-sample-offset* (not (eq *audio-driver* :jack))) ;; Number of milliseconds before to test whether MIDI input is ;; available (useful with PortMidi because it does not support a ;; blocking read). ;; low value = low latency but minor CPU time for the system (setq *midi-input-timeout* 1) ;;;------------------------[ Networking ]--------------------------- ;; addrinfo-flags for the argument 'hints' of the c-call getaddrinfo. (setq *addrinfo-hints-flags* 0) ;; Size of the foreign buffer used to read/write octets. (setq *network-buffer-size* 1000) ;; Open Sound Control (setq *osc-buffer-size* 1500) (setq *osc-max-values* 50) ;; INCUDINE.OSC package nicknames [default: (list "OSC")] ;(setq *osc-package-nicknames* nil) ;;;---------------------------[ Graph ]----------------------------- (setq *max-number-of-nodes* 1024) ;;;----------------------[ Event scheduling ]----------------------- ;; array or list (setq *fifo-buffer-type* 'array) ;; A power of two if *FIFO-BUFFER-TYPE* is ARRAY (setq *fifo-buffer-size* 128) ;; Max number of scheduled events in realtime (a power of two). (setq *rt-edf-heap-size* 1024) ;; Max number of scheduled events in non-realtime (a power of two). (setq *nrt-edf-heap-size* 65536) ;; Pool size of the temporary EDF heaps. (setq *edf-heap-pool-size* 2) ;; New EDF heaps to add when the pool is empty. (setq *edf-heap-pool-grow* 1) ;;;-------------------------[ Soundfile ]--------------------------- ;; Safe upper limit when the duration of the soundfile is undefined. (setq *bounce-to-disk-guard-size* 300) ; 5 minutes (setq *sndfile-buffer-size* 1024) (setq *default-header-type* #-darwin "wav" #+darwin "aiff") (setq *default-data-format* "pcm-24") ;;;--------------------[ Foreign memory pool ]---------------------- ;; Size (in bytes) of the pool for the C heap used in realtime. (setq *foreign-sample-pool-size* (* 64 1024 1024)) (setq *foreign-rt-memory-pool-size* (* 64 1024 1024)) ;; Size of the pool used for temporary C malloc in non-realtime. (setq *foreign-nrt-memory-pool-size* (* 64 1024 1024)) ;;;---------------------------[ Misc ]------------------------------ ;; Size in samples (power of two) for frequently used waveforms ;; (i.e. *SINE-TABLE* and *COSINE-TABLE*). (setq *default-table-size* 65536) ;; Initial tempo in beats per minute. (setq *default-bpm* 60) ;;; Default curve for fade in/out. (setq *fade-curve* :lin) ;;; Default duration for fade in/out. (setq *fade-time* 0) ;;; Velocity of the sound at 22 degrees Celsius, 1 atmosfera. (setq *sound-velocity* 345) ;;; Local Variables: ;;; mode: lisp ;;; End:
Next: GNU Free Documentation License, Previous: Installation, Up: Incudine [Contents][Index]
Next: Bus, Up: The Incudine dictionary [Contents][Index]
All types of Incudine error conditions inherit from this condition.
Signals an incudine-simple-error
controlled by format-control
and format-arguments
.
Subtype of incudine-error
and simple-error
.
Signaled if there is an error during the compilation of the Incudine library.
Subtype of incudine-simple-error
.
Signaled if there is an unhandled memory fault.
Subtype of incudine-simple-error
.
Subtype of incudine-simple-error
and storage-condition
.
Conditions that relate to networking interface should inherit from this type.
Subtype of incudine-simple-error
.
Conditions that relate to the node tree should inherit from this type.
Subtype of incudine-simple-error
.
Signaled if there is a missing argument.
Subtype of incudine-simple-error
.
Signals an incudine-missing-arg
error.
Signaled if the time unit is unknown.
Signaled if the virtual unit generator is undefined.
Signaled if the unit generator is undefined.
Signaled if the DSP is undefined.
All types of error conditions about MIDI files inherit from this condition.
Subtype of incudine-simple-error
.
Signaled if there is a MIDI file parsing error.
Signaled if the MIDI file parser encounters an invalid variable-length-quantity.
Subtype of midifile-parse-error
.
Signaled if the MIDI file parser encounters an invalid running status.
Subtype of midifile-parse-error
.
Signaled if the MIDI file parser encounters a header-chunk with invalid length of track data.
Subtype of midifile-parse-error
.
All types of error conditions about sound files inherit from this condition.
Subtype of incudine-simple-error
and file-error
.
All types of error conditions about analysis files inherit from this condition.
Subtype of incudine-simple-error
and file-error
.
All types of error conditions about foreign plugin inherit from this condition.
Subtype of incudine-simple-error
.
Next: Buffer, Previous: Condition, Up: The Incudine dictionary [Contents][Index]
Return the value of the zero-based bus number
. Setfable.
No bounds checking.
The utility bus
is similar to smp-ref
with a pre-allocated foreign
array of type sample
:
(bus 123) (setf (bus 123) value)
is equivalent to
(smp-ref preallocated-foreign-array 123) (setf (smp-ref preallocated-foreign-array 123) (sample value))
Example:
(in-package :scratch) (dsp! master () ;; Stereo output from the first two buses. (out (bus 0) (bus 1)) ;; Zero before the next audio cycle. (setf (bus 0) 0) (setf (bus 1) 0)) (dsp! track (freq amp pos) (foreach-channel ;; We can use CURRENT-CHANNEL here because MASTER reads the buses ;; 0 and 1, and CURRENT-CHANNEL starts from 0. INCF means "mix" ;; (use SETF if you want to overwrite the current bus value). (incf (bus current-channel) (pan2 (sine freq amp) pos)))) (dsp! stereo-test (freq amp (nbus fixnum)) ;; The adjacent bus number is explicitally computed. ;; Note: this initialization avoids a sum during the performance ;; and it is necessary because BUS is a function. (with ((nbus2 (+ nbus 1))) (incf (bus nbus) (sine freq amp)) ;; Note: SINE is a VUG, therefore the initialization for `(* freq 3/2)' ;; is implicit (there is a hidden WITH). (incf (bus nbus2) (sine (* freq 3/2) amp)))) (set-rt-block-size 1) (rt-start) (master :id 1) ;; In this case `:before 1' is unnecessary because the new node is ;; added at the head of the root node by default. (track 440 .1 .3 :before 1) (track 660 .15 .9 :before 1) (stereo-test 220 .1 0 :before 1) (free 0)
If the block size is greater than 1, it is necessary to change the strategy. The following example is a possible implementation but we can also define other utilities for custom structures (i.e. a matrix frames*channels):
(dsp! master () (with ((frames (block-size))) (foreach-frame ;; Stereo output from the first blocksize*2 buses. (out (bus current-frame) (bus (+ frames current-frame))) (setf (bus current-frame) 0) (setf (bus (+ frames current-frame)) 0)))) (dsp! track (freq amp pos) (with ((frames (block-size))) (foreach-frame (foreach-channel (incf (bus (+ current-frame (the fixnum (* frames current-channel)))) (pan2 (sine freq amp) pos)))))) (dsp! stereo-test (freq amp (nbus fixnum)) (with ((frames (+ nbus (block-size)))) (declare (fixnum frames)) (foreach-frame (incf (bus (+ nbus current-frame)) (sine freq amp)) (incf (bus (+ frames current-frame)) (sine (* freq 3/2) amp))))) (set-rt-block-size 64) (rt-start) (master :id 1) (track 440 .1 .3) (track 660 .15 .9) (stereo-test 220 .1 0) (free 0) (set-rt-block-size 1)
Return the value of the channel
of the input buffer frame
.
channel
and frame
are zero-based.
If audio-in
is used within a VUG definition, frame
is ignored.
No bounds checking.
Return the value of the channel
of the output buffer frame
. Setfable.
channel
and frame
are zero-based.
If audio-out
is used within a VUG definition, frame
is ignored.
No bounds checking.
Return peak information for the zero-based channel
.
No bounds checking.
Print the peak information.
The number of the channels defaults to *number-of-output-bus-channels*
.
The output stream is *logger-stream*
by default.
No bounds checking.
Reset the peak meters.
Safe way to change the number of the input/output channels.
This setting stops the real-time thread.
Next: Tuning, Previous: Bus, Up: The Incudine dictionary [Contents][Index]
Buffer type.
buffer
structure of size *default-table-size*
with a single cycle sinusoid.
buffer
structure of size *default-table-size*
with a single cycle cosinusoid.
Create a new buffer with frames
sample frames.
If file
is non-NIL, copy the sample frames of a soundfile starting from
offset
sample frame.
initial-contents
is used to initialize the contents of the buffer from start
to end
frame.
fill-function
is a function used to fill the buffer from start
to end
frame.
The function arguments are the foreign pointer to the buffer data and the
buffer size (i.e. gen
routines are valid functions).
If normalize-p
is t
, normalize the initial content of the buffer.
Set real-time-p
to nil
to disallow real-time memory pools.
Return a copy of buffer
.
Return t
if object is of type buffer
.
Deallocate the buffer
.
Return t
if the buffer
is deallocated.
Return the foreign pointer to the buffer data.
Return the buffer size.
Return the number of the sample frames of the buffer.
Return the number of the channels of the buffer.
Return the buffer sample rate.
If the buffer is created with buffer-load
or make-buffer
with
a non-NIL file
argument, return the pathname.
If the buffer size is a power of two, return that size minus one, otherwise the returned value is
(1- (next-power-of-two (ash (buffer-size instance) -1)))
The phase computed for a table of size +table-maxlen+
is shifted
right by buffer-lobits
bits to get the index for a table lookup.
Return the number of bits for the arithmetic shift operation.
Return the division of the buffer size by +table-maxlen+
.
Return the division of +table-maxlen+
by the buffer size, minus one.
Example: wavetable lookup oscillator with phase of type integer
between 0 and +table-maxlen+
. Buffer size is assumed to be a
power of two.
The following DSP
(dsp! oscillator-test ((buf buffer) freq amp) (out (osc buf freq amp 0 :linear)))
is equivalent to
(dsp! oscillator-test ((buf buffer) freq amp) (with ((frac (sample 0)) (phase 0) ;; Memo: *CPS2INC* is table_maxlen/sample_rate (phase-increment (sample->fixnum (* freq *cps2inc*))) (minus-lobits (- (buffer-lobits buf))) (index 0)) (declare (type sample frac) (type fixnum phase phase-increment index) (type (integer #.(- +max-lobits+) 0) minus-lobits)) (setf frac (* (buffer-lodiv buf) (logand phase (buffer-lomask buf)))) (setf index (ash phase minus-lobits)) (out (* amp (linear-interp frac (buffer-value buf index) (buffer-value buf (logand (the fixnum (1+ index)) (buffer-mask buf)))))) ;; Phase increment without branching. (setf phase (logand (the fixnum (+ phase phase-increment)) +phase-mask+)))) ;; Buffer size 8192 = 2^13 (defvar *waveform* (make-buffer 8192 :fill-function (gen:partials '(1)))) (rt-start) (oscillator-test *waveform* 440 .3)
Return the buffer value stored at the sample frame index
. Setfable.
Create a new buffer by loading the file path
(string or pathname).
If path
represents a sound file, load that file starting from offset
sample frame (defaults to 0).
If path
corresponds to a text file that contains numbers, create a buffer
with that values. There is not the parsing of the numbers, a text file is
valid if it contains numbers separated with spaces, tabs or newlines.
It is possible to use line comments that begin with the ’;’ character.
If frames
is non-NIL, create a buffer with frames
sample frames.
If channel
is greater than or equal to zero, load that channel (zero based)
of the sound file, otherwise import all the channels (default).
The number of channels is channels
or the number of channels of the
sound file if channels
is nil
(default).
If headerless-p
is t
, load a headerless file with data-location
in bytes
(defaults to 0) and sample type data-format
(defaults to “double”).
See bounce-to-disk
for the list of available data formats.
sample-rate
is *sample-rate*
by default.
Save the buffer data of buf
to the file path
.
start
specifies an offset into the buffer and marks the beginning
position of that buffer. end
marks the position following the last
value of the buffer.
If sample-rate
is non-NIL, it replaces the sample rate of the buffer.
If textfile-p
is t
, save the buffer data to a text file.
header-type
defaults to *default-header-type*
.
data-format
defaults to *default-data-format*
.
See bounce-to-disk
for the list of available header types and data
formats.
Destructively modifies buffer
to contain the results of applying
function
to each buffer value. The function arguments are the index
and the buffer value.
Destructively modifies result-buffer
to contain the results of
applying function
to each element in the argument buffers
in turn
function
is a function of as many arguments as there are buffers.
Resize buffer
to frames
sample frames.
If channels
is non-NIL, the resized buffer is created with that number
of channels.
Multiply the buffer values by mult
.
Scale the buffer values to be between -value
and value
.
Rescale the buffer values to be between min
and max
.
Destructively sort buffer
and return it.
Perform a circular shift of length n
.
Quantize buffer
with respect to a real number, a vector, a buffer
or tuning
structure in sorted order.
The keywords start
and end
are the bounding index designators, and
the keyword filter-function
is usable to apply a function to the
quantized value. The arguments of that function are the vector index
and the quantized value.
Create a new array of type (simple-array sample (*)) with the content of the buffer.
Create a new list with the content of the buffer.
If obj
is a function, fill the buffer to contain the results of
applying obj
. The function arguments are the foreign pointer to the
buffer data and the buffer size (i.e. gen
routines are valid functions).
If obj
is a list, a vector or an envelope
struct, it is used to fill
the buffer.
If obj
is of type string or pathname, load that file. If the file is
a sound file, load obj
starting from sndfile-start
sample frame
(defaults to 0). If headerless-p
is t
, load a headerless file with
data-location
in bytes (defaults to 0) and sample type data-format
(defaults to “double”). See bounce-to-disk
for the list of available
data formats. If obj
corresponds to a text file that contains numbers,
fill the buffer with that values.
There is not the parsing of the numbers, a text file is valid if it
contains numbers separated with spaces, tabs or newlines. It is
possible to use line comments that begin with the ’;’ character.
start
specifies an offset into the buffer and marks the beginning
position of that buffer. end
marks the position following the last
value of the buffer.
channel-map
is a list of lists (soundfile-channel buffer-channel)
used to define the mapping between the sound file channel data and
the buffer channel data. For example, channel-map
’((1 0) (0 1))
fills the first two buffer channel data with the swapped channels of
a stereo sound file.
If normalize-p
is t
, normalize the buffer data between -1 and 1.
Bind var
to a newly allocated buffer
structure with dynamic extent
during body
.
frames
and the other keyword arguments args
are passed to make-buffer
.
Create bindings to newly allocated buffer
structures with dynamic extent
during body
.
bindings
is a list of lists
(var frames &rest args)
where var
is the variable bound to a buffer, frames
and the other keyword
arguments args
are passed to make-buffer
.
Next: Envelope, Previous: Buffer, Up: The Incudine dictionary [Contents][Index]
Tuning type.
Default tuning
structure.
Create and return a new tuning
structure with optional description
.
If notes
is non-NIL, it is a list of pitch values that are ratios
and/or floating point values (cents). The first note 1/1 (or 0.0) is
implicit. This format is compatible with the Scale file format
described at http://www.huygens-fokker.org/scala/scl_format.html.
If file
is non-NIL, get the scale from a Scala file.
If notes
and file
are nil
, create a 12-tone equal tempered scale.
The reference frequency freq-base
, the related key number keynum-base
and degree-index
default to 440, 69 and 9 respectively.
Set real-time-p
to nil
to disallow real-time memory pools.
Return a copy of tuning
.
Deallocate the tuning
.
Return t
if the tuning
is deallocated.
Return the description of the tuning.
Return the list of pitch values of the tuning
in cents.
Return the list of pitch values of the tuning
as ratios.
Return the frequency of the key number keynum
in a tuning
.
Setfable.
Return the foreign pointer to the tuning data.
Return the scale degree of tuning
used as reference.
Return the reference frequency of tuning
.
Return the key number of tuning
used as reference.
Change the notes and optionally the description
, the reference
frequency freq-base
, keynum-base
and degree-index
of a tuning
structure.
If notes-or-file
is the path of a Scala file, import the notes from
that file.
Change keynum-base
, freq-base
and degree-index
used as reference
to generate the frequencies of the tuning
.
If obj
is a tuning
structure, the frequencies and the description
of obj
are changed with the data received from a MIDI bulk tuning dump
message. If obj
is a function, it is called with the program number
contained in the MIDI bulk tuning message. The function has to return
the tuning
structure to set or nil
to ignore the MIDI message.
The checksum of the message is ignored.
Try to minimize the tuning
ratios by introducing an error in the
significand of the floating point numbers. The error is 0.0005% by default.
Compute the notes of the scale from the frequencies stored in a
tuning
structure, starting from the key number start
and ending to the
key number end
. The ratio between the frequencies in start
and end
is
the last tuning
ratio. If significand-error
is non-zero (default), try
to minimize the tuning
ratios by introducing an error (default 0.0005%)
in the significand of the floating point numbers.
Save pitch values and description of a tuning
structure to the file path
in Scale file format.
Return the pitch values, the number of notes and the description of
the scale stored in the Scala file path
.
Convert from freq
cycles-per-second to pitch class value.
The tuning
structure defaults to *default-tuning*
.
Convert from pitch-class
value to cycles-per-second. If tuning
is nil
,
the table lookup is the same used by Csound’s cpspch opcode. If tuning
is
a tuning
structure, pitch-class
is a floating point number xx.yy[z]* where
xx = octave number from 0 to 14 yy = scale degree from 0 to 99 z* = fractional part 0.z* to interpolate between yy and (+ yy 1)
Example with et12
scale:
pch | cps |
---|---|
8.00 | 261 |
8.09 | 440 |
8.095 | 453 |
8.10 | 466 |
8.12 | 523 |
9.00 | 523 |
Convert from key number keynum
to pitch class value.
The tuning
structure defaults to *default-tuning*
.
Convert from pitch-class
value to key number. The second returned
value is the fractional part. pitch-class
is a floating point number
xx.yy[z]* where
xx = octave number from 0 to 14 yy = scale degree from 0 to 99 z* = fractional part 0.z* to interpolate between yy and (+ yy 1)
Note: if the returned key number is used without the fractional part, it
is necessary to avoid round off problems by adding 1e-6 to pitch-class
before the conversion.
Example with et12
scale:
pch | keynum | frac |
---|---|---|
8.00 | 60 | 0.000 |
8.09 | 69 | 0.000 |
8.10 | 70 | 0.000 |
8.095 | 69 | 0.500 |
8.12 | 71 | 0.999 |
8.120001 | 72 | 0.000 |
9.00 | 72 | 0.000 |
Quantize tuning
with respect to a real number, a vector, a buffer
or tuning
structure in sorted order.
The keywords start
and end
are the bounding index designators, and
the keyword filter-function
is usable to apply a function to the
quantized value. The arguments of that function are the vector index
and the quantized value.
Next: Time, Previous: Tuning, Up: The Incudine dictionary [Contents][Index]
Envelope type.
Create and return a new envelope
structure from a list of levels
and
a list of times
in seconds.
If base
is a number, it is the envelope’s base in the style of clm
(Common Lisp Music), where base
is e^k and the curvature depends on
the highest and lowest levels.
curve
sets the shape of the segments; the possible values are :step
,
:lin
or :linear
(default), :exp
or :exponential
, :sin
or :sine
, :wel
or :welch
, :sqr
or :square
, :cub
or :cubic
, a number that represents
the curvature value between two levels for all the segments or a list
of the prior values to specify the curvature values for each segment.
curve
is ignored if base
is non-NIL.
If the envelope is sustained, release-node
specifies the point of the
release (starting from 0). The default is -1 that means ’envelope
without sustain’.
If loop-node
is a non-negative value, it is the starting point of the
loop of the segments during the sustain phase of the envelope. The
ending point is the point that precedes the release point
release-node
.
If restart-level
is nil
(default), the envelope restarts from the
current level otherwise it restarts from the value restart-level
.
Set real-time-p
to nil
to disallow real-time memory pools.
Return a copy of envelope
.
Return t
if object is of type envelope
.
Deallocate the envelope
.
Return t
if the envelope
is deallocated.
Return the foreign pointer to the envelope data.
Return the duration of the envelope.
Return the number of envelope points.
Return a non-negative value if it is the starting point of the loop of the segments during the sustain phase of the envelope.
Return the point of the release (starting from 0) or -1 if the envelope is without sustain.
Return the restart level of the envelope or nil
if it is the value
of the level before to restart. Setfable.
Return the list of curvature values for the curve
keyword in
make-envelope
related to an envelope’s base in the style of clm
.
Edit an envelope
structure.
If levels
is non-NIL, change the list of levels
and the list of times
.
curve
sets the shape of the segments; the possible values are :step
,
:lin
or :linear
, :exp
or :exponential
, :sin
or :sine
, :wel
or :welch
,
:sqr
or :square
, :cub
or :cubic
, a number that represents the curvature
value between two levels for all the segments or a list of the prior
values to specify the curvature values for each segment. curve
is
ignored if base
is non-NIL.
If the envelope is sustained, release-node
specifies the point of the
release (starting from 0). -1 means ’envelope without sustain’.
If loop-node
is a non-negative value, it is the starting point of the
loop of the segments during the sustain phase of the envelope. The
ending point is the point that precedes the release point release-node
.
linen
is nil
or a list (attack-time sustain-time release-time). curve
defaults to :linear
.
perc
is nil
or a list (attack-time release-time). curve
defaults to -4.
cutoff
is nil
or the release time. curve
defaults to :exponential
and
release-node
is 0.
asr
is nil
or the list (attack-time sustain-level release-time).
curve
and release-node
default to -4 and 1 respectively.
adsr
is nil
or the list (attack-time decay-time sustain-level release-time).
curve
and release-node
default to -4 and 2 respectively.
sustain-level
is a ratio of peak-level
.
dadsr
is nil
or the list (delay-time attack-time decay-time sustain-level release-time).
curve
and release-node
default to -4 and 3 respectively.
sustain-level
is a ratio of peak-level
.
peak-level
is the peak level (1 by default) when levels
and asr
are nil
.
If restart-level
is nil
, the envelope restarts from the current level
otherwise it restarts from the value restart-level
.
Return the level of the envelope env
at node-number
. Setfable.
Return the time of the envelope env
at node-number
. Setfable.
Return the curvature of the envelope env
at node-number
. Setfable.
Set the curvature of the envelope in the style of clm
, where base
is e^k and the curvature depends on the highest and lowest levels.
Return the level of the envelope env
at time time
.
Multiply the levels of the envelope by mult
.
Scale the levels of the envelope to be between -value
and value
.
Rescale the levels of the envelope to be between min
and max
.
Create and return a new envelope
from a sequence of break-point pairs.
If base
is a number, it is e^k and the curvature depends on the highest
and lowest levels.
If scaler
is non-NIL, the levels of the envelope are scaled by that value.
If offset
is non-NIL, it is the value added to the levels of the envelope.
If duration
is non-NIL, it is the duration of the envelope in seconds.
curve
sets the shape of the segments; the possible values are :step
,
:lin
or :linear
(default), :exp
or :exponential
, :sin
or :sine
, :wel
or :welch
, :sqr
or :square
, :cub
or :cubic
, a number that represents
the curvature value between two levels for all the segments or a list
of the prior values to specify the curvature values for each segment.
curve
is ignored if base
is non-NIL.
If the envelope is sustained, release-node
specifies the point of the
release (starting from 0). The default is -1 that means ’envelope
without sustain’.
If loop-node
is a non-negative value, it is the starting point of the
loop of the segments during the sustain phase of the envelope. The
ending point is the point that precedes the release point
release-node
.
If restart-level
is nil
(default), the envelope restarts from the
current level otherwise it restarts from the value restart-level
.
Set real-time-p
to nil
to disallow real-time memory pools.
Create and return a new envelope
from a sequence of break-point
pairs interpreted as frequency response.
freq-max
is the highest frequency and defaults to the half of *sample-rate*
.
If base
is a number, it is e^k and the curvature depends on the
highest and lowest levels.
curve
sets the shape of the segments; the possible values are :step
,
:lin
or :linear
(default), :exp
or :exponential
, :sin
or :sine
, :wel
or :welch
, :sqr
or :square
, :cub
or :cubic
, a number that represents
the curvature value between two levels for all the segments or a list
of the prior values to specify the curvature values for each segment.
curve
is ignored if base
is non-NIL.
Set real-time-p
to nil
to disallow real-time memory pools.
Create and return a new envelope
structure with peak level
and a
straight line rise and decay pattern by default.
Create and return a new envelope
structure with peak level
,
attack-time
and release-time
.
The curvature curve
defaults to -4.
Create and return a new envelope
structure with peak level
and release-time
.
The curvature curve
defaults to :exponential
.
Create and return a new envelope
structure with attack-time
, sustain-level
and release-time
.
The curvature curve
defaults to -4.
Create and return a new envelope
structure with attack-time
,
peak-level
, decay-time
, sustain-level
and release-time
.
peak-levels
defaults to 1.
sustain-level
is a ratio of peak-level
for compatibility with
Env.adsr in SuperCollider.
The curvature curve
defaults to -4.
Other available keyword arguments are base
, restart-level
and
real-time-p
. See make-envelope
for details.
Create and return a new envelope
structure with delay-time
,
attack-time
, peak-level
, decay-time
, sustain-level
and release-time
.
peak-levels
defaults to 1.
sustain-level
is a ratio of peak-level
for compatibility with
Env.adsr in SuperCollider.
The curvature curve
defaults to -4.
Other available keyword arguments are base
, restart-level
and
real-time-p
. See make-envelope
for details.
Next: Foreign Array, Previous: Envelope, Up: The Incudine dictionary [Contents][Index]
Tempo type.
Create and return a new tempo
structure.
unit
is :bpm
(default), :spb
or :bps
to set the tempo value
in beats
per minute, seconds per beat or beats per second respectively.
Return t
if object is of type tempo
.
Default tempo
structure.
The value is initially *default-bpm*
beats per minute.
Return the tempo in beats per minute. Setfable.
Return the tempo in beats per second. Setfable.
Return the tempo in seconds per beat. Setfable.
Temporal envelope type.
Create and return a new tempo-envelope
structure from a list of
tempo values in beats per minute and a list of times in beats.
curve
sets the shape of the segments; the possible values are :step
,
:lin
or :linear
(default), :exp
or :exponential
, :sin
or :sine
, :wel
or :welch
, :sqr
or :square
, :cub
or :cubic
, a number that represents
the curvature value between two levels for all the segments or a list
of the prior values to specify the curvature values for each segment.
curve
is ignored if base
is non-NIL.
If the envelope is sustained, release-node
specifies the point of the
release (starting from 0). The default is -1 that means ’envelope
without sustain’.
If loop-node
is a non-negative value, it is the starting point of the
loop of the segments during the sustain phase of the envelope. The
ending point is the point that precedes the release point
release-node
.
If restart-level
is nil
(default), the envelope restarts from the
current level otherwise it restarts from the value restart-level
.
Set real-time-p
to nil
to disallow real-time memory pools.
Return t
if object is of type tempo-envelope
.
Return a copy of a tempo-envelope
structure.
Deallocate the tempo
or tempo-envelope
instance.
Return t
if the tempo
or tempo-envelope
instance is deallocated.
Change a tempo-envelope
structure.
bpms
is a list of tempo values in beats per minute.
beats
is a list of times in beats.
curve
sets the shape of the segments; the possible values are :step
,
:lin
or :linear
(default), :exp
or :exponential
, :sin
or :sine
, :wel
or :welch
, :sqr
or :square
, :cub
or :cubic
, a number that represents
the curvature value between two levels for all the segments or a list
of the prior values to specify the curvature values for each segment.
curve
is ignored if base
is non-NIL.
If the envelope is sustained, release-node
specifies the point of the
release (starting from 0). The default is -1 that means ’envelope
without sustain’.
If loop-node
is a non-negative value, it is the starting point of the
loop of the segments during the sustain phase of the envelope. The
ending point is the point that precedes the release point
release-node
.
If restart-level
is nil
(default), the envelope restarts from the
current level otherwise it restarts from the value restart-level
.
Return a list of {beats bpm} break-point pairs obtained from a
tempo-envelope
structure.
If the curve of a transition is not :step
, transition-time-step
is the
time in beats between adjacent points during that transition.
transition-time-step
defaults to 1/8.
Return the tempo in beats per minute of a tempo-envelope
structure
at time beats
.
Return the tempo in beats per second of a tempo-envelope
structure
at time beats
.
Return the tempo in seconds per beat of a tempo-envelope
structure
at time beats
.
Convert the time from number of beats to seconds by following a
tempo-envelope
structure, starting from offset
beats (zero by default).
Convert the time from seconds to number of beats by following a
tempo-envelope
structure, starting from offset
seconds (zero by default).
The returned time in beats is always precise if the segments of the
envelope have shapes :step
, :linear
, :exponential
, :square
or :cubic
.
It is approximated during the transitions between two BPM’s if the
curvatures are sinusoidal, Welch or custom.
Return the current time in samples.
Use a local counter during body
.
start
is the initial time in samples and defaults to zero.
The function now
is setfable to change the time, for example:
(with-local-time (loop repeat 8 collect (incf (now)))) ;; => (1.0d0 2.0d0 3.0d0 4.0d0 5.0d0 6.0d0 7.0d0 8.0d0)
Get the time synchronized to period
samples. It is equivalent to
(- (+ (now) period) (mod (now) period))
Return a double float value for the current time of day in universal time format.
Enable the reader syntax #[…] to enter the time in samples by using different units, and to begin and end a string as an alternative to double-quote. The syntax is
#[number unit] #[number-of-beats b.*] #[number-of-beats b.* tempo] #[number-of-beats b.* tempo-envelope offset-in-beats] #[[text]]
The number of beats depends on a tempo
or tempo-envelope
structure.
The default is *tempo*
.
The possible units are:
unit | the symbol starts with | examples |
---|---|---|
sample | sa | sa, samp, samps, samples |
millisecond | ms | ms, msec |
second | s | s, sec, seconds |
minute | mi | mi, min, minutes |
hour | h | h, hours |
day | d | d, days |
week | w | w, weeks |
beat | b | b, beats |
meter | m | m, meters |
The number of meters depends on the velocity of the sound in m/s at
22 degrees Celsius, 1 atmosfera (the default is *sound-velocity*
).
Next: Memory Management, Previous: Time, Up: The Incudine dictionary [Contents][Index]
Bind var
to a newly allocated foreign array of type type
and size count
with dynamic extent during body
.
Create new variable bindings to sample values by allocating foreign
memory with dynamic extent during body
.
With the exception of the initializations of VUG, UGEN or DSP instances,
with-samples
performs the bindings in parallel.
Within the definition of a VUG, UGEN or DSP,
(with-samples ((var0 form0) (var1 form1) ... (varN formN)) ...)
is equivalent to
(with ((var0 form0) (var1 form1) ... (varN formN)) (declare (type sample var0 var1 ... varN)) ...)
Create new variable bindings to sample values by allocating foreign
memory with dynamic extent during body
.
with-samples*
performs the bindings sequentially.
Access the foreign array element of type :int8
specified by index
. Setfable.
Access the foreign array element of type :int16
specified by index
. Setfable.
Access the foreign array element of type :int32
specified by index
. Setfable.
Access the foreign array element of type :int64
specified by index
. Setfable.
Access the foreign array element of type :uint8
specified by index
. Setfable.
Access the foreign array element of type :uint16
specified by index
. Setfable.
Access the foreign array element of type :uint32
specified by index
. Setfable.
Access the foreign array element of type :uint64
specified by index
. Setfable.
Access the foreign array element of type :float
specified by index
. Setfable.
Access the foreign array element of type :double
specified by index
. Setfable.
Access the foreign array element of type :pointer
specified by index
. Setfable.
Fills the first size
bytes of the foreign memory area pointed to by
ptr
with the byte C.
Return the pointer to the memory area ptr
.
Copy bytes
bytes from foreign memory area src
to foreign memory
area dest
. The memory areas must not overlap.
Copy size
samples from foreign memory area src
to foreign memory
area dest
. The memory areas must not overlap.
Set the first size
samples of the area starting at ptr
to zero.
Next: Realtime, Previous: Foreign Array, Up: The Incudine dictionary [Contents][Index]
Deallocate the object obj
.
Return t
if the object obj is deallocated.
Next: Finalization, Up: Memory Management [Contents][Index]
Allocate enough foreign memory to hold size
samples.
Change the size of the memory block pointed to by ptr to hold count
objects of type type
. If zero-p
is t
, the memory is initialized with zeros.
If initial-element
is supplied, each element of the newly reallocated
memory is initialized with its value. If initial-contents
is supplied,
each of its elements will be used to initialize the contents of the newly
reallocated memory.
Return the maximum size of the foreign memory pool used to allocate temporary foreign arrays from any non-real-time thread.
Return the number of bytes that can be allocated from the foreign memory pool used to allocate temporary foreign arrays from any non-real-time thread.
Return the number of bytes allocated from the foreign memory pool used to allocate temporary foreign arrays from any non-real-time thread.
Up: Foreign Memory [Contents][Index]
Whether the foreign memory pool is usable from the real-time thread.
Return t
if the current thread is the real-time thread and the
related foreign memory pool is usable.
Allocate enough memory to hold count
objects of type type
. If
zero-p
is t
, the memory is initialized with zeros. If initial-element
is supplied, each element of the newly allocated memory is initialized
with its value. If initial-contents
is supplied, each of its elements
will be used to initialize the contents of the newly allocated memory.
This function has to be called from the real-time thread.
Change the size of the memory block pointed to by ptr to hold count
objects of type type
. If zero-p
is t
, the memory is initialized with zeros.
If initial-element
is supplied, each element of the newly reallocated
memory is initialized with its value. If initial-contents
is supplied,
each of its elements will be used to initialize the contents of the newly
reallocated memory.
This function has to be called from the real-time thread.
Free ptr
previously allocated by foreign-rt-alloc
.
This function has to be called from the real-time thread.
Call foreign-rt-free
from the real-time thread.
Return the maximum size of the foreign memory pool used from the real-time thread.
Return the the number of bytes that can be allocated from the foreign memory pool used from the real-time thread.
Return the number of bytes allocated from the foreign memory pool used from the real-time thread.
Return the maximum size of the foreign memory pool used to allocate arrays of samples in DSP and UGEN instances from the real-time thread.
Return the number of bytes that can be allocated from the foreign memory pool used to allocate arrays of samples in DSP and UGEN instances from the real-time thread.
Return the number of bytes allocated from the foreign memory pool used to allocate arrays of samples in DSP and UGEN instances from the real-time thread.
Next: Cons Pool, Previous: Foreign Memory, Up: Memory Management [Contents][Index]
All the objects with finalizations arranged by incudine-finalize
and method incudine:free
instantiated within body
are invalid beyond
the dynamic extent of body
.
Used inside the body of with-cleanup
to ignore the dynamic
finalizers during body
.
Return t
within the dynamic extend of with-cleanup
.
Arrange for the designated function
to be called when there are no
more references to obj
, including references in function
itself.
If dynamic-p
is nil
, the object is valid outside with-cleanup
.
Cancel all finalizations arranged for obj
.
Next: Foreign Pool, Previous: Finalization, Up: Memory Management [Contents][Index]
Cons pool type.
Create and return a new cons-pool
structure initialized with the
list data
or a list of length size
(128 by default).
If expand-function
is a function of one argument, the pool, it is
called to add new conses to the pool if necessary.
See also expand-cons-pool
.
The pool is incremented by grow
if more conses are required.
grow
defaults to 128.
Get a cons cell from pool
.
Return the cons
cell to the pool
.
Get a list of length list-size
from pool
.
Return the list
to the pool
.
Return the cons pool size.
If delta
is a number, add delta
cons cells to the pool
.
If delta
is nil
, the pool size is incremented by the value specified
with make-cons-pool
.
new-form
is evaluated to set the car
of a cons
.
Next: Non-Realtime Cons Pool, Up: Cons Pool [Contents][Index]
Return a preallocated cons cell.
This function has to be called from the real-time thread.
Return the cons
cell to the global pool.
This function has to be called from the real-time thread.
Return a preallocated list of length list-size
.
This function has to be called from the real-time thread.
Return the list
to the global pool.
This function has to be called from the real-time thread.
Next: Tlist, Previous: Realtime Cons Pool, Up: Cons Pool [Contents][Index]
Return a preallocated cons cell.
This function has to be called from any non-real-time thread.
Return the cons
cell to the global pool.
This function has to be called from any non-real-time thread.
Return a preallocated list of length list-size
.
This function has to be called from any non-real-time thread.
Return the list
to the global pool.
This function has to be called from any non-real-time thread.
Previous: Non-Realtime Cons Pool, Up: Cons Pool [Contents][Index]
Get a cons cell from pool
and return an empty tlist.
Returns t
if tl
is the empty tlist; otherwise, returns nil
.
Get a cons cell from the cons pool
and add obj
to the left of
the tlist tl
.
Get a cons cell from the cons pool
and add obj
to the right of
the tlist tl
.
Return the left element of the tlist tl
.
Remove the left element of the tlist tl
and return it.
Return the cons cell to the cons pool
.
Return the right element of the tlist tl
.
Next: Consing, Previous: Cons Pool, Up: Memory Management [Contents][Index]
Initialize the foreign memory pool of size size
pointed to by ptr
.
Example:
;; Pool size of 10 MB (define-constant +mem-pool-size+ (* 10 1024 1024)) (defvar *mem-pool* (cffi:foreign-alloc :char :count +mem-pool-size+)) (declaim (type foreign-pointer *mem-pool*)) (incudine.external:init-foreign-memory-pool +mem-pool-size+ *mem-pool*)
Destroy the foreign memory pool pointed to by pool
.
Allocate size
bytes from the foreign memory pool
and return a
pointer to the allocated memory.
Change the size of the foreign memory block of pool
to size
bytes.
Return a pointer to the newly allocated memory.
Free ptr
previously allocated by foreign-alloc-ex
.
Return the maximum size of the foreign memory pool
.
Return the number of bytes allocated from the foreign memory pool
.
Previous: Foreign Pool, Up: Memory Management [Contents][Index]
Rough estimate of the bytes consed in time
seconds.
Next: Multithreaded Synchronization, Previous: Memory Management, Up: The Incudine dictionary [Contents][Index]
A list of function designators which are called in an unspecified
order when the block size is changed via set-rt-block-size
.
Change the block size, update the default realtime loop callback
and run the hook incudine.util:*block-size-hook*
.
This setting stops the real-time thread.
Safe way to set the maximum number of frames per period (not used in PortAudio).
This setting stops the real-time thread during the change.
See also the configuration variable *max-buffer-size*
.
Return a real-time loop callback with an arbitrary block-size
.
If silent-p
is nil
, display jack
error messages.
Create the real-time thread named thread-name
and return :started
if no error has occured.
Call init
to initialize Incudine if necessary.
If cpu
is non-NIL, it is the zero-based number of cpu
reserved for the
real-time thread. The thread affinities of the other threads are
reverted during rt-stop
if they are unchanged in the meanwhile.
cpu
defaults to the configuration variable *rt-cpu*
.
preamble-function
is called before to create the thread. By default
it starts the auxiliary non-real-time threads and set the client name.
thread-name
defaults to “audio-rt-thread”.
thread-function
is called on the arguments thread-function-args
for
the initialisation and to call the real-time loop callback.
after-stop-function
is called by rt-stop
and it terminates the audio loop
by default.
If gc-p
is t
(default), initiate a garbage collection before to create
the thread.
Stop the real-time thread and return :stopped
.
Real-time thread status. Return :started
or :stopped
.
A list of function designators which are called in an unspecified order when the real-time thread starts.
A list of function designators which are called in an unspecified order when the real-time thread exits.
Return the zero-based number of cpu
reserved for the real-time thread.
Setfable.
Whether the audio cycles suspended during gc are recovered by processing the cached audio inputs and MIDI events (audio outputs are ignored). Setfable.
If nil
, the time is not incremented after gc, therefore the old scheduled
functions are delayed by the garbage collection time.
The default is the value of the configuration variable
*recover-suspended-audio-cycles-p*
, or nil
if that variable is not set.
Return the number of frames passed to the real-time callback function.
Setfable for Jack audio after rt-start
if the value is not greater than
the maximum size for Incudine. See also incudine:set-max-buffer-size
.
Return the sample rate of the real-time audio system.
Return the number of the occurred xruns and the time in samples of
the last xrun. If reset-p
is non-NIL, set the number of xruns to zero.
Return the time from the start of the current real-time process cycle.
time-unit
is frames
or seconds
(default).
Example:
;;; How to fix a relative OSC time in real-time thread. (in-package :scratch) (rt-start) (defvar *oscout* (osc:open :direction :output)) (defun osc-test (time) (let ((os (rt-time-offset))) ;; osc-time is (+ (timestamp) os .3) (osc:simple-bundle *oscout* (+ os .3) "/time/test" "d" os) (aat (+ time #[1/3 s]) #'osc-test it) (nrt-msg info "~A" os))) (setf (logger-level) :info) (rt-eval () (osc-test (now))) (flush-pending) (rt-stop)
Return the time in samples of the start of the current real-time process cycle.
Return the foreign pointer to the jack
client or PortAudio stream.
Evaluate form
in real-time thread.
If return-value-p
is t
, return the results of form
.
Return t
if the current thread is the real-time thread.
Real-time thread or nil
.
Non-real-time thread or nil
.
Fast-non-real-time thread or nil
.
The fast-non-real-time thread is used for fast communication with the real-time thread.
Priority of the real-time thread.
Priority of the non-real-time thread.
Priority of the fast non-real-time thread.
Responder type.
Create and return a responder for stream
.
function
is added to the list of receiver-functions called whenever
there is input available from stream
.
If stream
is a MIDI input stream, the function requires one, three
or four arguments:
(func stream) (func status-byte data-byte-1 data-byte-2) (func status-byte data-byte-1 data-byte-2 stream) (func status-byte data-byte-1 data-byte-2 &optional stream) (func &rest arguments)
If stream
is a net:input-stream
, the function takes the stream as
argument.
If stream
is a cl:input-stream
, the function takes the value
returned by the read-function passed to recv-start
.
Create and return a responder for a osc:input-stream
that responds
to an OSC message with address
and types
.
Note: the receiver reads the OSC messages from an OSC bundle too,
therefore an OSC bundle doesn’t require a specific responder.
See osc:receive
and osc:message-time
for details.
function
is added to the list of receiver-functions for stream
.
The function takes the OSC values as arguments.
Example:
(make-osc-responder *oscin* "/osc/test" "iii" (lambda (a b c) (msg warn "~D ~D ~D" a b c)))
Add the function of the responder resp
to the list of the
receiver-functions.
Remove the function of the responder resp
from the list of the
receiver-functions.
Return the list of the responders for stream
.
Remove the responders for stream
or all the responders if stream
is nil
.
Receiver type.
Return the receiver related to stream
if it exists. Otherwise,
return nil
.
Return the input stream of a receiver.
Remove the receiver related to stream
.
Return the list of the receivers.
Remove all the receivers.
Return the list of the receiver-functions called whenever there is
input available from stream
.
Start receiving from stream
.
priority
is the priority of the receiver-thread that defaults to
*receiver-default-priority*
.
If update-midi-table-p
is t
(default), update the MIDI table used by
DSP and UGEN instances.
PortMidi receiver is started with polling timeout
that defaults to
*midi-input-timeout*
.
If stream
is a cl:input-stream
, the required read-function
is the
function of one argument used to read from the stream. This function
returns the value passed to the responders of stream
. If an end of
file occurs, the receiver is stopped.
Stop receiving from stream
.
Receiver status for stream
. Return :running
, :stopped
or :unknown
.
Next: Scheduling, Previous: Realtime, Up: The Incudine dictionary [Contents][Index]
Next: Spinlock Support, Up: Multithreaded Synchronization [Contents][Index]
Use a lock-free fifo
to run function
from “audio-nrt-thread”.
This function has to be called from the real-time thread.
See also rt-funcall
.
Example:
(in-package :scratch) (rt-start) (rt-eval () ;; From rt-thread to nrt-thread. (nrt-funcall (lambda () (msg warn "[~A] sleeping..." (bt:thread-name (bt:current-thread))) ;; Block in nrt-thread. (sleep 1) (msg warn "[~A] ... and real-time funcall" (bt:thread-name (bt:current-thread))) (rt-funcall (lambda () ;; From rt-thread to nrt-thread. (nrt-funcall (lambda () (msg warn "hello from ~S." (bt:thread-name (bt:current-thread)))))))))) ;; => WARN: [audio-nrt-thread] sleeping... ;; WARN: [audio-nrt-thread] ... and real-time funcall ;; WARN: hello from "audio-nrt-thread".
Use a lock-free fifo
to run function
from “audio-fast-nrt-thread”.
This function has to be called from the real-time thread.
See also fast-rt-funcall
.
Use a lock-free fifo
to run function
from the real-time thread.
This function has to be called from “audio-nrt-thread”.
See also nrt-funcall
.
Use a lock-free fifo
to run function
from the real-time thread.
This function has to be called from “audio-fast-nrt-thread”.
See also fast-nrt-funcall
.
See documentation for sb-thread:barrier
.
See documentation for sb-ext:compare-and-swap
.
Previous: Lock-Free FIFO, Up: Multithreaded Synchronization [Contents][Index]
Spinlock type.
Create and return a spinlock
with optional name
.
The name of the spinlock. Setfable.
Acquire the spinlock
.
Return nil
if the spinlock
was already locked. Otherwise, acquire
the spinlock
and return t
.
Example:
(defun do-something-out-of-audio-thread (lock) (incudine.util:with-spinlock-held (lock) (do-something))) (defun maybe-do-something-in-audio-thread (lock) (let ((ret nil)) (unwind-protect (progn ;; TRY-ACQUIRE-SPINLOCK is lock-free. (setf ret (incudine.util:try-acquire-spinlock lock)) (if ret (do-something) (nrt-funcall #'do-something-out-of-audio-thread))) (if ret (incudine.util:release-spinlock lock))))) (at time #'maybe-do-something-in-audio-thread spinlock)
Release the spinlock
.
Acquire spinlock
for the dynamic scope of body
.
Next: DSP Graph, Previous: Multithreaded Synchronization, Up: The Incudine dictionary [Contents][Index]
Schedule function
to be called with the supplied arguments
from the
real-time thread at time
samples.
Like at
, except bind the time
to it
for the scope of the rest of
the arguments
.
Example:
(defun simple-test (time) (set-controls 1 :freq (+ 100 (random 1000))) (aat (+ time #[1 beat]) #'simple-test it))
Fast way to schedule multiple events in realtime without an extensive use
of memory barriers and/or cas
. It fills a temporary queue in non-realtime,
then it pours the content of the queue on the realtime edf
heap.
The temporary queue introduces a generally unspecified latency.
If the first form in body
is a list
(:start-time value-form)
value-form
is the absolute time offset in samples of the first
scheduled event if
(>= value-form (+ (now) latency))
If it is necessary to change the start-time within body
, the
specification is
(:start-time initial-value-form variable)
In this case, a variable
is bound to a time-getter function. It is a
function because the computation occurs in rt-thread.
Examples:
(with-schedule (:start-time (tempo-sync #[4 beats])) ...) (with-schedule (:start-time (incudine.edf:next-time #'phrase-7)) ...) (with-schedule (:start-time 0 start) ;; Initially, the variable START is `(lambda () 0)' ... (setf start (lambda () (tempo-sync #[1 b]))) ...)
The sample counter is zero and read-only inside with-schedule
:
(with-schedule (incf (now)) (princ (now))) ;; => 0.0d0
However, we can require a SETFable local counter:
(with-schedule (with-local-time () (incf (now)) (princ (now)))) ;; => 1.0d0
Cancel the scheduled events that satisfy the test
.
The function test
takes three arguments: time in samples, function and
function arguments of a scheduled event.
Example:
;; Cancel the events with function PLAY-FUNCTION (i.e. scheduled ;; from a sequencer during the playback and cancelled after stop). (unschedule-if (lambda (time function args) (declare (ignore time args)) ;; Warning: it returns NIL if PLAY-FUNCTION is an inlined function. (eq function #'play-function)))
If time-step
is nil
(default), cancel all the scheduled events.
If time-step
is a number, the evaluation of a pending event is
forced every time-step
samples.
Clear the buffers of the real-time FIFO’s.
Up: Scheduling [Contents][Index]
Heap node type.
Create and return a new heap node
structure.
Heap type.
Default edf
heap.
Max number of scheduled events. It is assumed to be a power of two.
Create and return a new heap
structure to schedule at maximum size
events.
size
defaults to heap-size.
Whether the edf
heap is empty.
Return the number of entries in the edf
heap.
Integer identifier for the root node of the edf
heap.
Schedule function
to be called with the supplied arguments
at time
samples.
Earliest Deadline First scheduling loop to call the functions scheduled at the current time.
Return the time in samples of the next scheduled function
, starting
its search at start-time
(zero by default). Otherwise, return zero if
the searched event is not available.
If function
is nil
(default), return the time of the next scheduled event.
Example:
;; The bass line is synchronized with the next drum pattern. ;; Note: the time is more reliable from rt-thread. (rt-eval () (at (incudine.edf:next-time #'drum-pattern) #'bass-line ...))
Return the time in samples of the last scheduled function to call.
Regiter a hook function
to be run when flush-pending
is called.
Unregister the flush-pending hook function
.
Reset the heap-pool size to the value of the configuration variable
*edf-heap-pool-size*
.
Next: Logging, Previous: Scheduling, Up: The Incudine dictionary [Contents][Index]
Node type.
Return the node with integer identifier id
.
Return t
if object is of type node
.
The root node of the node tree.
Return the integer identifier of the node or nil
if the node is null.
Return the name of the node.
Return the number of live nodes.
Deallocate the node
.
node
is a node
structure or the integer identifier of the node.
Free all the nodes.
Return t
if the node is null.
Return the current value of the node-gain. Setfable.
Return t
if node output is enabled. Setfable.
Whether node output is enabled for all the nodes.
Return the duration of the fade in/out of the node output. Setfable.
Default fade-time.
Return the curve of the envelope
structure used to fade in/out
the node output. Setfable.
Default curve of the envelope
structure used for fade in/out.
If *node-enable-gain-p*
is t
or node-enable-gain-p
returns t
, change
the node-gain from 0 to 1 in duration
or node-fade-time
seconds.
The fade curve
is the curve of an envelope
structure or nil
to use the
curve returned by node-fade-curve
.
If *node-enable-gain-p*
is t
or node-enable-gain-p
returns t
, change
the node-gain from the current value to zero in duration
or node-fade-time
seconds.
The fade curve
is the curve of an envelope
structure or nil
to use the
curve returned by node-fade-curve
.
Change the node-gain of obj
from start
to end
in dur
seconds.
obj
is a node
structure or the integer identifier of the node.
start
defaults to the current level.
The fade curve
is the curve of an envelope
structure or nil
to use the
curve returned by node-fade-curve
.
The one-argument function done-action
, #'identity
by default, is called
when the DSP finished playing. The function argument is the DSP node.
Return t
if the node is related to a released object (i.e. DSP instance).
Return the start time of the node in samples.
How long the node has been running. The returned time is in samples.
Return the next avalaible integer identifier for a node.
A list of function designators which are called in
an unspecified order at the time the object obj
is freed. The function
argument is the object to free.
A list of function designators which are called in
an unspecified order at the time the object obj
is stopped by calling
the stop
method. The function argument is the object to stop.
Return the parent group of the node obj
.
Create a group node.
id
is an integer identifier or nil
to use the next available id.
The keywords head
, tail
, before
and after
specify the add-action to
add the new group node. The value is the target node or node-id. By
default the new group node is added at the head of the root node.
If name
is non-NIL, it is the name of the group.
If action
is non-NIL, it is a one-argument function called on the
group node after the initialization.
free-hook
is a list of function designators which are called in an
unspecified order at the time the group node is freed. The function
argument is the group node to free. stop-hook
is a similar list but it
is called when the group node is stopped.
Return t
if obj
is a group node.
Iterate over the live nodes with var
bound to each node and
execute the body once for each node, then result
form is evaluated.
The first node is node
or *root-node*
.
Iterate over the nodes of the group
node with var
bound to each node
and execute the body once for each node, then result
form is evaluated.
If recursive-p
is t
(default), iterate over the nodes of the sub-groups
of group
.
Move a live node of the node tree.
If move-action
is :head
, move node
at the head of the group node target
.
If move-action
is :tail
, move node
at the tail of the group node target
.
If move-action
is :before
, move node
immediately before target
.
If move-action
is :after
, move node
immediately after target
.
Return t
if node1
precedes node0
.
Return t
if node0
precedes node1
.
Return t
if node
is at the head of group
.
Return t
if node
is at the tail of group
.
Start playing.
init-function
is the one-argument initialization function called on
the node object. init-function
defaults to #'identity
.
id
is an integer identifier or nil
to use the next available id.
The keywords head
, tail
, before
, after
and replace
specify the add-action
to add the new node. The value is the target node or node-id. By default
the new node is added at the head of the root node.
If name
is non-NIL, it is the name of the node object.
If action
is non-NIL, it is a one-argument function called on the
node object after the initialization.
free-hook
is a list of function designators which are called in an
unspecified order at the time the node object is freed. The function
argument is the node to free. stop-hook
is a similar list but it
is called when the node object is stopped.
Example: low-passed noise with single-float values (no consing on 64-bit platforms).
(set-rt-block-size 1) (rt-start) (play (let ((y0 0.0) (y1 0.0)) (declare (single-float y0 y1)) (lambda () (setf y0 (- (random .04) .02)) (setf y1 (+ y0 (* .995 y1))) (incf (audio-out 0) (sample y1)) ;; Consing if the function returns a double-float value. (values))))
A similar example with buses and double-float values:
(rt-start) (play (symbol-macrolet ((y0 (bus 0)) (y1 (bus 1)) (coef (bus 2))) (setf y1 (sample 0)) (setf coef (sample .995)) (lambda () (setf y0 (sample (- (random .04) .02))) (setf y1 (+ y0 (* coef y1))) (incf (audio-out 0) y1) (values))))
Stop playing.
Pause the object.
Unpause the object.
Return t
if object is paused.
Whether the DSP related to node
finished playing. Setfable.
node
defaults to vug:dsp-node
.
Reinitialize node
by calling the initialization function with
arguments args
.
Dump information about obj
to stream
.
Example: DSP cycle on demand through unpause
(dsp! cycle-on-demand () (with ((i 1)) (declare (fixnum i)) (nrt-msg warn "DSP cycle number ~D" i) (incf i) (pause (dsp-node)))) (rt-start) (cycle-on-demand :id 1) ; WARN: DSP cycle number 1 (pause-p 1) ;; => T (dump (node 0)) ;; group 0 ;; node 1 (pause) ;; CYCLE-ON-DEMAND (unpause 1) ; WARN: DSP cycle number 2 (unpause 1) ; WARN: DSP cycle number 3 (unpause 1) ; WARN: DSP cycle number 4 (reinit 1) (unpause 1) ; WARN: DSP cycle number 1 (unpause 1) ; WARN: DSP cycle number 2 (unpause 1) ; WARN: DSP cycle number 3 (free 1)
Return the getter function to get the control parameter control-name
related to the node obj
.
obj
is a node
structure or the integer identifier of the node.
Return the setter function to set the control parameter control-name
related to the node obj
.
obj
is a node
structure or the integer identifier of the node.
Return the list of the values of the control parameters related to
the node obj
.
Return the list of the names of the control parameters related to
the node obj
.
Return the value of the control parameter control-name
related
to the node obj
. Setfable.
obj
is a node
structure or the integer identifier of the node.
If the control parameter control-name
is represented by a foreign
object (i.e. a control of type sample
), the first returned value is a
foreign pointer to the control value. The second returned value is the
function of no arguments called to update the dependencies if it exists.
Example:
(in-package :scratch) (dsp! dsp-control ((node (or fixnum node)) (control-name symbol) initial-value value duration) (with ((ptr (cffi:null-pointer)) (func nil) (this (dsp-node))) (declare (type pointer ptr) (type (or function null) func) (type node this)) (initialize ;; The foreign pointer is useless if the controlled node is freed. (push (lambda (n) n (free this)) (free-hook node)) (setf (values ptr func) (control-pointer node control-name))) (setf (smp-ref ptr) (line initial-value value duration)) (if func (funcall (the function func))))) (dsp! oscilla (freq amp) (stereo (sine freq amp))) (rt-start) (oscilla 440 .3 :id 1 :action (lambda (n) (dsp-control n 'freq 440 880 1 :id 2 :before n))) (set-controls 2 :value 100 :duration 3) (set-controls 2 :value 440 :duration .25) ;; `(free 2)' is called from the free-hook of node 1. (free 1)
Set the value
of the control parameter control-name
related to the node obj
.
obj
is a node
structure or the integer identifier of the node.
Set one or more control parameters related to the node obj
.
obj
is a node
structure or the integer identifier of the node.
The rest is an even number of arguments that are alternating control parameter names and values.
Next: defun*, lambda* and defmacro*, Previous: DSP Graph, Up: The Incudine dictionary [Contents][Index]
Stream for log messages.
Output stream for null output.
Whether force-output
is called after a log message.
Produce a formatted log message controlled by format-control
and
format-arguments
.
type
should be one of error
, warn
, info
or debug
.
Produce a formatted log message in nrt-thread controlled by
format-control
and format-arguments
.
type
should be one of error
, warn
, info
or debug
.
Return the log level. Should be one of :error
, :warn
(default),
:info
or :debug
. Setfable.
Return the time unit used for the log messages. Should be one
of :sec
, :samp
or nil
(default). Setfable.
Return the function of no arguments to format the timestamp used for the log messages. Setfable.
Default function to format the timestamp used for the log messages.
Log level
, time-unit
and time-format-function
to log messages inside body
.
Next: Sharp-T Reader Macro, Previous: Logging, Up: The Incudine dictionary [Contents][Index]
defun*
, lambda*
and defmacro*
are inspired by the extensions
define*, lambda* and define-macro* in Bill Schottstaedt’s Scheme
implementation s7 1.
Some examples from s7.html translated to CL:
(defun* hi (a (b 32) (c "hi")) (list a b c)) (hi 1) ; => (1 32 "hi") (hi :b 2 :a 3) ; => (3 2 "hi") (hi 3 2 1) ; => (3 2 1) (defun* foo ((a 0) (b (+ a 4)) (c (+ a 7))) (list a b c)) (foo :b 2 :a 60) ; => (60 2 67) (defun* foo (&rest a &rest b) (mapcar #'+ a b)) (foo 1 2 3 4 5) ; => (3 5 7 9) (defun* foo ((b 3) &rest x (c 1)) (list b c x)) (foo 32) ; => (32 1 NIL) (foo 1 2 3 4 5) ; => (1 3 (2 3 4 5)) (funcall (lambda* ((b 3) &rest x (c 1) . d) (list b c x d)) 1 2 3 4 5) ; => (1 3 (2 3 4 5) (4 5)) (defmacro* add-2 (a (b 2)) `(+ ,a ,b)) (add-2 1 3) ; => 4 (add-2 1) ; => 3 (add-2 :b 3 :a 1) ; => 4
Every argument in args
has a default value and is automatically
available as a keyword argument. The default value is either nil
if
unspecified, or given in a list whose first member is the argument name.
The last argument can be preceded by &rest or a dot to indicate that
all other trailing arguments should be packaged as a list under that
argument’s name. A trailing or rest argument’s default value is nil
.
You can have more than one &rest parameter.
See defun*
.
See defun*
for details.
A nested lambda list with optional keywords begins with the special keyword &optional-key, and precedes the optional keywords of the (possibly nested) lambda list. For example:
(defmacro* optkey-test-1 ((a 1) (b 2) (c 3)) `(list ,a ,b ,c)) (defmacro* optkey-test-2 ((&optional-key (a 1) (b 2)) &rest rest) `(list ,a ,b ,@rest)) (defmacro* optkey-test-3 ((&optional-key (a 1) (b 2)) (&optional-key (&optional-key (c 3) (d 4)) (e 5)) (f 6) g . h) `(list ,a ,b ,c ,d ,e ,f ,g ,@h)) (optkey-test-1) ; => (1 2 3) (optkey-test-1 :b 123) ; => (1 123 3) (optkey-test-2) ; => (1 2) (optkey-test-2 (:b 3) 4 5 6) ; => (1 3 4 5 6) (optkey-test-3) ; => (1 2 3 4 5 6 NIL) (optkey-test-3 () ((:d 123))) ; => (1 2 3 123 5 6 NIL) (optkey-test-3 () () :h (1 2 3)) ; => (1 2 3 4 5 6 NIL 1 2 3) (optkey-test-3 (10) ((20) 30) :g 40 :f 50 :h (60)) ;; => (10 2 20 4 30 50 40 60)
Return the optional-key arguments of arglist
.
Next: Numeric Types, Previous: defun*, lambda* and defmacro*, Up: The Incudine dictionary [Contents][Index]
Enable sharp-t reader syntax, useful to apply a filter multiple times.
Example: apply a pole filter four times (4t)
#4t(pole in coef)
is equivalent to
(pole (pole (pole (pole in coef) coef) coef) coef)
Often the input of a filter is the first argument, but if it is not the case, an integer after sharp-t specifies the position of the input in the argument list starting from zero. Example:
#4t1(fname x in y)
is equivalent to
(fname x (fname x (fname x (fname x in y) y) y) y)
Next: Constants, Previous: Sharp-T Reader Macro, Up: The Incudine dictionary [Contents][Index]
Coerce number
to type sample
.
A limited-sample
is a sample
between -4e18 and 4e18.
sin
, cos
and tan
are optimized on x86 if the argument type is
limited-sample
.
Correspond to limited-sample
on sbcl
x86.
Type designator for a foreign array of samples.
Non negative fixnum
on 64-bit platforms.
Next: Utilities, Previous: Numeric Types, Up: The Incudine dictionary [Contents][Index]
Zero coerced to sample
.
Two pi
coerced to sample
.
The inverse of two pi
coerced to sample
.
Half pi
coerced to sample
Natural logarithm of 0.001 coerced to sample
.
Square root of two coerced to sample
.
Size in bytes of the foreign type sample
.
Size in bytes of a foreign complex number.
Size in bytes of the foreign pointer.
Foreign address type. Should be one of :int32
, :int64
.
Maximum table length used to compute the phase of type integer for a wavetable lookup oscillator with power-of-two buffer size.
The bitmask calculated as +table-maxlen+
minus 1.
Number of bits needed to represent the bitmask +phase-mask+
.
Division of +table-maxlen+
by two pi
.
Next: Analysis, Previous: Constants, Up: The Incudine dictionary [Contents][Index]
Return a string that identifies the Incudine version.
Whether the current Incudine version is equal to or greater than the version specified in the arguments.
Example:
(incudine-version->= 0 9 25)
Return a list of lists
(deprecated-symbol :from date)
If obsolete-p
is t
, the deprecated symbol is obsolete starting from
the specified date.
A deprecated symbol is obsolete after one year.
Incudine initialization, optionally forced if force-p
is t
.
Exit lisp with code
from a non-real-time thread.
code
defaults to 0.
Declaration to muffle compiler-notes.
Execute body
by muffling compiler-notes.
Return a string that describes the error code errno
.
errno
defaults to the foreign integer variable errno. See errno man
page for details.
Return the block size.
Define a sequence of DSP’s by using the stop-hook
of the functions
defined by DSP!. The last of the function-call-forms
is arbitrary
and useful to define recursive sequences.
Example:
(defun seq-test (rep freq amp) (when (plusp rep) (dsp-seq (dsp-test freq amp env) (dsp-test (* freq 7/4) amp env) (dsp-test (* freq 2) amp env) (seq-test (1- rep) freq amp))))
Perform a circular shift of length n
.
Quantize obj
with respect to a real number, a
vector, a buffer
or tuning
structure in sorted order.
If obj
is a vector, a buffer
or tuning
structure, the keywords start
and
end
are the bounding index designators, and the keyword filter-function
is
usable to apply a function to the quantized value. The arguments of that
function are the vector index and the quantized value.
Return base
raised to the power
.
The returned value is of type double-float
.
If base
is a negative value and power
is not an integer,
floating-point-invalid-operation
is signalled.
Linear interpolation between y0
and y1
by in
.
Four-point interpolation.
Sinusoidal interpolation between y0
and y1
by in
.
Convert the value
from Hz to radians.
Convert the value
from radians to Hz.
Convert the value
from dB to linear.
Convert the value
from linear to dB.
Coerce value
from type sample
to type fixnum
.
If roundp
is t
, round value
to the nearest integer.
value
has to be between most-negative-fixnum
and most-positive-fixnum
.
Coerce value
from type sample
to type integer
.
Coerce value
from type single-float
or double-float
to type fixnum
.
If roundp
is t
, round value
to the nearest integer.
value
has to be between most-negative-fixnum
and most-positive-fixnum
.
Return a real pole for a 60dB exponential decay in time
seconds.
Convert the representation of the complex sample data from complex to polar.
ptr
is the foreign pointer to size
complex samples.
Convert the representation of the complex sample data from polar to complex.
ptr
is the foreign pointer to size
complex samples.
Sort a foreign array of size
samples pointed to by pointer
.
Convert reals to rationals and try to minimize the ratios by introducing an error in the significand of the floating point number. The error is 0.0005% by default.
Parse a floating point number from the substring of string
delimited by start
and end
.
The first value returned is either the floating point number that was
parsed or nil
.
The second value is either the index into the string of the delimiter that terminated the parse, or the upper bounding index of the substring.
The type
of the returned value is single-float
by default.
Iterate over the channels
with var
bound to each number of channel
and execute the body once for each channel, then result
form is evaluated.
Access the foreign array element of type sample
specified by index
. Setfable.
Whether the positive integer n
is a power of two.
Return the next power of two of the positive integer n
.
Sample rate in Hz.
Duration of one sample in seconds.
A list of function designators which are called in an unspecified
order when the sample rate is changed via set-sample-rate
or
set-sample-duration
.
Set the sample rate to value
and run the hook *sample-rate-hook*
.
The following variables are updated: *sample-rate*
, *sample-duration*
,
*twopi-div-sr*
, *sr-div-twopi*
, *pi-div-sr*
, *minus-pi-div-sr*
and *cps2inc*
.
Set the sample duration to value
and run the hook *sample-rate-hook*
.
The following variables are updated: *sample-rate*
, *sample-duration*
,
*twopi-div-sr*
, *sr-div-twopi*
, *pi-div-sr*
, *minus-pi-div-sr*
and *cps2inc*
.
Division of +table-maxlen+
by the sample rate.
Division of two pi
by the sample rate.
Division of the sample rate by two pi
.
Division of pi
by the sample rate.
Division of minus pi
by the sample rate.
Velocity of the sound in m/s at 22 degrees Celsius, 1 atmosfera.
The inverse of the sound velocity in s/m at 22 degrees Celsius, 1 atmosfera.
A list of function designators which are called in an unspecified
order when the sound velocity is changed via set-sound-velocity
.
Set the the velocity of the sound in m/s at 22 degrees Celsius, 1
atmosfera and run the hook *sound-velocity-hook*
.
Set the current random state.
Return the cpu
affinity mask of thread
. Setfable.
It is also possible to specify a list of zero-based processors to set the thread affinity.
For more details on cpu
affinity masks, see taskset and/or
sched_setaffinity man page.
Example: 8 processors
(rt-stop) (mapcar (lambda (thr) ;; Exclude processor 0. The list is equivalent ;; to the affinity mask #b11111110. (setf (thread-affinity thr) '(1 2 3 4 5 6 7))) (bt:all-threads)) (rt-start) ;; Dedicate processor 0 to real-time thread. (setf (thread-affinity *rt-thread*) '(0)) ;; => 1 ;; Verify affinity mask. (mapcar #'thread-affinity (bt:all-threads)) ;; => (1 254 254 254)
Return the thread priority. Setfable.
See documentation for sb-sys:with-pinned-objects
.
See documentation for sb-sys:without-interrupts
.
Next: GEN Routines, Previous: Utilities, Up: The Incudine dictionary [Contents][Index]
Next: Analysis Buffer, Up: Analysis [Contents][Index]
Analysis type.
Return t
if object is of type analysis
.
Return the foreign pointer to the analysis input buffer.
Return the analysis input buffer size.
Return the foreign pointer to the analysis output buffer.
Return the analysis output buffer size.
Return the time in samples of the last analysis. Setfable.
Update the modification time of the analysis.
Discard the analysis.
Next: Fast Fourier Transform, Previous: Analysis Structure, Up: Analysis [Contents][Index]
Abuffer (Analysis Buffer) type.
Create and return a new abuffer
structure linked to analysis-object
.
Set real-time-p
to nil
to disallow real-time memory pools.
Return t
if object is of type abuffer
.
Deallocate the abuffer
.
Return t
if the abuffer
is deallocated.
Return the foreign pointer to the abuffer data.
Return the abuffer data size.
Return the number of analysis bins of the abuffer.
Return the analysis object linked to the abuffer.
Return the modification time in samples of the abuffer obj
. Setfable.
Whether the abuffer is normalized.
Convert the representation of the abuffer data from polar to complex if necessary.
Convert the representation of the abuffer data from complex to polar if necessary.
Return the imaginary part of the analysis bin nbin
of the abuffer obj
.
Setfable.
Return the real part of the analysis bin nbin
of the abuffer obj
.
Setfable.
Fill the abuffer with the updated analysis data of the linked analysis object.
If force-p
is nil
(default), the abuffer is updated once for the
current time.
Called within compute-abuffer
to update the linked object.
Update the modification time of the abuffer data.
Discard the retrieved data of the abuffer
object obj
.
Next: Short-Time Fourier Transform and Phase Vocoder, Previous: Analysis Buffer, Up: Analysis [Contents][Index]
FFT type.
Create and return a new FFT structure with the specified size
.
window-size
is the size of the analysis window and defaults to size
.
window-function
is nil
or a function of two arguments called to fill the
FFT data window. The function arguments are the foreign pointer to the
data window of type sample
and the window size respectively.
If window-function
is nil
, the window is initially rectangular but
we can call fft-window
to get the pointer to the buffer and directly
manipulate the sample values.
window-function
defaults to *fft-default-window-function*
.
The argument flags
for the FFT planner is usually +fft-plan-optimal+
,
+fft-plan-best+
or +fft-plan-fast+
. If a cached fft-plan
with the same size
already exists, return it if the current thread is the real-time thread,
otherwise recompute the plan if flags
is non-NIL or the cached fft-plan
is
not the best. Without a cached fft-plan
, flags
defaults to +fft-plan-fast+
.
Set real-time-p
to nil
to disallow real-time memory pools.
Return t
if object is of type FFT.
Return the FFT size.
FFT planner type.
Return the planner of the FFT instance.
Return the foreign pointer to the sample values of the FFT window and the FFT window size.
Return the sample value of the current FFT input.
Setfable also with an input value of type real
, but it is faster if
the type is sample
.
The FFT structure uses a ring buffer internally and the input buffer is filled during the transform.
Compute an unnormalized fast Fourier transform on the input data of
the FFT structure obj
and write the results into the FFT output buffer.
compute-ifft
normalizes the input data before the inverse transform.
If force-p
is nil
(default), the transform is computed once for the
current time.
Example:
(in-package :scratch) (defvar *fft* (make-fft 8 :window-function #'rectangular-window)) ;; Fill the internal ring buffer with an impulse. (setf (fft-input *fft*) 1d0) (loop repeat (1- (fft-size *fft*)) do (setf (fft-input *fft*) 0d0)) (compute-fft *fft* t) ;; Output with 5 complex analysis bins. (loop for i below (analysis-output-buffer-size *fft*) collect (smp-ref (analysis-output-buffer *fft*) i)) ;; => (1.0d0 0.0d0 1.0d0 0.0d0 1.0d0 0.0d0 1.0d0 0.0d0 1.0d0 0.0d0)
Perform a circular shift of length n
during compute-fft
.
IFFT type.
Create and return a new IFFT structure with the specified size
.
window-size
is the size of the analysis window and defaults to size
.
window-function
is nil
or a function of two arguments called to fill the
FFT data window. The function arguments are the foreign pointer to the
data window of type sample
and the window size respectively.
If window-function
is nil
, the window is initially rectangular but
we can call ifft-window
to get the pointer to the buffer and directly
manipulate the sample values.
window-function
defaults to *fft-default-window-function*
.
The argument flags
for the FFT planner is usually +fft-plan-optimal+
,
+fft-plan-best+
or +fft-plan-fast+
. If a cached fft-plan
with the same size
already exists, return it if the current thread is the real-time thread,
otherwise recompute the plan if flags
is non-NIL or the cached fft-plan
is
not the best. Without a cached fft-plan
, flags
defaults to +fft-plan-fast+
.
Set real-time-p
to nil
to disallow real-time memory pools.
Return t
if object is of type IFFT.
Return the IFFT size.
Return the planner of the IFFT instance.
Return the foreign pointer to the sample values of the IFFT window and the IFFT window size.
Return the sample value of the current IFFT output.
Compute an inverse fast Fourier transform on the input data of the
IFFT structure obj
and write the results into the IFFT output buffer.
If abuffer
is non-NIL, update that abuffer and copy the results into
the IFFT input buffer before to calculate the transform. If the abuffer
is linked to a FFT object, the copied analysis data are normalized
because the fast Fourier transform of compute-fft
is unnormalized.
If force-p
is nil
(default), the transform is computed once for the
current time.
Example:
(in-package :scratch) (defvar *ifft* (make-ifft 8 :window-function #'rectangular-window)) ;; Set the real part of the complex analysis bins to 1/8. (dotimes (i (analysis-input-buffer-size *ifft*)) (setf (smp-ref (analysis-input-buffer *ifft*) i) (if (evenp i) 125d-3 0d0))) (compute-ifft *ifft* nil t) ;; The output is an impulse. (loop for i below (ifft-size *ifft*) collect (ifft-output *ifft*)) ;; => (1.0d0 0.0d0 0.0d0 0.0d0 0.0d0 0.0d0 0.0d0 0.0d0)
Perform a circular shift of length n
.
If before-windowing-p
is T, perform the shift during compute-ifft
,
before the application of the window.
Return the analysis window size. Setfable.
nil
or the function of two arguments called to fill an analysis data window.
The function arguments are the foreign pointer to the data window of type
sample
and the window size respectively. Setfable.
Return the STFT frame offset. Setfable.
Default function of two arguments called to fill an analysis data window.
The function arguments are the foreign pointer to the data window of type
sample
and the window size respectively.
Initially this is set to (GEN:SINE-WINDOW).
Fill a foreign-array
of the given size
and type sample
with a
rectangular window.
Iterate over the complex values of one or more abuffer
structures
in abuffer-src-list
and abuffer-dest-list
with index-var
bound to each
number of analysis bin from index-start
to index-end
, then result
form
is evaluated.
nbins-var
is bound to the number of analysis bins that it is supposed
to be the same for all the abuffer’s.
index-start
and index-end
default to 0 and the number of analysis bins.
The strings x-var-prefix
and y-var-prefix
are the prefixes of the real
and imaginary parts of a complex number, respectively. For example, if
x-var-prefix
is “MAG”, the variables mag0
, mag1
and mag2
are bound
to the real parts of each complex value related to the first three
abuffer’s.
If coord-check-p
is t
(default), the representation of the data for
the abuffer’s in abuffer-src-list
is converted if necessary.
The optional init
form is inserted before the loop.
The modification time of the abuffer’s in abuffer-dest-list
is updated.
Iterate over the complex values of one or more abuffer
structures
in abuffer-src-list
and abuffer-dest-list
by using polar coordinates,
with index-var
bound to each number of analysis bin from index-start
to index-end
, then result
form is evaluated.
nbins-var
is bound to the number of analysis bins that it is supposed
to be the same for all the abuffer’s.
index-start
and index-end
default to 0 and the number of analysis bins.
“MAG” and “PHASE” are the prefixes of the variables bound to the
real and imaginary parts of each complex value of the abuffer’s: mag0
and phase0
for the first abuffer, mag1
and phase1
for the second, etc.
If coord-check-p
is t
(default), the representation of the data for
the abuffer’s in abuffer-src-list
is converted if necessary.
The optional init
form is inserted before the loop.
The modification time of the abuffer’s in abuffer-dest-list
is updated.
Examples:
(dofft-polar (i nbins ((compute-abuffer abuf)) () :result abuf) (when (>= i threshold) (setf mag0 +sample-zero+))) (dofft-polar (i nbins ((compute-abuffer abuf-src)) (abuf-dest) :result abuf-dest :index-start 1 :index-end (1- nbins)) (if (or (< mag0 threshold) (< (abuffer-realpart abuf-src (1- i)) threshold) (< (abuffer-realpart abuf-src (1+ i)) threshold)) (setf mag1 +sample-zero+ phase1 +sample-zero+) (setf mag1 mag0 phase1 phase0)))
Iterate over the complex values of one or more abuffer
structures
in abuffer-src-list
and abuffer-dest-list
by using complex coordinates,
with index-var
bound to each number of analysis bin from index-start
to index-end
, then result
form is evaluated.
nbins-var
is bound to the number of analysis bins that it is supposed
to be the same for all the abuffer’s.
index-start
and index-end
default to 0 and the number of analysis bins.
“RE” and “IM” are the prefixes of the variables bound to the real
and imaginary parts of each complex value of the abuffer’s: re0
and
im0
for the first abuffer, re1
and im1
for the second, etc.
If coord-check-p
is t
(default), the representation of the data for
the abuffer’s in abuffer-src-list
is converted if necessary.
The optional init
form is inserted before the loop.
The modification time of the abuffer’s in abuffer-dest-list
is updated.
Calculate and cache a new fft-plan
structure with the specified size
if necessary.
flags
is usually +fft-plan-optimal+
, +fft-plan-best+
or +fft-plan-fast+
.
If a cached fft-plan
with the same size already exists, return it if the
current thread is the real-time thread, otherwise recompute the plan if
flags
is non-NIL or the cached fft-plan
is not the best. Without a cached
fft-plan
, flags
defaults to +fft-plan-fast+
.
Fast computation of a reasonable FFT plan.
Slow computation of an accurate FFT plan.
Slowest computation of an optimal FFT plan.
Remove the cached fft-plan
with the specified size
.
Return the cached fft-plan
with the specified size
if it exists.
Otherwise, return nil
.
Return the list of the cached fft-plan
instances.
If only-size-p
is t
, return the sizes of these planners.
Previous: Fast Fourier Transform, Up: Analysis [Contents][Index]
PVbuffer type.
A pvbuffer
contains a sequence of spectral data.
Create and return a new pvbuffer
structure with the specified frames
and fft-size
.
The number of channels
defaults to 1.
The sample-rate
of the analysed data is incudine.util:*sample-rate*
by
default.
data-type
is one of :complex
(default), :magnitude-phase
or
:magnitude-frequency
.
window-size
is the size of the analysis window and defaults to fft-size
.
window-function
is nil
or a function of two arguments called to fill the
window buffer. The function arguments are the foreign pointer to the
data window of type sample
and the window size respectively.
window-function
defaults to *fft-default-window-function*
.
If the pvbuffer
is used to store the STFT frames, hop-size
is the STFT
frame offset and defaults to a quarter of window-size
.
Set real-time-p
to nil
to disallow real-time memory pools.
Create and return a new PVbuffer structure with spectral data
obtained from a sequence of FFT’s of the buffer
structure buf
partitioned with partition size partsize
. This PVbuffer works with
part-convolve
, a VUG to compute the partitioned convolution between a
signal and a multi-channel impulse response.
The optional keywords start
and frames
mark the beginning position in
frames and the number of frames of the buffer, respectively.
Create and return a new FFT structure to fill the PVbuffer frames.
The argument flags
for the FFT planner is usually +fft-plan-optimal+
,
+fft-plan-best+
or +fft-plan-fast+
. If a cached fft-plan
with the same size
already exists, return it if the current thread is the real-time thread,
otherwise recompute the plan if flags
is non-NIL or the cached fft-plan
is
not the best. Without a cached fft-plan
, flags
defaults to +fft-plan-fast+
.
Set real-time-p
to nil
to disallow real-time memory pools.
Create and return a new IFFT structure to transform the PVbuffer data.
The argument flags
for the FFT planner is usually +fft-plan-optimal+
,
+fft-plan-best+
or +fft-plan-fast+
. If a cached fft-plan
with the same size
already exists, return it if the current thread is the real-time thread,
otherwise recompute the plan if flags
is non-NIL or the cached fft-plan
is
not the best. Without a cached fft-plan
, flags
defaults to +fft-plan-fast+
.
Set real-time-p
to nil
to disallow real-time memory pools.
Create and return a new PVbuffer structure with spectral data
obtained from the Short-Time Fourier Transform of a sound file or
buffer
data with the specified fft-size
.
input
is of type string
, pathname
or buffer
.
window-size
defaults to half fft-size
.
window-function
is a function of two arguments called to fill the
FFT data window. The function arguments are the foreign pointer to
the data window of type sample
and the window size respectively.
window-function
defaults to *fft-default-window-function*
.
hop-size
is the STFT frame offset and defaults to a quarter of
window-size
.
start
and frames
mark the beginning position in frames and the number
of frames of input
, respectively.
If normalized-p
is t
(default), the FFT analysis data are normalized.
If zero-phase-window-p
is t
, the FFT windows are zero-phase.
Deallocate the pvbuffer
.
Return t
if the pvbuffer
is deallocated.
Return the foreign pointer to the sample values of the analysis window data and window size of the PVbuffer.
Return the analysis window size of the pvbuffer frames. Setfable.
Return the analysis window function of the pvbuffer frames. Setfable.
Return the STFT frame offset of the pvbuffer. Setfable.
Return the foreign pointer to the data frame
of a PVbuffer channel
.
frame
and channel
default to zero.
No bounds checking.
If the PVbuffer data type is not :magnitude-frequency
and obj
is of
type FFT or abuffer
, fill the data frame
of the PVbuffer channel
with
the FFT analysis.
channel
defaults to 0.
Example:
(defvar *pvb* (make-pvbuffer 10 1024 :window-size 512)) (defvar *fft* (make-fft-from-pvbuffer *pvb*)) (dotimes (frame 10) (dotimes (i 1024) (setf (fft-input *fft*) (random 1d0))) ;; zero-phase FFT window. (circular-shift *fft* -256) (fill-pvbuffer *pvb* frame (compute-fft *fft*))) ;; Convert data type from complex to magnitude-frequency. ;; (setf (pvbuffer-data-type *pvb*) :magnitude-frequency)
If the PVbuffer data type is not :magnitude-frequency
, copy the data frame
of a PVbuffer channel
to destination
and return the PVbuffer instance.
destination
is of type IFFT or abuffer
.
Return the PVbuffer size.
Return the number of the PVbuffer channels.
Return the number of the PVbuffer spectral frames.
Return the PVbuffer sample rate. Setfable.
Return the FFT size used to compute the spectral data of the PVbuffer.
Return the PVbuffer block size.
Return the PVbuffer data type. It is one of :complex
(default),
:magnitude-phase
or :magnitude-frequency
. Setfable.
Return the PVbuffer scale factor. It is one if the PVbuffer data are normalized.
Multiply the magnitudes of the unnormalized PVbuffer data by 1/fftsize.
Whether the PVbuffer data are normalized.
Save the PVbuffer analysis data to the file path
.
path
is of type string or pathname.
Create a new PVbuffer by loading the file path
.
path
is of type string or pathname.
Next: MIDI, Previous: Analysis, Up: The Incudine dictionary [Contents][Index]
Next: Envelope, Up: GEN Routines [Contents][Index]
Return a function called to fill a foreign array with the analysis
data of an analysis
or abuffer
structure passed as argument.
The returned function takes two arguments, the foreign pointer to the sample data and the data size, and returns the foreign array.
Next: Filter, Previous: Analysis, Up: GEN Routines [Contents][Index]
Return a function called to fill a foreign array with the envelope
defined in the passed envelope
structure env
.
The returned function always refers to the same envelope
structure.
It takes two arguments, the foreign pointer to the sample data and the
data size, and returns three values: the foreign array, the scale
factor to normalize the samples and the boolean normalize-p
to specify
whether the normalization is necessary.
If periodic-p
is t
(default), the resultant envelope is a cycle of a
periodic waveform.
Next: Partials, Previous: Envelope, Up: GEN Routines [Contents][Index]
Return a function called to fill a foreign array with the FIR filter coefficients obtained from a sequence of break-point pairs interpreted as frequency response.
The returned function takes two arguments, the foreign pointer to the
sample data and the data size, and returns three values: the foreign
array, the scale factor to normalize the samples and the boolean
normalize-p
to specify whether the normalization is necessary.
sample-rate
defaults to sample-rate.
curve
sets the shape of the segments of the frequency response; the
possible values are :step
, :lin
or :linear
, :exp
or :exponential
, :sin
or :sine
, :wel
or :welch
, :sqr
or :square
, :cub
or :cubic
, a number
that represents the curvature value between two levels for all the
segments or a list of the prior values to specify the curvature values
for each segment. curve
is ignored if base
is non-NIL.
base
(1 by default) is e^k and the curvature depends on the highest
and lowest levels.
Return a function called to fill a foreign array with the FIR filter coefficients necessary to approximate a Hilbert transform.
If window-function
is non-NIL, it is a function of two arguments
(i.e. the function created by gen:kaiser
), the foreign pointer to
the data window of type sample
and the window size, called to scale
the filter coefficients. The window function is the Hamming window
by default.
The returned function takes two arguments, the foreign pointer to the sample data and the data size, and returns two values: the foreign array and the (generally unnecessary) scale factor to normalize the samples. If the data size is an even number, the last coefficient value is zero.
The FIR Hilbert filter is causal with the coefficients for the zero-phase impulse response shifted right by order:
(datasize - 1)/2 for datasize odd datasize/2 - 1 for datasize even
Example:
(in-package :scratch) (define-vug ssb-am (input (fir-hilbert buffer) frequency-shift) "Single side-band AM." (with ((order (ash (logior (1- (buffer-size fir-hilbert)) 1) -1))) (declare (type non-negative-fixnum order)) (- (* (delay-s input 4000 order) (sine frequency-shift 1 +half-pi+)) (* (direct-convolve input fir-hilbert) (sine frequency-shift))))) (dsp! ssb-am-test ((fir-hilbert buffer) frequency-shift) "Modulation of the sound obtained from the first input channel." (out (ssb-am (butter-lp (audio-in 0) 8000) fir-hilbert frequency-shift))) ;; Order 149 => causal FIR filter with 149*2 + 1 coefficients. (defvar *fir-hilbert* (make-buffer 299 :fill-function (gen:hilbert))) (defun set-fir-hilbert-window-function (func) (fill-buffer *fir-hilbert* (gen:hilbert :window-function func))) (rt-start) (ssb-am-test *fir-hilbert* 567) (rt-eval () (set-fir-hilbert-window-function #'rectangular-window)) (rt-eval () (set-fir-hilbert-window-function (gen:kaiser 6)))
Next: Polynomial, Previous: Filter, Up: GEN Routines [Contents][Index]
Return a function called to fill a foreign array with a composite
waveform made up of weighted sums of sinusoids. If periodic-p
is t
(default),
the result is a cycle of a periodic waveform. list
is a list where each element
is one of the following:
(with-buffers ((b0 16 :fill-function (gen:partials '(1 0 .5 0 0 0 .2 .1))) (b1 16 :fill-function (gen:partials '(1 0 .5 (7 .2) .1)))) (equal (buffer->list b0) (buffer->list b1))) ;; => T
strength
is the strength of the partial
partial-number
(not necessarily an integer value). A negative strength
value implies a phase inversion.
phase
is the initial phase of the
partial. It is a multiplier for +twopi+
.
The returned function takes two arguments, the foreign pointer to the
sample data and the data size, and returns three values: the foreign
array, the scale factor to normalize the samples and the boolean
normalize-p
to specify whether the normalization is necessary.
Return a function called to fill a foreign array with a composite waveform made up of harmonically related sine partials.
num-harm
is the number of harmonics.
lowest-harm
is the lowest harmonic and defaults to 1.
mul
is a real number and defaults to 1. It specifies the multiplier
of a power series where
(* strength-coeff (expt mul n))
is the strength of the partial (+ lowest-harm n).
The returned function takes two arguments, the foreign pointer to the sample data and the data size, and returns the foreign array.
Return a function called to fill a foreign array by using a weighted combination of Chebyshev polynomials of the first kind.
The Chebyshev functions take values between xmin
and xmax
(-1 and 1 by
default).
If offset-p
is t
(default), the center value of the wavetable is zero.
The returned function takes two arguments, the foreign pointer to the
sample data and the data size, and returns three values: the foreign
array, the scale factor to normalize the samples and the boolean
normalize-p
to specify whether the normalization is necessary.
Example:
(in-package :scratch) (define-vug shaper (in (buf buffer)) (with ((n (ash (buffer-frames buf) -1))) (declare (fixnum n)) (buffer-read buf (+ (* in n) n) :interpolation :linear))) (defvar *cheb* (make-buffer 512 :fill-function (gen:chebyshev-1 '(1 1/2 1/3 1/4 1/5)))) (dsp! cheby-test (freq amp dur) (:defaults 440 .3 4) (out (* amp (shaper (sine freq (line 0 .99 dur #'free) 0) *cheb*))))
Return the order
Chebyshev polynomial calculated at the point x.
Next: Random, Previous: Partials, Up: GEN Routines [Contents][Index]
Return a function called to fill a foreign array by evaluating a
nth-order polynomial in x between xmin
and xmax
(-1 and 1 by default)
with coefficients
(cN ... c2 c1 c0)
The returned function takes two arguments, the foreign pointer to the
sample data and the data size, and returns three values: the foreign
array, the scale factor to normalize the samples and the boolean
normalize-p
to specify whether the normalization is necessary.
Example: 2 x^2 - 3, with x in [-1, 1]
(gen:polynomial '(2 0 -3))
Next: Windows, Previous: Polynomial, Up: GEN Routines [Contents][Index]
Return the list of the available random number distributions.
The keyword names of a sublist are aliases for the same distribution.
Return a function called to fill a foreign array with random numbers from
a random number distribution
.
The returned function takes two arguments, the foreign pointer to the sample data and the data size, and returns the foreign array.
See all-random-distributions
for the list of the available random
number distributions and rand-args
for the related keyword arguments.
Return the list of arguments
(return-type [((param0 param-type) . default) ((param1 param-type) . default) ...])
for gen:rand
used with the random number distribution
.
Previous: Random, Up: GEN Routines [Contents][Index]
Define a new gen
routine named name
with lambda-list args
to
generate window functions.
The variables foreign-array-var
and size-var
are bound to the window
function arguments.
Example:
(gen:defwindow hanning (foreign-array size) (with-samples ((delta (/ +twopi+ (1- size))) (phase +sample-zero+)) (gen:symmetric-loop (i j size foreign-array) (gen:symmetric-set foreign-array i j (* 0.5 (- 1.0 (cos (the limited-sample phase))))) (incf phase delta))))
Iterate over the integer from 0 up to but not including the half of count
,
execute body
with var0
bound to each integer and var1
bound to the integers
from count
minus 1 down to the half of count
, then result
form is evaluated.
Example:
(gen:symmetric-loop (i j 8) (princ (list i j))) ;; => (0 7)(1 6)(2 5)(3 4)
Companion of symmetric-loop
, set the symmetric elements of
foreign-array
specified by index0
and index1
to value
.
Return a function called to fill a foreign array with a Bartlett window.
The returned function takes two arguments, the foreign pointer to the sample data and the data size, and returns the foreign array.
Return a function called to fill a foreign array with a Blackman window.
The returned function takes two arguments, the foreign pointer to the sample data and the data size, and returns the foreign array.
Return a function called to fill a foreign array with a Gaussian window
using beta
(4.5 by default) as the window parameter.
The returned function takes two arguments, the foreign pointer to the sample data and the data size, and returns the foreign array.
Return a function called to fill a foreign array with a Hamming window.
The returned function takes two arguments, the foreign pointer to the sample data and the data size, and returns the foreign array.
Return a function called to fill a foreign array with a Hanning window.
The returned function takes two arguments, the foreign pointer to the sample data and the data size, and returns the foreign array.
Return a function called to fill a foreign array with a Kaiser window
using beta
(12 by default) as the window parameter.
The returned function takes two arguments, the foreign pointer to the sample data and the data size, and returns the foreign array.
Return a function called to fill a foreign array with a sinc window
using beta
(1 by default) as the window parameter.
The returned function takes two arguments, the foreign pointer to the sample data and the data size, and returns the foreign array.
Return a function called to fill a foreign array with a Dolph-Chebyshev
window using attenuation
(120 dB by default) as the window parameter.
The returned function takes two arguments, the foreign pointer to the sample data and the data size, and returns the foreign array.
Return a function called to fill a foreign array with a sine window.
The returned function takes two arguments, the foreign pointer to the sample data and the data size, and returns the foreign array.
Next: Mouse Support, Previous: GEN Routines, Up: The Incudine dictionary [Contents][Index]
Send three bytes status
, data1
and data2
of a generic MIDI message
to a MIDI output stream
.
Send a MIDI SysEx message to a MIDI output stream
.
seq
is of type sequence
.
Return the vector of octets stored in the buffer of the MIDI input
stream
and the MIDI SysEx message size.
Create a new vector if octets
is nil
(default).
start
specifies an offset into octets
and marks the beginning position
of that vector.
Example:
(in-package :scratch) ;; Test with PortMidi. (defvar *midiin-test* (pm:open (pm:get-default-input-device-id))) (defun verbose-responder (status data1 data2) (cond ((= status #xf0) (format *logger-stream* "MIDI SysEx: ~A~%" (midiin-sysex-octets *midiin-test*))) ((>= status #x80) (format *logger-stream* "MIDI event: ~D ~D ~D~%" status data1 data2))) (force-output *logger-stream*)) (make-responder *midiin-test* #'verbose-responder) (recv-start *midiin-test*) ;; Send a MIDI SysEx message from a sequencer... ;; Get the octets of the last received MIDI SysEx. (midiin-sysex-octets *midiin-test*) (recv-stop *midiin-test*) (remove-all-responders *midiin-test*) (remove-receiver *midiin-test*) (pm:close *midiin-test*) ;; The same test with JACK MIDI. (setf *midiin-test* (jackmidi:open)) ;; Start JACK. (rt-start) (make-responder *midiin-test* #'verbose-responder) (recv-start *midiin-test*) ;; Connect a sequencer to the JACK MIDI input port "incudine:midi_in", ;; send a MIDI SysEx message from the sequencer... ;; Octets of the last received MIDI SysEx. (midiin-sysex-octets *midiin-test*) (recv-stop *midiin-test*) (remove-all-responders *midiin-test*) (remove-receiver *midiin-test*) (jackmidi:close *midiin-test*) (rt-stop)
Send a bulk tuning dump message to a MIDI output stream
. The new
frequencies are related to a tuning
structure. If single-note-tuning-p
is non-NIL, send 128 single note tuning change messages instead.
The optional checksum-function
requires two arguments: the foreign
buffer containing the MIDI SysEx message and the buffer size in bytes.
It is useful if the manufacturer implements a different checksum.
device-id
and program
default to 0.
Next: Voicer, Previous: MIDI, Up: The Incudine dictionary [Contents][Index]
Currently, mouse pointer support requires X window system.
Create the mouse-loop thread and return :started
if no error has occured.
Stop the mouse-loop thread and return :stopped
.
Mouse-loop thread status. Return :started
or :stopped
.
Return the coordinate x of the mouse pointer position.
This value is of type sample
in the range [0,1].
Return the coordinate y of the mouse pointer position.
This value is of type sample
in the range [0,1].
Return the mouse button state. 1 means the button has been pressed, 0 means it hasn’t.
Next: Virtual Unit Generator, Previous: Mouse Support, Up: The Incudine dictionary [Contents][Index]
Voicer type.
Create and return a new voicer
structure usable for voice management.
polyphony
is the maximum number of allocable voices.
form
is the template of the DSP related to the voicer:
(dsp-function-name &rest dsp-function-arguments)
If steal-voice
is :first
or :last
, release the first or the last
allocated voice when there aren’t available voices.
Example:
(defvar *voi* (voicer:create 20 (superbass 110 .2 1))) where 110, 0.2 and 1 are the default control parameters of the DSP instances.
Update the voicer
instance with a new template form
:
(dsp-function-name &rest dsp-function-arguments)
Deallocate the voicer
.
Return t
if all the voices of the given voicer
are available.
Return t
if all the voices of the given voicer
are allocated.
Return the maximum number of voices allocable by the given voicer
.
Setfable.
Voice to steal when all the voices of the voicer
are allocated.
Should be one of :first
, :last
or nil
. Setfable.
Allocate a voice of the given voicer
with identifier tag
.
Release a voice of the given voicer
with identifier tag
.
Return the list of the values of the control parameters related to
the given voicer
.
Return the list of control names related to the given voicer
.
Return the value of the control parameter control-name
related to
the given voicer
. Setfable.
Set the control parameters of the given voicer
.
arguments
is an even number of arguments that are alternating control
parameter names and values.
Define a mapping function named name
to call immediately after
voicer:trigger
, before the new event.
controls
is the list of the control parameters used within
function-body
.
Example:
(voicer:define-map map-test my-voicer (freq amp) (setf freq (+ 100 (random 2000)) amp (random (if (> freq 800) .1 .3))))
Remove the mapping function definition named name
related to the voicer
.
Remove all the mapping function definitions related to the voicer
.
Force the release of the voices allocated by the given voicer
.
MIDI event type for voice management.
Create and return a new midi-event
structure bound to voicer
and MIDI
input stream
.
Allocate a new voice if the received MIDI channel is channel
(0 by default)
and the MIDI key number is an integer between lokey
and hikey
(0 and 127 by
default).
The keywords freq-keyword
, amp-keyword
and gate-keyword
related to the
control parameters to set the DSP frequency, amplitude and gate, default to
:freq
, :amp
and :gate
respectively.
gate-value
is the value of the control parameter gate and defaults to 1.
If freq-function
is a function of one argument, it is used to convert
from MIDI key number to frequency value in Hz.
If amp-function
is a function of one argument, it is used to convert
from MIDI velocity to amplitude value.
If note-off-p
is t
(default), a note-on message (status byte 9) with
velocity 0 is interpreted as a note-off message.
Scale the table of the amplitudes of midi-event
by mult
.
Fill the table of the amplitudes of midi-event
with the content of
a incudine:buffer
or by calling a function with the key number as
argument.
If obj
is nil
, use the default function.
Fill the table of the frequencies of midi-event
with the content of
a incudine:tuning
, incudine:buffer
or by calling a function with the
key number as argument.
If obj
is nil
, use the default function.
Next: Built-in Virtual Unit Generators, Previous: Voicer, Up: The Incudine dictionary [Contents][Index]
Virtual Unit Generator type.
Return the VUG or vug-macro
named name
if it exists.
Virtual Unit Generator Macro type.
Return t
if object is of type VUG or vug-macro
.
Return t
if object is of type vug-macro
.
Define a new VUG and the auxiliary function named name
.
Remove the UGEN definition of name
if it exists.
Each element of the arglist
is a list
(argument-name argument-type)
or a symbol argument-name
if the control parameter is of type sample
.
The auxiliary function name
is used within the body of define-vug
,
define-vug-macro
, define-ugen
or DSP!.
If the first forms in body
are lists beginning with a keyword, they
are VUG SPEC’s. The keyword indicates the interpretation of the
other forms in the specification:
:DEFAULTS default-values Default values for VUG parameter controls. :METADATA Type Value Set the metadata Type to Value.
If the specification :defaults
is defined, all the arguments of the
auxiliary function are optional keywords.
Return the new VUG structure.
Define a new vug-macro
and the auxiliary macro named name
.
lambda-list
is an ordinary lambda list without default values.
Each element of lambda-list
is not necessarily the name of a control
parameter; use vug-input
or with-vug-inputs
to specify the VUG inputs
or vuglet
to define a local VUG definition. Example:
(define-vug-macro megasynth (freq amp &optional interpolation) (with-vug-inputs ((f freq) (a amp)) (if interpolation `(megasynth-with-interpolation ,f ,a) `(megasynth-without-interpolation ,f ,a)))) ;; Alternative. (define-vug-macro megasynth (freq amp &optional interpolation) (with-gensyms (megasynth) `(vuglet ((,megasynth (f a) ,(if interpolation `(megasynth-with-interpolation f a) `(megasynth-without-interpolation f a)))) (,megasynth ,freq ,amp))))
The auxiliary macro name
is used within the body of define-vug
,
define-vug-macro
, define-ugen
or DSP!.
If the first forms in body
are lists beginning with a keyword, they
are VUG SPEC’s. The keyword indicates the interpretation of the
other forms in the specification:
:DEFAULTS default-values Default values for VUG parameter controls. :METADATA Type Value Set the metadata Type to Value.
If the specification :defaults
is defined, all the arguments of the
auxiliary macro are optional keywords.
Return the new vug-macro
structure.
Return the lambda list and the default values for the VUG name
.
name
can also be a VUG structure.
Rename the VUG named old-name
to new-name
.
Remove the VUG or vug-macro
definition, if any, of name
.
Return the name list of the defined VUG’s and VUG-MACRO’s.
If inaccessible-p
is t
, the list also includes the symbols unexported
from the other packages.
The function named name
is forced to be the auxiliary function of
the VUG or vug-macro
with the same name. Useful if that function is
accidentally redefined.
Used within the body of define-vug-macro
to declare and return the VUG
input arg
(not all macro arguments are necessarily control parameters).
Used within the body of define-vug-macro
to create bindings to VUG inputs
(not all macro arguments are necessarily control parameters).
bindings
is a list of lists
(vug-varname value)
where value
is a VUG input.
Evaluate the body-forms
with local VUG definitions
within the body of
define-vug
, define-vug-macro
, define-ugen
or DSP!.
The local VUG names shadow the global VUG’s or functions with the same name.
Create new variable bindings within the definition of a VUG, UGEN or DSP.
The bindings are performed sequentially.
If the form associated with a variable includes one or more control
parameters, that variable is updated during the performance-function
if some of these control parameters change. See without-follow
to
remove some dependences.
Declarations may appear at the beginning of the body
. with
also accepts
the following declare
expressions:
(performance-time var*) (preserve var*)
A variable is performance-time if its value changes during the
execution of the performance-function. A variable is performance-time
by default if its value is changed by using setf
, setq
, incf
, decf
,
psetf
or psetq
.
VUG, vug-macro
and UGEN are always performance-time.
If there are redundant variables, they are removed during the compilation.
The declaration preserve
avoids that simplification and it is generally
useful for debugging purposes.
Explicitally define the dependence on some parameters
.
If with-follow
is within a initialize
construct, the code is expanded
at initialization-time and updated after the change of the ’followed’
parameters
.
If with-follow
is within the body of a vug/ugen/dsp
, the code is
evaluated only after the change of the ’followed’ parameters
.
If there is a binding between a vug-variable
and with-follow
, the
variable is updated after the change of the ’followed’ parameters
.
Example:
(dsp! with-follow-test (freq amp) (with-follow (freq) (setf amp (sample (if (< freq 500) .5 .2)))) ;; AMP is updated if FREQ changes. (out (sine freq amp 0)))
Form associated with a variable in with
binding to remove the
dependence on some parameters
.
Example:
(dsp! without-follow-test (freq amp) (with-samples ((g (without-follow (amp) (setf amp (sample (if (< freq 500) .5 .2)))))) ;; G is updated only if the control parameter FREQ changes. (out (sine freq g 0))))
Form associated with a variable in with
binding to ensure an
initialization-time variable when forms
is performance-time.
Return the variable name
defined out of the scope of a macro or
vug-macro
expansion.
Used within the definition of a VUG, UGEN or DSP to specify the
forms
to evaluate at initialization-time.
Execute forms
at performance-time. Example:
(dsp! tick-test (amp) ;; A normal function is init-time by default. (out (* amp (1- (tick (random (sample 2)))))))
Update the value of the variable var
by evaluating the form
associated in with
binding.
Example:
(dsp! update-test () (with-samples ((rnd (1- (tick (random (sample 2)))))) (out ;; A performance-time variable is updated when it occurs the ;; first time within the body of a definition. rnd ;; Update again. (update rnd))))
Used within the definition of a VUG, UGEN or DSP to iterate over
the number of output channels with current-channel
bound to each
number of channel.
Examples:
(dsp! foreach-channel-example-1 (amp) (foreach-channel ;; Single noise generator for each output channel: the ;; generator doesn't depend on CURRENT-CHANNEL. (incf (audio-out current-channel) (white-noise amp)))) ;; The same example with the VUG-MACRO COUT. (dsp! foreach-channel-example-1 (amp) (foreach-channel (cout (white-noise amp)))) (dsp! foreach-channel-example-2 (amp) (vuglet ((randi (freq) (interpolate (white-noise) freq)) (sig (freq offset mult) (:defaults 1 2000 1950) (osc *sine-table* (+ offset (* mult (randi freq))) amp))) (foreach-channel ;; These generators depend on CURRENT-CHANNEL. ;; In this case there are four generators for the ;; first four output channels. (cout (case current-channel (0 (sig 8)) (1 (sig 19)) (2 (sig 41)) (3 (sig 23)) (otherwise (sample 0)))))))
Used within the definition of a VUG, UGEN or DSP to iterate over
the number of frames with current-frame
, current-input-sample
and
current-sample
bound to each frame, input-sample and output-sample,
respectively.
Execute forms
once at current time.
Used within the definition of a VUG, UGEN or DSP, to update the
variables in body
if necessary, and inhibit the expansion of one
or more performance-time variables after a particular point of the
code (i.e. loop or condition).
Example:
(dsp! maybe-expand-test ((rain-p boolean)) (with-samples ((s (performance-time-humidity))) (maybe-expand s) (out (if rain-p s (* s 0.15)))))
Used within the body of with
to retrieve the foreign pointer to the
value of a bound variable
of type sample
, pointer
or foreign array.
Return the DSP node.
Free the DSP node.
Associated with a variable in with
binding to create a foreign
array of type signed-byte
32 and size size
.
Associated with a variable in with
binding to create a foreign
array of type unsigned-byte
32 and size size
.
Associated with a variable in with
binding to create and foreign
array of type signed-byte
64 and size size
.
Associated with a variable in with
binding to create a foreign
array of type unsigned-byte
64 and size size
.
Associated with a variable in with
binding to create a foreign
array of type single-float
and size size
.
Associated with a variable in with
binding to create a foreign
array of type double-float
and size size
.
Associated with a variable in with
binding to create a foreign
array of type foreign-pointer and size size
.
Associated with a variable in with
binding to create an array of
type (signed-byte 32) and size size
. The array is foreign on 32-bit
platforms because the size of a fixnum is less than 32 bits.
Access the element of the array created by maybe-make-i32-array. Setfable.
Associated with a variable in with
binding to create an array of
type (unsigned-byte 32) and size size
. The array is foreign on 32-bit
platforms because the size of a fixnum is less than 32 bits.
Access the element of the array created by maybe-make-u32-array. Setfable.
Return the type of a foreign array created by one of the
make-*-array utilities associated with a variable in with
binding.
Return the number of elements in a foreign array created by one of
the make-*-array utilities associated with a variable in with
binding.
Zero the variables sample-vars
of type sample
.
Next: Unit Generator, Previous: Virtual Unit Generator, Up: The Incudine dictionary [Contents][Index]
Next: Generator, Up: Built-in Virtual Unit Generators [Contents][Index]
Mix the values
into the output busses.
Mix the nth element of values
into the nth output bus if n is equal
to current-channel
.
Example:
(dsp! cout-test (freq amp pos) (foreach-channel (cout (pan2 (sine freq amp) pos))))
Mix channels
values of a foreign array of samples ptr
into the
output busses.
offset
is the array index of the first sample to write.
The samples are scaled by scale
(1 by default).
If scale-type
is non-NIL, it is the (unquoted) type of scale
.
Mix the nth element of values
, scaled by the node-gain, into the
nth output bus if n is equal to current-channel
.
Next: Noise, Previous: Output, Up: Built-in Virtual Unit Generators [Contents][Index]
Band limited impulse generator with frequency freq
, amplitude amp
and phase
. The output is a set of num-harm
harmonically related sine
partials.
phase
defaults to zero.
If table-lookup-p
is t
, use the buffer
with a single cycle sinusoid
instead of the function sin
. buffer
defaults to *sine-table*
.
The buffer size is assumed to be a power of two.
harm-change-lag
is the lag-time for the crossfade when the number of
the harmonics changes.
interpolation
is one of :linear
(default), :cubic
or nil
.
Band limited impulse generator with frequency freq
, amplitude amp
and phase
. The output is a set of num-harm
harmonically related sine
partials.
phase
defaults to zero.
mul
is a real number and defaults to 1. It specifies the multiplier
of a power series where
(* strength-coeff (expt mul n))
is the strength of the partial (+ lowest-harm n).
If table-lookup-p
is t
, use the buffer
with a single cycle sinusoid
instead of the function cos
. buffer
defaults to *cosine-table*
.
The buffer size is assumed to be a power of two.
harm-change-lag
is the lag-time for the crossfade when the number of
the harmonics changes.
interpolation
is one of :linear
(default), :cubic
or nil
.
Impulse oscillator with frequency freq
, amplitude amp
and phase
.
If freq
is not set, play back a single impulse.
Frquency, amplitude and phase default to 0, 1 and 0 respectively.
Wavetable lookup oscillator with frequency freq
, amplitude amp
and phase
.
freq
, amp
and phase
default to 440, 1 and 0 respectively.
interpolation
is one of :linear
, :cubic
or nil
(default).
The buffer size is assumed to be a power of two.
Sinusoidal oscillator based on 2d
vector rotation (sine output by
default) with frequency freq
and amplitude amp
.
Sinusoidal oscillator based on 2d
vector rotation (cosine output)
with frequency freq
and amplitude amp
.
Sinusoidal oscillator based on 2d
vector rotation (sine and cosine outputs)
with frequency freq
.
Sinusoidal oscillator based on 2d
vector rotation (sine output)
with frequency freq
and amplitude amp
.
Produce a normalized moving phase value with frequency freq
and
initial value init
(0 by default).
Produce a normalized moving phase value with a loop between
loopstart
and loopend
, and initial value start-pos
.
rate
is the multiply factor of the rate.
Pulse wave oscillator with frequency freq
, amplitude amp
and width
between 0 and 1.
High precision sine wave oscillator with frequency freq
, amplitude
amp
and phase
.
Next: Amplitude, Previous: Generator, Up: Built-in Virtual Unit Generators [Contents][Index]
White noise generator with output optionally scaled by amp
.
Pink Noise generator using the Gardner method with the James McCartney’s optimization.
The output is optionally scaled by amp
.
number-of-bands
defaults to 20.
Fractal noise generator implemented as a white noise filtered by a
cascade of filter-order
(15 by default) filters.
The output is scaled by amp
.
beta
is the spectral parameter related to the fractal dimension (defines
the target 1/f^beta spectrum). Examples:
beta | noise |
---|---|
0 | white |
1 | pink |
2 | brown |
poles-density
defaults to 6.
The frequency lowest-freq
of the first pole defaults to 50.
Noise generator based on a chaotic function with scale factor amp
(1 by default).
The formula is
y[n] = | param * y[n-1] - y[n-2] - 0.05 |
init-value
is the initial value of y and defaults to 0.3.
Noise generator with random number distribution
.
distribution | param 1 | param 2 | param 3 | return type |
---|---|---|---|---|
:linear | :a 0.0 | :b 1.0 | double | |
:high | :a 0.0 | :b 1.0 | double | |
:triangular | :a 0.0 | :b 1.0 | double | |
:gauss | :sigma 1.0 | double | ||
:gauss-tail | :a 1.0 | :sigma 1.0 | double | |
:exp | :mu 1.0 | double | ||
:laplace | :a 1.0 | double | ||
:exppow | :a 1.0 | :b 1.5 | double | |
:cauchy | :a 1.0 | double | ||
:rayleigh | :sigma 1.0 | double | ||
:rayleigh-tail | :a 1.0 | :sigma 1.0 | double | |
:landau | double | |||
:levy | :c 1.0 | :alpha 1.0 | double | |
:levy-skew | :c 1.0 | :alpha 1.0 | :beta 1.0 | double |
:gamma | :a 1.0 | :b 1.0 | double | |
:uni | :a 0.0 | :b 1.0 | double | |
:lognormal | :zeta 1.0 | :sigma 1.0 | double | |
:chisq | :nu 1.0 | double | ||
:f | :nu1 1.0 | :nu2 1.0 | double | |
:t | :nu 1.0 | double | ||
:beta | :a 1.0 | :b 1.0 | double | |
:pareto | :a 1.0 | :b 1.0 | double | |
:logistic | :a 1.0 | double | ||
:weibull | :a 1.0 | :b 1.0 | double | |
:gumbel1 | :a 1.0 | :b 1.0 | double | |
:gumbel2 | :a 1.0 | :b 1.0 | double | |
:poisson | :mu 1.0 | uint | ||
:bernoulli | :p 0.5 | uint | ||
:binomial | :n 1 | uint | ||
:negative-binomial | :p 0.5 | :n 1.0 | uint | |
:pascal | :p 0.5 | :n 1 | uint | |
:geom | :p 0.5 | uint | ||
:hypergeom | :n1 1 | :n2 1 | :tt 1 | uint |
:log | :p 0.5 | uint |
See also gen:all-random-distributions
and gen:rand-args
.
Next: Envelope, Previous: Noise, Up: Built-in Virtual Unit Generators [Contents][Index]
Envelope follower.
rms
value of the input in
.
The response curve’s half-power point hp
of the low-pass filter
defaults to 10 Hz.
Scale the input in
to match a rms
value.
The response curve’s half-power point hp
of the low-pass filter
defaults to 10 Hz.
Scale the input in
according to a rms
value of the comparator signal comp
.
The response curve’s half-power point hp
of the low-pass filter
defaults to 10 Hz.
Example:
(dsp! balance-test (scl dur) (with-samples ((in (white-noise scl))) (out (balance (bpf in (expon 100 4000 dur #'free) 100) in))))
Next: Panpot, Previous: Amplitude, Up: Built-in Virtual Unit Generators [Contents][Index]
Exponential decay.
Exponential decay with the attack obtained by subtracting two DECAY’s.
Linear ramp from start
to end
in duration
seconds.
If the control parameter duration
is changed, start a new ramp from
the new start
, or current level, to the new end
. Example:
(dsp! ramp-test (start end duration) (out (* (line start end duration) (white-noise)))) (rt-start) (ramp-test 0 1 3) (set-controls 1 :end 0 :duration 2) (set-controls 1 :end .5 :duration .3) (set-controls 1 :start 0 :end 1 :duration .5)
start
, end
and duration
default to 0, 1 and 1 respectively.
The one-argument function done-action
, #'identity
by default, is
called at the end of the ramp. The function argument is the DSP node.
Exponential curve from start
to end
in duration
seconds.
If start
or end
is 0, it is reset to 0.00001. The sign of end
has to be
the sign of start
.
If the control parameter duration
is changed, start a new curve from the
new start
, or current level, to the new end
.
start
, end
and duration
default to 0.00001, 1 and 1 respectively.
The one-argument function done-action
, #'identity
by default, is
called at the end of the curve. The function argument is the DSP node.
Play back the curves of the envelope env
.
gate
is one of:
0 start the release phase -1 immediate cutoff less than -1 release stage with a custom duration -1 minus GATE
The envelope is re-triggered if the difference between the gate of the current audio cycle and the gate of the previous audio cycle is a positive value.
gate
and time-scale
default to 1.
The one-argument function done-action
, #'identity
by default, is
called at the end of the envelope. The function argument is the DSP node.
location
, 0 by default, is the current position in samples (an integer)
of the envelope.
Next: Delay, Previous: Envelope, Up: Built-in Virtual Unit Generators [Contents][Index]
Fast stereo equal power panpot with position pos
between 0 (left)
and 1 (right).
Stereo equal power panpot with position pos
between 0 (left)
and 1 (right).
Mix the input
into the first two output busses.
Next: Filter, Previous: Panpot, Up: Built-in Virtual Unit Generators [Contents][Index]
Buffer based delay line with delay time in samples.
Use all the buffer
memory if the buffer
size is a power of two.
Buffer based delay line with delay-time
in seconds.
Use all the buffer
memory if the buffer
size is a power of two.
Buffer based delay line with interpolation
and delay-time
in seconds.
If write-head-var
is non-NIL, it is the name of the variable used as
write head.
Use all the buffer
memory if the buffer
size is a power of two.
One sample delay.
Delay line with delay time in samples.
Delay line with delay-time
in seconds.
Delay line with interpolation
and delay-time
in seconds.
interpolation
is one of :linear
(default), :cubic
or nil
.
Tap a buffer based delay line with interpolation
at delay-time
seconds.
write-head-var
is the name of the variable used as write head.
Use all the buffer
memory if the buffer
size is a power of two.
Feedback coefficient for a feed back comb filter with delay-time
and decay-time
.
Allpass filter without interpolation and delay-time
in samples.
Allpass filter without interpolation and delay-time
in seconds.
Allpass filter with delay-time
in seconds.
Feed back comb filter with delay-time
in seconds.
Feed forward comb filter with delay-time
in seconds.
Next: Conversion, Previous: Delay, Up: Built-in Virtual Unit Generators [Contents][Index]
Anaphoric VUG macro
for recursive composition.
Second-order allpass filter.
Biquad filter.
Second-order bandpass filter.
Second-order Butterworth bandpass filter.
Second-order Butterworth bandreject filter.
Second-order Butterworth highpass filter.
Second-order Butterworth lowpass filter.
A first-order recursive highpass filter where hp
is the response curve’s
half-power point.
A first-order recursive lowpass filter where hp
is the response curve’s
half-power point.
DC blocking filter.
First order difference.
Direct convolution of an input with a finite impulse response stored in a buffer.
FOF-like filter.
Second-order high shelf filter.
Second-order highpass filter.
Integrate the input in
.
Scaled one pole filter with the coefficient calculated from
a 60 dB lag time
.
Scaled one pole filter with the coefficient calculated from
a 60 dB lag attack-time
and decay-time
.
Second-order low shelf filter.
Second-order lowpass filter.
Digital emulation of a 3 pole lowpass filter.
Moving Average Filter.
Median filter.
A discrete-time version of the Moog vcf
.
Non linear digital implementation of the Moog ladder filter.
Second order normalized digital waveguide resonator.
Second-order notch filter.
Partitioned convolution. The pvbuffer
contains the partitioned FFT
of a multichannel finite impulse response.
Second-order peaking equalizer.
One pole filter.
Scaled one pole filter.
Two pole resonant filter.
Two pole resonant filter with zeroes located at +/- sqrt(radius).
Two pole resonant filter with zeroes located at z = 1 and z = -1.
Two pole resonant filter with zeroes located at +/- sqrt(radius).
The bandwidth is specified in a 60dB ring decay-time
and a constant
scale factor.
Two pole resonant filter with zeroes located at z = 1 and z = -1.
The bandwidth is specified in a 60dB ring decay-time
and a constant
scale factor.
State Variable Filter.
Two pole filter.
Two zero filter.
One zero filter.
Scaled one zero filter.
Next: Buffer, Previous: Filter, Up: Built-in Virtual Unit Generators [Contents][Index]
Return a value between new-min
and new-max
that is the linear
mapping of the input
sample in the range of old-min
to old-max
.
Return a value between new-min
and new-max
that is the exponential
mapping of the input
sample in the range of old-min
to old-max
.
old-min
is not equal to old-max
.
new-min
and new-max
are non-zero values. The sign of new-max
has to be
the sign of new-min
.
Next: Frame, Previous: Conversion, Up: Built-in Virtual Unit Generators [Contents][Index]
Return the value of the current-channel
of the buffer
frame
.
If wrap-p
is t
, wrap around if necessary.
interpolation
is one of :linear
, :cubic
or nil
(default).
Write input
to the current-channel
of the buffer
frame
.
Return the related buffer index.
Play back the current-channel
of the buffer data starting from the
frame start-pos
(0 by default).
rate
is the multiply factor of the sampling rate of buffer
. For example,
1 (default) is the original, 1.5 is a fifth up and 0.5 is an octave down.
If loop-p
is t
, play it back in a loop.
The one-argument function done-action
, #'free
by default, is called
when loop-p
is nil
and the buffer is finished playing. The function
argument is the DSP node.
Example:
(dsp! buffer-play-test ((buf buffer)) (foreach-channel (cout (buffer-play buf))))
Return the buffer
frame
.
If wrap-p
is t
, wrap around if necessary.
interpolation
is one of :linear
, :cubic
or nil
(default).
Next: Distortion, Previous: Buffer, Up: Built-in Virtual Unit Generators [Contents][Index]
Associated with a variable in with
binding to create a foreign
array of type sample
and size size
.
Access the foreign array element of type sample
specified by index
.
Setfable.
Used within the definition of a VUG, UGEN or DSP to bind the variables
vars
to the corresponding values in the foreign array of samples frame
.
Used within the definition of a VUG, UGEN or DSP to return values
as a foreign array of samples. The second returned value is the number
of samples.
Next: Analysis, Previous: Frame, Up: Built-in Virtual Unit Generators [Contents][Index]
Clip the input
sample to a value between low
and high
.
Destructively clip the input
sample to a value between low
and high
.
Wrap-around the input
sample that exceeds the low
and high
thresholds.
Destructively wrap-around the input
sample that exceeds the low
and
high
thresholds.
Reflect the input
sample that exceeds the low
and high
thresholds.
Destructively reflect the input
sample that exceeds the low
and
high
thresholds.
Next: Chaos, Previous: Distortion, Up: Built-in Virtual Unit Generators [Contents][Index]
Compute the spectral centroid of the abuffer
data using moments.
Overwrite the abuffer
data with the result.
Example:
(dsp! centroid-test () (with ((fft (make-fft 1024 :window-size 512 :window-function (gen:hanning))) (abuf (make-abuffer fft)) (result +sample-zero+)) (declare (type sample result)) (setf (fft-input fft) ;; Exponential growth from 1 to 30 harmonics in 20 seconds (buzz 440 .5 (sample->fixnum (expon 1 30 20 #'free)))) (with-control-period ((sample->fixnum *sample-rate*)) (setf result (* (centroid abuf) *sample-rate* 0.5)) (nrt-msg info "~D" (sample->fixnum result))) (out (tick (fft-input fft)))))
Compute the spectral flatness of the abuffer
data.
Overwrite the abuffer
data with the result.
Example:
(define-vug crossfade (in1 in2 pos) (with-samples ((alpha (* +half-pi+ pos))) (+ (* (cos alpha) in1) (* (sin alpha) in2)))) (dsp! flatness-test () (with ((fft (make-fft 1024 :window-function (gen:hanning))) (abuf (make-abuffer fft)) (result +sample-zero+)) (declare (type sample result)) (setf (fft-input fft) (crossfade (sine 1000 .5 0) (white-noise .1) (line 0 1 8 #'free))) (with-control-period (1024) (setf result (flatness abuf)) (nrt-msg info "~D" (sample->fixnum (* 100 result)))) (out (tick (fft-input fft)))))
Compute the spectral flux of the abuffer
data.
If half-wave-rectifier-p
is t
, use the half-wave rectifier function.
If l1-norm-p
is t
, return the L1-norm of the spectral flux.
Overwrite the abuffer
data with the result.
Examples:
(dsp! flux-test ((buf buffer)) (with ((fft (make-fft 2048 :window-function (gen:hamming))) (abuf (make-abuffer fft)) (hop-size (sample->fixnum (* *sample-rate* 0.1))) (result +sample-zero+)) (declare (type sample result)) (setf (fft-input fft) (buffer-play buf 1 0 nil #'free)) (with-control-period (hop-size) (setf result (flux abuf)) (nrt-msg info "~D" (sample->fixnum result))) (out (tick (fft-input fft))))) (dsp! flux-rectified-test ((buf buffer) flux-threshold) (with ((fft (make-fft 2048 :window-function (gen:hamming))) (abuf (make-abuffer fft)) (hop-size (sample->fixnum (* *sample-rate* 0.1))) ;; The result of FLUX is unnormalized (threshold (* flux-threshold (fft-size fft))) (result +sample-zero+)) (declare (type sample threshold result)) (setf (fft-input fft) (buffer-play buf 1 0 t #'identity)) (with-control-period (hop-size) ;; Spectral flux with half-wave rectifier function ;; and L1-norm (Dixon DAFx-06) (setf result (sample (if (> (flux abuf t t) threshold) 100 0)))) (out (tick (fft-input fft)) (prog1 (ringz result 3000 .1) (unless (zerop result) (setf result +sample-zero+))))))
Compute the spectral rolloff of the abuffer
data.
Overwrite the abuffer
data with the result.
Example:
(dsp! rolloff-test (percent) (with ((fft (make-fft 1024 :window-function (gen:hanning))) (abuf (make-abuffer fft)) (srdiv2 (* *sample-rate* 0.5)) (perc (sample->fixnum (* percent 100))) (result +sample-zero+)) (declare (type sample srdiv2 result)) (setf (fft-input fft) (audio-in 0)) (with-control-period (1024) (setf result (* (rolloff abuf percent) srdiv2)) (nrt-msg info "~D% rolloff: ~D" perc (sample->fixnum result)))))
Compute the spectral rms
of the abuffer
data.
Overwrite the abuffer
data with the result.
Example:
(dsp! spectral-rms-test () (with ((fft (make-fft 1024 :window-function (gen:hanning))) (abuf (make-abuffer fft)) (mult (/ (sample 1.0) (fft-size fft))) (rms +sample-zero+)) (declare (type sample mult rms)) (setf (fft-input fft) (audio-in 0)) (with-control-period (1024) (setf rms (* (spectral-rms abuf) mult)) (reduce-warnings (nrt-msg info "~F" rms)))))
Next: MIDI, Previous: Analysis, Up: Built-in Virtual Unit Generators [Contents][Index]
Cusp map chaotic generator with frequency freq
.
The formula is
x = a - b * sqrt(|x|)
interpolation
is one of :linear
, :cos
, :cubic
or nil
(default).
Feedback sine with chaotic phase indexing and frequency freq
.
The formula is
x = sin(index_mult * y + feedback * x) y = (phase_mult * y + phase_add) % 2pi
interpolation
is one of :linear
, :cos
, :cubic
or nil
(default).
Gingerbreadman map chaotic generator with frequency freq
.
The formula is
x1 = x0 x0 = 1 - y + |x0| y = x1
interpolation
is one of :linear
, :cos
, :cubic
or nil
(default).
Dynamic stochastic approach to waveform synthesis conceived by Iannis Xenakis.
The waveform is generated by used-points
minus 1 segments and is
repeated in the time. The vertexes (control points) are moved
according to a stochastic action and they are limited within the
boundaries of a mirror formed by an amplitude barrier and a time
barrier.
amp-distr
is the probability distribution for the next perturbation of
the amplitude of a control point. The valid distributions are:
0 - LINEAR 1 - CAUCHY 2 - LOGIST 3 - HYPERBCOS 4 - ARCSINE 5 - EXPON 6 - SINUS (external signal)
amp-distr-param
is the parameter for the amp-distr
distribution.
Should be in the range of 0.0001 to 1 or a form that represents a
random number generator if amp-distr
is 6.
dur-distr
is the distribution for the perturbation of the current
inter control point duration. See amp-distr
for the valid distributions.
dur-distr-param
is the parameter for the dur-distr
distribution.
Should be in the range of 0.0001 to 1 or a form that represents a
random number generator if dur-distr
is 6.
freq-min
and freq-max
are the minimum and maximum allowed frequency of
oscillation.
amp-scale
is the multiplier for the distribution’s delta value for amplitude
(1.0 is full range).
dur-scale
is the multiplier for the distribution’s delta value for duration.
max-points
minus 1 is the maximum number of segments.
interpolation
is one of :linear
(default), :cos
, :cubic
or nil
.
Hénon map chaotic generator with frequency freq
.
The formula is
x = 1 - a*x0^2 + b*x1
interpolation
is one of :linear
, :cos
, :cubic
or nil
(default).
Latoocarfian chaotic generator with frequency freq
.
The formula is
x1 = x0 x0 = sin(b*y) + c*sin(b*x0) y = sin(a*y) + d*sin(a*x1)
interpolation
is one of :linear
, :cos
, :cubic
or nil
(default).
Linear congruential chaotic generator with frequency freq
.
The formula is
x = (mult * x + increment) % modulus
interpolation
is one of :linear
, :cos
, :cubic
or nil
(default).
Lorenz chaotic generator with frequency freq
.
The formula is
x' = s*(y - x) y' = x*(r - z) - y z' = x*y - b*z
interpolation
is one of :linear
, :cos
, :cubic
or nil
(default).
Return a frame with the three coordinates.
General quadratic map chaotic generator with frequency freq
.
The formula is
x = a*x^2 + b*x + c
interpolation
is one of :linear
, :cos
, :cubic
or nil
(default).
Standard map chaotic generator with frequency freq
.
The formula is
x = (x + y) % 2pi y = (y + perturbation * sin(x)) % 2pi
interpolation
is one of :linear
, :cos
, :cubic
or nil
(default).
Next: Misc, Previous: Chaos, Up: Built-in Virtual Unit Generators [Contents][Index]
buffer
structure of size 128 for linear mapping from [0, 127]
to [0.0, 1.0].
Return t
if status
is the status byte of a MIDI note. Otherwise,
return nil
.
Return the key number of the last received MIDI note-off message
for the channel
.
Return t
if status
is the status byte of a MIDI note-off. Otherwise, return nil
.
Return the key number of the last received MIDI note-on message for
the channel
.
Return t
if status
is the status byte of a MIDI note-on. Otherwise, return nil
.
Return the lowest received MIDI key number for channel
.
Return the highest received MIDI key number for channel
.
Return the velocity of the last received MIDI note for channel
and key number keynum
.
Return the amplitude that is the linear mapping of the last
received MIDI note for channel
and key number keynum
.
ampbuf
is the buffer
structure of size 128 used for linear mapping
from key number to amplitude.
Return the frequency of the key number keynum
in a tuning
.
Return the value of the last received MIDI cc number
for channel
.
Return t
if status
is the status byte of a MIDI cc. Otherwise, return nil
.
Return the MIDI program for channel
.
Return t
if status
is the status byte of a MIDI program. Otherwise, return nil
.
Return the last received MIDI pitch bend for channel
.
Return t
if status
is the status byte of a MIDI pitch-bend. Otherwise, return nil
.
Return the last received MIDI poly-aftertouch for channel
and key
number keynum
.
Return t
if status
is the status byte of a MIDI poly-aftertouch. Otherwise, return nil
.
Return the MIDI global-aftertouch for channel
.
Return t
if status
is the status byte of a MIDI global-aftertouch. Otherwise, return nil
.
Return a value between min
and max
that is the linear mapping of
the last received MIDI cc number
for channel
.
Return a value between min
and max
that is the linear mapping of
the last received MIDI pitch bend for channel
.
Return a value between min
and max
that is the linear mapping of
the last received MIDI poly-aftertouch for channel
and key number keynum
.
Return a value between min
and max
that is the linear mapping of
the last received MIDI global-aftertouch for channel
and key number
keynum
.
Return a value between min
and max
that is the exponential mapping
of the last received MIDI cc number
for channel
.
min
and max
are non-zero values. The sign of max
has to be the sign of min
.
Return a value between min
and max
that is the exponential mapping
of the last received MIDI pitch bend for channel
.
min
and max
are non-zero values. The sign of max
has to be the sign of min
.
Return a value between min
and max
that is the exponential mapping of
the last received MIDI poly-aftertouch for channel
and key number keynum
.
min
and max
are non-zero values. The sign of max
has to be the sign of min
.
Return a value between min
and max
that is the exponential mapping
of the last received MIDI global-aftertouch for channel
and key number
keynum
.
min
and max
are non-zero values. The sign of max
has to be the sign of min
.
Return three values: the played MIDI note-number
starting from zero,
the related MIDI velocity and t
if the note is played. This is useful
to create MIDI arpeggiators.
channel
is the MIDI channel from 0 to 15.
Examples:
;; F7 chord [65 69 72 75] played on the first channel. (played-midi-note 1 0) ; => 69, 96, T (played-midi-note 3 0) ; => 75, 89, T (played-midi-note 6 0) ; => 0, 0, NIL
Zero the MIDI note table for channel
or all the tables if channel
is nil
.
Next: Mouse, Previous: MIDI, Up: Built-in Virtual Unit Generators [Contents][Index]
Count from start
to end
(excluded) by step
, optionally in loop if
loop-p
is t
.
The one-argument function done-action
is called at the end if loop-p
is nil
.
The function argument is the DSP node.
Downsampling of input
with control-period
.
Interpolation of the values generated by a performance-time generator-form
.
The values of the generator are calculated with a modulable frequency freq
.
interpolation
is one of :linear
(default), :cos
, :cubic
or nil
(sample-and-hold).
If interpolation
is :cubic
and initial-value-p
is t
, three adjacent
points are initialized with the same value.
Example:
(define-vug randi (amp freq) (* amp (interpolate (white-noise) freq)))
Sample and hold the input
whenever gate
decreases from one sample
to the next, for example when a phasor wraps around. This mechanism is
similar to the Pd-version.
initial-value
and initial-threshold
default to 0 and 1 respectively.
input
is updated every gate
samples, on demand or never.
If gate
is positive, the output is input
calculated every gate
samples.
If gate
is zero, the output is the old value of input
.
If gate
is negative, the output is the current value of input
and gate
becomes zero.
start-offset
is the initial offset for the internal counter.
The body
forms are updated every n
samples, on demand or never.
If n
is positive, body
is updated every n
samples.
If n
is zero, body
is not updated.
If n
is negative, body
is updated and n
becomes zero.
start-offset
(0 by default) is the initial offset for the internal counter.
Next: Foreign Plugin, Previous: Misc, Up: Built-in Virtual Unit Generators [Contents][Index]
Return the coordinate x of the mouse pointer position.
This value is of type sample
in the range [0,1].
Return the coordinate y of the mouse pointer position.
This value is of type sample
in the range [0,1].
Return the mouse button state. 1 means the button has been pressed, 0 means it hasn’t.
Return the coordinate x of the mouse pointer position, linearly
rescaled to be between min
and max
.
Return the coordinate y of the mouse pointer position, linearly
rescaled to be between min
and max
.
Return the coordinate x of the mouse pointer position,
exponentially rescaled to be between min
and max
.
min
and max
are non-zero values. The sign of max
has to be the sign of min
.
Return the coordinate y of the mouse pointer position,
exponentially rescaled to be between min
and max
.
min
and max
are non-zero values. The sign of max
has to be the sign of min
.
Previous: Mouse, Up: Built-in Virtual Unit Generators [Contents][Index]
Foreign plugin type.
Foreign plugin instance type.
Return the foreign plugin instance pointer.
Return the foreign pointer to the data of the plugin port index
.
Foreign plugin port type.
Documentation string for VUG.
Next: DSP, Previous: Built-in Virtual Unit Generators, Up: The Incudine dictionary [Contents][Index]
Unit Generator type.
Return the UGEN named name
if it exists.
Define a new VUG, the UGEN obtained by compiling that VUG and the
auxiliary function named name
.
If the UGEN is declared inline within the definition of a VUG, UGEN or DSP, it is replaced with the parent VUG.
The UGEN output is of type return-type
.
Each element of the arglist
is a list
(argument-name argument-type)
or a symbol argument-name
if the control parameter is of type sample
.
If the auxiliary function name
is used within the body of define-vug
,
define-vug-macro
, define-ugen
or DSP!, the behaviour is analogous to
the auxiliary function of a VUG. Otherwise, it returns the function
of no arguments to allocate new UGEN instances. In the last case, it
accepts an UGEN node as optional argument.
If the first forms in body
are lists beginning with a keyword, they
are UGEN SPEC’s. The keyword indicates the interpretation of the
other forms in the specification:
:DEFAULTS default-values Default values for UGEN parameter controls. :INSTANCE-TYPE Name Type of the UGEN instance (default: UGEN-INSTANCE). :CONSTRUCTOR Name Contructor function used to create a UGEN instance (default: MAKE-[instance-type]). :READERS {(Control-Name {Key Value}*)}* Specifications of the control getters. The valid keywords are: :NAME Getter name (default: [ugen-name]-[control-name]) :ARG-NAME Argument name for the UGEN instance (default: UGEN-INSTANCE) :INLINE-P T to declare the function inline (default: T if METHOD-P NIL) :METHOD-P T to define the getter with DEFMETHOD (default: nil) :WRITERS {(Control-Name {Key Value}*)}* Specifications of the control setters. The valid keywords are: :NAME Setter name (default: SET-[ugen-name]-[control-name]) :ARG-NAME Argument name for the UGEN instance (default: UGEN-INSTANCE) :VALUE-NAME Argument name for the new value (default: VALUE) :VALUE-TYPE New value type :INLINE-P T to declare the function inline (default: T if METHOD-P NIL) :METHOD-P T to define the setter with DEFMETHOD (default: nil) :ACCESSORS {(Control-Name {Key Value}*)}* Specifications of the control getters and setters. The valid keywords are: :NAME :ARG-NAME :VALUE-NAME :VALUE-TYPE :INLINE-P :METHOD-P If :METHOD-P is NIL and :NAME is specified, the function NAME is SETF-able: (defun name ...) (defun set-name ...) (defsetf name set-name) If :METHOD-P is T, define the methods: (defmethod name ...) (defmethod (setf name) ...) :METADATA Type Value Set the metadata Type to Value. :OPTIMIZE {Quality | (Quality Value)}* Optimization qualities for the declaration OPTIMIZE.
If the specification :defaults
is defined, all the arguments of the
auxiliary function are optional keywords.
Return the new UGEN structure.
Return a function to show the code generated by define-ugen
.
See define-ugen
for the macro function arguments.
The returned function requires the UGEN arguments plus one optional argument to specify the output stream.
Return the lambda list, the default values and the return type for
the UGEN name
.
name
can also be a UGEN structure.
Whether the dynamic variables in *specials-to-eval*
are evaluated
during the compilation of a UGEN or DSP. The default is nil
.
List of the dynamic variables to eval during the compilation of a
UGEN or DSP if *eval-some-specials-p*
is t
.
Define a new UGEN and the auxiliary function named name
by
compiling an existing VUG.
name-or-vug
is a VUG structure or a VUG name.
The UGEN output is of type return-type
.
If force-p
is t
, force the compilation.
If ugen-instance-constructor
is non-NIL, it is the constructor used to
create the UGEN instances.
If optimize
is non-NIL, it is the quoted list of optimization
qualities for the declaration optimize
.
Whether obj
is a compiled VUG or the name of a compiled VUG.
Rename the UGEN named old-name
to new-name
.
Remove the UGEN definition, if any, of name
.
Return the name list of the defined UGEN’s.
If inaccessible-p
is t
, the list also includes the symbols unexported
from the other packages.
The function named name
is forced to be the auxiliary function of
the UGEN with the same name. Useful if that function is accidentally
redefined.
UGen instance type.
Bind var
to a newly allocated UGEN instance with arguments args
and
dynamic extent during body
.
Create bindings to newly allocated UGEN instances with dynamic extent
during body
.
bindings
is a list of lists
(var ugen-name &rest args)
where var
is the variable bound to a UGEN instance named ugen-name
with arguments args
.
Deallocate the ugen-instance
.
Return t
if the ugen-instance
is deallocated.
Return the ugen-instance
performance function.
If the return type of ugen-instance
is sample
or a foreign pointer,
the performance function returns no values. In this case, the function
ugen-return-pointer
has to be called to get the foreign pointer to the
returned value.
Return the function to reinitialize ugen-instance
.
If the return type of ugen-instance
is sample
or a foreign pointer,
return the foreign pointer to the returned value. Otherwise, return nil
.
If the ugen-instance
control control-name-or-index
is represented
by a foreign object (i.e. a control of sample
type), the first returned
value is a foreign pointer to the control value, otherwise it is a
function of no arguments called to get the control value.
The second returned value is the function of no arguments called to update the dependencies if it exists.
Define a UGEN control getter for the control control-name
.
The getter-name
defaults to [ugen-name]-[control-name].
The argument name arg-name
for the UGEN instance defaults to ugen-instance
.
ugen-instance-type
defaults to ugen-instance
.
If inline-p
is t
(default if method-p
is nil
), the getter is declared inline.
If method-p
is t
, the getter is defined as a method on a generic function.
Define a UGEN control setter for the control control-name
.
The setter-name
defaults to set-[ugen-name]-[control-name].
If value-type
is non-NIL, it is the new value type.
value-name
is the argument name for the new value and defaults to value
.
The argument name arg-name
for the UGEN instance defaults to ugen-instance
.
ugen-instance-type
defaults to ugen-instance
.
If inline-p
is t
(default if method-p
is nil
), the setter is declared inline.
If method-p
is t
, the setter is defined as a method on a generic function.
Next: The rule of the first expansion, Previous: Unit Generator, Up: The Incudine dictionary [Contents][Index]
Whether the running DSP instances are updated when a DSP is redefined.
The default is t
.
Define a new DSP and the auxiliary function named name
.
Each element of the arglist
is a list
(argument-name argument-type)
or a symbol argument-name
if the control parameter is of type sample
.
If *update-dsp-instances-p*
is t
, update the running DSP instances
for name
if the arguments remain the same.
If the first forms in body
are lists beginning with a keyword, they
are DSP SPEC’s. The keyword indicates the interpretation of the
other forms in the specification:
:DEFAULTS default-values Default values for DSP parameter controls. :METADATA Type Value Set the metadata Type to Value. :OPTIMIZE {Quality | (Quality Value)}* Optimization qualities for the declaration OPTIMIZE.
The auxiliary function name
is called to allocate and run a new DSP
instance. It requires the DSP arguments and accepts the following
keywords arguments:
(&key ID HEAD TAIL BEFORE AFTER REPLACE ACTION STOP-HOOK FREE-HOOK FADE-TIME FADE-CURVE)
However, if the specification :defaults
is defined, all the arguments
are optional keywords.
id
is an integer identifier or nil
to use the next available id.
The keywords head
, tail
, before
, after
and replace
specify the add-action
to add the new node. The value is the target node or node-id. By default
the new node is added at the head of the root node.
If action
is non-NIL, it is a one-argument function called on the node
object after the initialization.
free-hook
is a list of function designators which are called in an
unspecified order at the time the node object is freed. The function
argument is the node to free. stop-hook
is a similar list but it is
called when the node object is stopped.
If the node output is enabled (i.e. by using the vug-macro
node-out
instead of out
), a non-NIL fade-time
and fade-curve
are the duration
in seconds and the curve of the envelope
structure to fade in/out the
node output.
Return the auxiliary function name
.
Return a function to show the code generated by DSP!.
See DSP! for the macro function arguments.
The returned function requires the DSP arguments plus one optional argument to specify the output stream.
Return the lambda list and the default values for the DSP name
.
If the metadata type
is nil
(default), return the association list of the
metadata for the object obj
. If type
is non-NIL, return its corresponding
metadata value.
The metadata type
is a symbol or a string.
Example:
(in-package :scratch) (dsp! panner ((buffer buffer) pan) (:defaults (incudine-missing-arg "BUFFER") 0.5) (:metadata :inputs 1) (:metadata :outputs 2) (with-samples ((alpha (* +half-pi+ pan)) (left (cos alpha)) (right (sin alpha))) (loop for i below (buffer-size buffer) by 2 do (setf (buffer-value buffer (1+ i)) (* right (buffer-value buffer i))) (setf (buffer-value buffer i) (* left (buffer-value buffer i)))))) (metadata 'panner) ;; => ((:INPUTS . 1) (:OUTPUTS . 2)) (defparameter *effect-chain-buffer* (make-buffer (block-size) :channels (max (metadata 'panner :inputs) (metadata 'panner :outputs))))
Remove the DSP definition, if any, of name
.
If name
is non-NIL, free the cached DSP instances named name
.
Otherwise, free all the cached DSP instances.
Return the name list of the defined DSP’s.
Next: Mixdown, Previous: DSP, Up: The Incudine dictionary [Contents][Index]
If a variable is bound to a performance-time value, for example:
(define-vug first-expansion-test ((rain-p boolean)) (with-samples ((s (performance-time-humidity))) (out (* s .5) (* s .3))))
the variable is set the first time that it appears within the body of the definition:
(out (* (setf s (performance-time-humidity)) .5) (* s .3))
It is generally correct. Unfortunately, there is the posibility to introduce a bug if the performance-time variable is updated inside a branching, for example:
(define-vug first-expansion-test ((rain-p boolean)) (with-samples ((s (performance-time-humidity))) (out (if rain-p s (* s 0.15)))))
In this case, the result is
(out (if rain-p (setf s (performance-time-humidity)) (* s 0.15)))
where S is performance-time only if it’s raining. The simplest solution for this example is to explicitally set the variable before branching:
(define-vug first-expansion-test ((rain-p boolean)) (with-samples (s) (setf s (performance-time-humidity)) (out (if rain-p s (* s 0.15)))))
However the problem persists with a VUG input (obviously only if it is performance-time):
(define-vug first-expansion-test (s (rain-p boolean)) (out (if rain-p s (* s 0.15))))
The definitive solution is to indicate where the variable is updated if necessary (the VUG input is possibly set before this point):
(define-vug first-expansion-test (s (rain-p boolean)) (maybe-expand s) (out (if rain-p s (* s 0.15))))
Note: it is also possible to force the setting of a variable, for example:
(define-vug snapshot ((gate fixnum) (start-offset fixnum) input) (with-samples ((next-time (init-only (+ (now) gate))) (value (sample 0))) (initialize (setf next-time (+ (now) start-offset))) (cond ((plusp gate) (unless (< (now) next-time) (setf value (update input)) (setf next-time (+ (now) gate)))) ((minusp gate) (setf value (update input) gate 0))) value))
in this case the performance-time loop is:
(labels ((set-input[gensym-ed] () (setf input ...))) (cond ((plusp gate) (unless (< (now) next-time) (setf value (set-input[gensym-ed])) (setf next-time (+ (now) gate)))) ((minusp gate) (setf value (set-input[gensym-ed]) gate 0))) value))
Next: Rego File, Previous: The rule of the first expansion, Up: The Incudine dictionary [Contents][Index]
Max size in seconds of the written sound file when the duration is undefined.
Write the audio frames generated during body
to the sound file
output-filename
.
The execution of body
doesn’t interfere with the real-time context.
If input-filename
is a sound file, it represents the audio input
accessible via audio-in
.
channels
is the number of output channels and defaults to
*number-of-output-bus-channels*
.
If duration
is non-NIL, it is the duration in seconds of the sound data.
If the duration is undefined, i.e. the code in body
schedules infinite
events, the duration is *bounce-to-disk-guard-size*
.
pad
is the duration of the silence to add at the end of the produced
sound. pad
is 2 by default but it is ignored if duration
is non-NIL.
sample-rate
defaults to *sample-rate*
.
The string header-type
specifies the type of the header (*) for the
output file and defaults to *default-header-type*
.
Type | Description |
---|---|
wav | WAV (Microsoft) |
aiff | AIFF (Apple/SGI) |
au | AU (Sun/NeXT) |
raw | RAW (header-less) |
paf | PAF (Ensoniq PARIS) |
svx | IFF (Amiga IFF/SVX8/SV16) |
nist | WAV (NIST Sphere) |
voc | VOC (Creative Labs) |
ircam | SF (Berkeley/IRCAM/CARL) |
w64 | W64 (SoundFoundry WAVE 64) |
mat4 | MAT4 (GNU Octave 2.0 / Matlab 4.2) |
mat5 | MAT5 (GNU Octave 2.1 / Matlab 5.0) |
pvf | PVF (Portable Voice Format) |
xi | XI (FastTracker 2) |
htk | HTK (HMM Tool Kit) |
sds | SDS (Midi Sample Dump Standard) |
avr | AVR (Audio Visual Research) |
wavex | WAVEX (Microsoft) |
sd2 | SD2 (Sound Designer II) |
flac | FLAC (Free Lossless Audio Codec) |
caf | CAF (Apple Core Audio File) |
wve | WVE (Psion Series 3) |
ogg | OGG (OGG Container format) |
mpc2k | MPC (Akai MPC 2k) |
rf64 | RF64 (RIFF 64) |
mpeg | MPEG-1/2 Audio |
The string data-format
is the format (*) of the sample for the output
file and defaults to *default-data-format*
.
Format | Description |
---|---|
pcm-s8 | Signed 8 bit PCM |
pcm-16 | Signed 16 bit PCM |
pcm-24 | Signed 24 bit PCM |
pcm-32 | Signed 32 bit PCM |
pcm-u8 | Unsigned 8 bit PCM |
float | 32 bit float |
double | 64 bit float |
ulaw | U-Law |
alaw | A-Law |
ima-adpcm | IMA ADPCM |
ms-adpcm | Microsoft ADPCM |
gsm610 | GSM 6.10 |
vox-adpcm | VOX ADPCM |
nms-adpcm-16 | 16kbs NMS ADPCM |
nms-adpcm-24 | 24kbs NMS ADPCM |
nms-adpcm-32 | 32kbs NMS ADPCM |
g721-32 | 32kbs G721 ADPCM |
g723-24 | 24kbs G723 ADPCM |
g723-40 | 40kbs G723 ADPCM |
dwvw-12 | 12 bit DWVW |
dwvw-16 | 16 bit DWVW |
dwvw-24 | 24 bit DWVW |
dpcm-8 | 8 bit DPCM |
dpcm-16 | 16 bit DPCM |
vorbis | Vorbis |
opus | Opus |
alac-16 | 16 bit ALAC |
alac-20 | 20 bit ALAC |
alac-24 | 24 bit ALAC |
alac-32 | 32 bit ALAC |
mpeg-layer-I | MPEG Layer I |
mpeg-layer-II | MPEG Layer II |
mpeg-layer-III | MPEG Layer III |
(*) The recognized headers and formats depend on the version of libsndfile.
metadata
is a property list to set string metadata in output-filename
.
Not all file types support metadata. The valid properties are: title,
copyright, software, artist, comment, date, album, license, tracknumber
and genre.
The max number of scheduled events is the value of the configuration
variable *nrt-edf-heap-size*
(a power of two).
Write the audio frames generated during body
to the buffer
structure
output-buffer
, starting from the buffer frame start
(0 by default).
The execution of body
doesn’t interfere with the real-time context.
If frames
is non-NIL, it is the number of frames to write.
If input-buffer
is a buffer
structure, it represents the audio input
accessible via audio-in
.
sample-rate
defaults to *sample-rate*
.
If mix-p
is t
, mix the new data with the old content of the buffer.
The max number of scheduled events is the value of the configuration
variable *nrt-edf-heap-size*
(a power of two).
Execute body
without to interfere with the real-time context.
channels
and sample-rate
are the number of the output channels and the
sample rate respectively.
bpm
is the tempo in beats per minute and defaults to *default-bpm*
.
Next: Networking, Previous: Mixdown, Up: The Incudine dictionary [Contents][Index]
A rego file can contain time-tagged lisp functions, lisp statements, arbitrary score statements and lisp tags. Besides, the rego file format supports the Org markup language. It is possible to edit and organize score files with spreedsheet-like capabilities, headlines, unordered lists, blocks, properties, hyperlinks, todo items, tags, deadlines, scheduling, etc.
The syntax of a time-tagged lisp function is:
start-time-in-beats [time-increment]* function-name [arg1] [arg2] ...
The optional numbers between start-time-in-beats
and function-name
increment the start time. For example:
0.8 foo 220 .2 2.5 .15 foo 440 .5 3.2 .25 -.11 foo 432 .2
is equivalent to
0.8 foo 220 .2 (+ 2.5 .15) foo 440 .5 (+ 3.2 .25 -.11) foo 432 .2
A line comment starts with a semicolon. A line continuation requires
the character \
at the end of the line. The comments and the blocks
in Org markup language are ignored too.
If the symbol //
is used to separate the functions with the same
time-tag, the result is a polyphonic vertical sequencer in text files.
A quoted function name is ignored; useful to mute an instrument.
For example:
2.5 foo 440 .08 // bar 550 .1 // 'baz 660 .05 // sev 770 .1 3.2 // baz 330 .03 4.5 foo 220 .02 // sev 772 .07
is equivalent to
2.5 foo 440 .08 2.5 bar 550 .1 2.5 sev 770 .1 3.2 baz 330 .03 4.5 foo 220 .02 4.5 sev 772 .07
Example with common start-time and different delay-time:
0 .11 i1 1 2 3 // .25 i2 1 2 3 // .05 i3 1 2 3 1 2 i1 1 2 3 // .05 i2 1 2 3 // -.15 i3 1 2 3 3
is equivalent to
0.05 i3 1 2 3 0.11 i1 1 2 3 0.25 i2 1 2 3 1.85 i3 1 2 3 2.00 i1 1 2 3 2.05 i2 1 2 3
An isolated number is not a lisp tag otherwise a time-tagged function gets confused. A single column of numbers is useful for rhythm templates.
There are predefined variable bindings usable inside a rego file:
List of score function arguments.
T if the events are scheduled in real-time.
Temporal envelope of the events.
Time offset in beats.
Note: we can use tempo-env
within an event function only if the
event terminates before the end of the rego file.
The score statement :score-time:
sets the variable time
.
The name is surrounded by colons, so it is also a valid property
in Org markup language. For example:
:PROPERTIES: :score-time: 8 :END:
is equivalent to
(setf time 8)
The score statement :score-start-time:
sets the start time in beats.
The events scheduled before that time and the score start time of the
included files are ignored.
It is possible to create other variable bindings through
with
at the beginning of the score. For example:
;;; test.rego with (id 1) (last 4) ;; simple oscillators 0 simple 440 .2 :id id 1 simple 448 .2 :id (+ id 1) (1- last) simple 661 .2 :id (+ id 2) last free 0
We can also add a declare
expression after the bindings.
The score statement :score-bindings:
is an alias of with
.
The score statement :score-package:
sets the name of the package
used to read the rest of the score lines. For example:
:score-package: string-quartet 0 vla p1 p2 p3 0 vl q1 q2 q3
is equivalent to
0 string-quartet:vla string-quartet::p1 string-quartet::p2 string-quartet::p3 0 string-quartet:vl string-quartet::q1 string-quartet::q2 string-quartet::q3
dur
is a local macro to convert the duration from
beats to seconds with respect to tempo-env
.
tempo
is a local macro to change the tempo of the score.
The syntax is
(tempo bpm) (tempo bpms beats &key curve loop-node release-node restart-level real-time-p)
The score statement :score-tempo:
is an alternative to the local
macro tempo
:
:score-tempo: bpm :score-tempo: bpms beats &key curve [...]
If a function created with regofile->function
or
regostring->function
is scheduled in real-time:
;; The real scheduled time is `(+ time latency)'. (at time function-from-regofile ...)
there is a latency introduced during the creation of a temporary
queue for the score events (see also with-schedule
). If a precise
scheduling in real-time is required, the score statement
:score-realtime-offset:
sets the absolute time offset in samples
for the scheduled score events. For example, if the rego file
begins with the following lines:
:score-tempo: '(180 95) '(4) :curve :exp :score-realtime-offset: (tempo-sync #[4 b tempo-env 0])
a scheduled function is synchronized to a period of 4 beats.
The syntax to include the content of an external rego file is:
include "regofile" [time] {value}* {(var value)}*
where time
is an optional time offset in beats, and the variable
bindings set some score bindings of the included file. For example:
include "phrase-7.rego" include "phrase-7.rego" 4 include "phrase-7.rego" 8 (keynum 63) (channel 3) ;; Set the first score binding and CHANNEL in "phrase-7.rego". include "phrase-7.rego" 12 68 (channel 3) ;; Set the first two score bindings in "phrase-7.rego". include "phrase-7.rego" 16 70 3
time
and tempo-env
are a parent’s copy within an included rego file,
so we can locally change the temporal envelope and/or the time offset
without side effects. Moreover, all the local bindings and the labels
contained in a rego file continue to have lexical scope and dynamic
extent, therefore it is possible to include the same rego file multiple
times without name collisions.
A time-tagged string is an alternative syntax to include the content of a rego file:
time "regofile" {value}* {(var value)}*
There is not a specific limit on the depth of included rego files.
A score macro is defined with a macro block in Org markup language:
#+begin_macro name ... #+end_macro
The syntax for a score macro expansion is:
name [time] {value}* {(var value)}*
or the time-tagged version:
time name {value}* {(var value)}*
The inclusion of a rego file is equivalent to the expansion of a score macro defined with the same file contents (dynamic extent bindings, tempo, etc). For example:
:score-tempo: 120 #+begin_macro macro-test with x y z :score-tempo: '(120 30) '(12) :curve :exp 0 test x 4 test y 8 test z #+end_macro 16 bridge |------------+------+---+---+---| | ! | time | x | y | z | |------------+------+---+---+---| | macro-test | 0 | 1 | 2 | 3 | | macro-test | 12 | 4 | 5 | 6 | |------------+------+---+---+---| 30 free 0
is equivalent to
0.0d0 test 1 2.542321754062445d0 test 2 6.0d0 test 4 6.578005980902809d0 test 3 8.0d0 bridge 8.542321754062446d0 test 5 12.578005980902809d0 test 6 15.0d0 free 0
A rego file ends after the last event or after a long pending event if
the duration is known (defined with the local macro dur
). For
example:
0 ... 1.5 ... 3 ...
ends after 3 beats but
0 ... 1.5 ... (dur 5) ... 3 ...
ends after 6.5 beats.
The score pages are delimited by the form feed character.
The score statement :score-pages:
sets the pages to read (the
other pages are ignored). all
and t
mean “all the pages”.
Example:
:score-pages: 7 :score-pages: 3 7 8 :score-pages: all
:score-pages:
defaults to 1. In this case, a line with a form
feed character marks the end of score. For example, we can create
and edit a rego file in Emacs SES (Simple Emacs Spreadsheet) mode.
Note: the pages within a score macro block are not part of the main score, and the pages within other blocks in Org markup language are ignored.
#|
is an ignored score statement by default, therefore
the following ellipsislispy example is a valid score for
regofile->*
#| :score-pages: 2 |# (defun i1 ...) (defun i2 ...) #| Note: in this text ^L is not a real form feed char. ^L ;; second page 0 i1 ... // i2 ... 1 i1 ... 2 i2 ... ;; end of page ^L |# (defun i3 ...) ;; etc...
The score statement :score-radix:
sets the variable
*read-base*
to read the rest of the score lines.
:score-radix:
defaults to 10 if there is not a parent rego file.
Example:
12 i2 60 100 15 i2 63 78 :score-radix: 16 00 i1 7f ff 1f 1a 0b i1 2b 08 0c 3c ;; Ratios are affected by *READ-BASE* ff/1f i3 1/ff f/a :score-radix: 2 00011010 add 10101010 11001011
Warning: we could introduce some bugs if :score-radix:
is greater
than 10. For example:
:score-radix: 16 0 cc 10 7f 1 foo 'babba
is equivalent to
0 204 16 127 1 foo 764858
The score statement :score-float-format:
sets the variable
*read-default-float-format*
to read the rest of the score lines.
:score-float-format:
defaults to double-float
(the sample type)
if there is not a parent rego file.
Example:
0 print (list 1.0 1.2345 1.125s3 123.456d0 1f-3 1d-3 1e-3 1.234l0) ;; => (1.0d0 1.2345d0 1125.0 123.456d0 0.001 0.001d0 0.001d0 1.234d0) :score-float-format: single-float 0 print (list 1.0 1.2345 1.125s3 123.456d0 1f-3 1d-3 1e-3 1.234l0) ;; => (1.0 1.2345 1125.0 123.456d0 0.001 0.001d0 0.001 1.234d0) ** double-float again :PROPERTIES: :score-float-format: double-float :END: 0 print (list 1.0 1.2345 1.125s3 123.456d0 1f-3 1d-3 1e-3 1.234l0) ;; => (1.0d0 1.2345d0 1125.0 123.456d0 0.001 0.001d0 0.001d0 1.234d0) 0 force-output
The score statement call
pushes the return position on the stack
and transfers program control to the point labeled by a tag.
The score statement return
transfers control to the return position
located on the top of the stack.
Syntax for call
statement (a tag between [[]]
is a facility for
the Org markup language):
call tag call tag time call [[tag]] time ; the target label is <<tag>> call [[tag][description]] time ; the target label is <<tag>>
Example:
* score ** sequence call p1 0 call [[p2][pattern two]] 1 call p3 1.5 call p1 2 return ; end of score ** pattern 1 p1 0 write-line "pattern 1" // force-output call p3 .1 call p3 .25 return ** pattern 2 <<p2>> 0 write-line "pattern 2" // force-output return ** pattern 3 p3 0 write-line "pattern 3" // force-output return
Define an arbitrary score statement named name
, formed by the
elements of the returned list.
The name of the score statement is a symbol or a string. The symbol SomeName is equivalent to the string “somename”. The symbol |SomeName| is equivalent to the string “SomeName”.
Example:
(defscore-statement i1 (time dur freq amp) `(,time my-func (dur ,dur) ,freq ,amp))
where the Csound score statement
i1 3.4 1.75 440 .3
will be expanded in a time tagged lisp function
3.4 my-func (dur 1.75) 440 0.3
Delete the score statement defined by defscore-statement
or ignore-score-statements
.
Ignore the score statements in name-list
. The name of a statement is
a symbol, a string or a list of two score statements which delimit a
score block to ignore.
Readtable to read a rego file.
From a rego file path
, return the corresponding lisp form inside the
definition of a function optionally named function-name
.
If compile-rego-p
is nil
(default), use an interpreter to evaluate the
event list at runtime when this function is called.
From a rego file path
, define a function optionally named
function-name
to evaluate the corresponding lisp form.
If compile-rego-p
is nil
(default), use an interpreter to evaluate the
event list at runtime.
The score statement :score-function-name
: or :score-local-function-name
:
is an alternative method to set the function name.
Example:
* Score functions recursively scheduled :PROPERTIES: :score-bindings: (n (or (pop score-args) 12345)) \ (m (or (pop score-args) 16)) \ (local-call-p (pop score-args)) \ (freq (* m 100)) \ (next (if score-realtime-p 1/8 1/4)) \ (last (if score-realtime-p (- 4 1/8) 4)) :score-function-name: rego-function-name-test-1 :score-local-function-name: self :score-tempo: 240 :score-realtime-offset: (tempo-sync #[1/4 beats tempo-env 0]) :END: #+begin_src incudine :results silent (dsp! rego-test-3 (freq amp dur) (stereo (* (envelope (make-perc .1 .9) 1 dur #'free) (sine freq amp)))) #+end_src ** Recursion of SELF (unless (> m 0) (go end-of-score)) 0 rego-test-3 (* freq (expt 2 3/12)) (/ m 20) (dur 1/5) next self n (1- m) t (if local-call-p (go end-of-score)) ** Recursion of REGO-FUNCTION-NAME-TEST-1 (unless (> n 0) (go end-of-score)) last rego-function-name-test-1 (1- n) 16 (if (< n 12345) (go end-of-score)) ** New definition for REGO-FUNCTION-NAME-TEST-1 ;; The definition of REGO-FUNCTION-NAME-TEST-1 changes after 3 cycles ;; but the recursive local function SELF fills the fourth cycle. (* 4 3) .1 (lambda () (setf (symbol-function 'rego-function-name-test-1) \ (constantly nil))) ** End end-of-score
From a string containing a score in rego file format, define a
function optionally named function-name
to evaluate the corresponding
lisp form.
If compile-rego-p
is nil
(default), use an interpreter to evaluate the
event list at runtime.
The score statement :score-function-name
: or :score-local-function-name
:
is an alternative method to set the function name.
Convert from a rego file to a lisp file.
The lisp file contains the definition of a function optionally named
function-name
.
If lisp-file
is nil
, the name of the lisp file is the name of the rego
file path
with file extension “cudo”.
If compile-rego-p
is nil
(default), use an interpreter to evaluate the
event list at runtime when the function is called.
From a rego file path
, return the corresponding event list as a
list of lists (time function-name &rest arguments).
From a string containing a score in rego file format, return the corresponding event list as a list of lists (time function-name &rest arguments).
Write a rego file path
with the event list obtained from a list of
lists (time function-name &rest arguments).
Next: Serial IO, Previous: Rego File, Up: The Incudine dictionary [Contents][Index]
Next: Open Sound Control, Up: Networking [Contents][Index]
Stream socket type.
Extension of osc:stream
.
Input stream socket type.
Extension of osc:input-stream
.
Return t
if object is of type net:input-stream
.
Output stream socket type.
Extension of osc:output-stream
.
Return t
if object is of type net:output-stream
.
Default flags for the C functions send, sendto, recv and recvfrom.
It defaults to MSG_NOSIGNAL (don’t generate a sigpipe
signal) on Linux.
See the manual pages of the C functions and bits/socket.h for details.
Size in bytes of the net:stream
buffer used to read or write octets.
The maximum length to which the queue of pending connections for a socket stream may grow.
Return the address associated with stream
.
Return the numeric port associated with stream
.
Return the stream
direction.
Return the stream
protocol.
Return t
if the stream
protocol is protocol
; otherwise, return nil
.
Return the foreign pointer to the stream
buffer.
Return the size in bytes of the stream
buffer.
Create and return a new net:stream
.
The host
address/name and port
default to “localhost” and 24134
(aka #36rime
).
direction
is :input
(default) or :output
to return a net:input-stream
or a net:output-stream
respectively.
protocol
is :tcp
(default) or :udp
. If protocol
is :tcp
and
auto-connect-p
is t
(default), try to connect the output stream
socket. See also incudine.net:connect
and incudine.net:connected-p
.
buffer-size
is the size in bytes of the buffer used to read or
write octets. It defaults to net:*buffer-size*
.
If the net:stream
is also used with the OSC (Open Sound Control)
utilities (i.e. osc:send
and osc:receive
), max-values
is the maximum
number of the required values of a OSC message. It defaults to
osc:*max-values*
. message-encoding
is nil
(default) or :slip
.
Whether stream
is an open stream socket.
List of the functions of one argument called before to close a stream socket. The function argument is the stream to close.
Close the stream
socket.
Receive a message from a stream
socket and return the number of
octets read.
flags
defaults to net:+default-msg-flags+
. See the manual pages for
recv and recvfrom for details on the flags
argument.
Send the octets from obj
into a stream
socket and return the number
of octets written.
obj
is one of nil
, a vector of octets or a string. If nil
, send the
octets stored in the stream
buffer.
start
and end
are the bounding index designators of the array.
flags
defaults to net:+default-msg-flags+
. See the manual pages for
send and sendto for details on the flags
argument.
Read buffer-size
octets from a stream
socket into a foreign buffer
pointed to by buffer-pointer
. Return the number of octets read.
flags
defaults to net:+default-msg-flags+
. See the manual pages for
recv and recvfrom for details on the flags
argument.
Send buffer-size
octets from a foreign buffer pointed to by
buffer-pointer
into a stream
socket. Return the number of octets
written.
flags
defaults to net:+default-msg-flags+
. See the manual pages for
send and sendto for details on the flags
argument.
Whether broadcasting is enabled for the stream
socket. Setfable.
Whether the stream
socket is in blocking mode. Setfable.
Bind var
to input-stream
socket and set the non-blocking mode
during body
.
Return the socket file descriptor of the stream
socket.
Return the file descriptor for the accepted connection used to get the last received message.
Send octets
on a socket with file descriptor sockfd
.
flags
defaults to net:+default-msg-flags+
. See the manual pages for
send and sendto for details on the flags
argument.
Close the output stream
socket, create a new socket and try to connect it.
Whether stream
socket is connected.
Return the number of the connections accepted by the listening
stream
socket.
Return the file descriptors of the connections accepted by the
listening stream
socket.
Close all the connections to the stream
socket.
Close the input stream
socket and create a new socket.
Return the string stored in the buffer of the stream
socket.
Copy the string
into the buffer of the stream
socket.
Return the vector of octets stored in the buffer of the stream
socket.
Create a new vector if octets
is nil
(default).
start
and end
are the bounding index designators of the vector.
Copy the octets
into the buffer of the stream
socket.
start
and end
are the bounding index designators of the vector.
If osc-message-p
is t
(default), the content of the buffer is an OSC message
and the osc:stream
structure is specially updated.
Serial Line ip
encoding.
Serial Line ip
decoding.
Previous: General Stream Sockets, Up: Networking [Contents][Index]
Stream socket type for OSC (Open Sound Control) messages.
Input stream socket type for OSC (Open Sound Control) messages.
Return t
if object is of type osc:input-stream
.
Output stream socket type for OSC (Open Sound Control) messages.
Return t
if object is of type osc:output-stream
.
Size in bytes of the osc:stream
buffer used to read or write octets.
Maximum number of the values required by an OSC message.
Latency in seconds for OSC bundles sent from stream
. Setfable.
Maximum number of the values required by an OSC message for stream
.
Return the encoding type associated with stream
. Setfable.
Create and return a new osc:stream
.
The host
address/name and port
default to “localhost” and 32126
(aka #36rose
).
direction
is :input
(default) or :output
to return an osc:input-stream
or an osc:output-stream
respectively.
protocol
is :tcp
or :udp
(default). If protocol
is :tcp
and
auto-connect-p
is t
(default), try to connect the output stream
socket. See also incudine.net:connect
and incudine.net:connected-p
.
buffer-size
is the size in bytes of the buffer used to read or
write octets. It defaults to osc:*buffer-size*
.
latency
(0 by default) is the latency in seconds for OSC bundles.
max-values
is the maximum number of the required values of an OSC
message. It defaults to osc:*max-values*
.
message-encoding
is nil
(default) or :slip
.
Use osc:open
with arguments
to create an osc:stream
. When control
leaves the body, either normally or abnormally, the osc:stream
is
automatically closed.
Return the foreign pointer to the OSC message stored in the stream
buffer.
Return the length of the OSC message stored in the stream
buffer. Setfable.
If the contents of the stream
buffer are an OSC bundle,
return the length of that bundle. Otherwise, return zero.
If the OSC packet received through the stream
socket is an OSC bundle,
return the time obtained from the OSC time tag. Otherwise, return zero.
If time-unit
is nil
(default), the time value in samples is suitable as
first argument to incudine:at
(at (osc:message-time stream) function ...)
where message-time is the OSC bundle time or zero.
If time-unit
is seconds
, the bundle time is in universal time format.
Send an OSC message with OSC address
, OSC types
and arbitrary values
.
OSC type | Lisp type |
---|---|
b | (or simple-vector (simple-array (unsigned-byte 8) (*))) |
c | standard-char |
d | double-float |
f | single-float |
F | no required value |
h | (signed-byte 64) |
i | (signed-byte 32) |
I | no required value |
m | (unsigned-byte 32) i.e. (midifile:message 176 7 42) |
N | no required value |
s | string |
S | string |
t | (or (unsigned-byte 64) double-float) |
T | no required value |
No buffer bounds checking because it is an unnecessary lost of time
for the usual OSC messages. You can call your bounds checking routine
before osc:message
if you are sending OSC messages out of control.
See also :buffer-size
and :max-values
in osc:open
.
Write the OSC address
pattern and the OSC types
to the stream
buffer,
then index the required values.
No buffer bounds checking because it is an unnecessary lost of time
for the usual OSC messages. You can call your bounds checking routine
before osc:start-message
if you are sending OSC messages out of
control. See also :buffer-size
and :max-values
in osc:open
.
Send the OSC message stored in the stream
buffer.
flags
defaults to net:+default-msg-flags+
. See the manual pages for
send and sendto for details on the flags
argument.
Send an OSC message with timestamp seconds
plus stream latency,
OSC address
, OSC types
and arbitrary values
.
If values
is :send-p
nil
, or there are no values
and the string types
implies some required values, prepare the OSC message but don’t send it.
The OSC timestamp seconds
is used with dual meaning: if it is greater
than 63103 seconds (about 17 hours), the time is absolute otherwise it
is added to the current time. 63104 is the offset of the NTP Timestamp
Era 1 (from 8 Feb 2036), so this hack will work for centuries.
No buffer bounds checking because it is an unnecessary lost of time for
the usual OSC messages. You can call your bounds checking routine before
osc:simple-bundle
if you are sending OSC messages out of control.
See also :buffer-size
and :max-values
in osc:open
.
Example:
(osc:simple-bundle stream .5 "/osc/test" "iii" 1 2 3) ;; => 52
is equivalent to
(osc:simple-bundle stream 0 "/osc/test" "iii") ;; => 0 (setf (osc:value stream 0) 1) (setf (osc:value stream 1) 2) (setf (osc:value stream 2) 3) (osc:send-bundle stream .5) ;; => 52
Send an OSC bundle with timestamp seconds
plus stream latency.
An OSC message is a list
(address types &rest values)
If seconds
is nil
, prepare the OSC message but don’t send it.
The OSC timestamp seconds
is used with dual meaning: if it is greater
than 63103 seconds (about 17 hours), the time is absolute otherwise it
is added to the current time. 63104 is the offset of the NTP Timestamp
Era 1 (from 8 Feb 2036), so this hack will work for centuries.
No buffer bounds checking. You can call your bounds checking routine
before osc:bundle
if you are sending OSC messages out of control.
See also :buffer-size
and :max-values
in osc:open
.
Example:
(defvar *oscout* (osc:open :direction :output :port 9999)) (osc:bundle *oscout* 3/4 '("/bp/freq" "f" 2909.09) '("/bp/q" "f" 60.0) '("/bp/gain" "f" 6.5)) (loop for i below (osc:required-values *oscout*) collect (osc:value *oscout* i)) ;; => (2909.09 60.0 6.5) (setf (osc:value *oscout* 0) 3469.88) (setf (osc:value *oscout* 2) 8.2) (osc:send-bundle *oscout* .4)
Send the OSC bundle stored in the stream
buffer with OSC timestamp
seconds
(0.0 by default) plus the stream latency.
See osc:bundle
or osc:simple-bundle
for details about the OSC
timestamp seconds
.
flags
defaults to net:+default-msg-flags+
. See the manual pages for
send and sendto for details on the flags
argument.
Note: osc:send-bundle
continues to work after osc:message
if the
message length is equal to the length of the prior contents.
Store the received OSC packet into the stream
buffer.
If the packet is an OSC bundle, the current OSC message is the
first message of that bundle. The other messages are queued for
the successive calls to osc:receive
. See osc:message-time
for
the time value obtained from the OSC time tag.
flags
defaults to net:+default-msg-flags+
. See the manual pages
for recv and recvfrom for details on the flags
argument.
Return the number of bytes of the OSC message.
Return t
if the current OSC message is the last of the received OSC bundle,
and a secondary value t
if the message is part of a bundle.
osc:flush-bundle
discards the queued OSC messages.
The next call to osc:receive
waits for a new OSC packet.
Copy the contents of an OSC stream buffer to an OSC output stream buffer.
No bounds checking. You can call your bounds checking routine if the streams
were created with different buffer size or maximum number of required
values (see buffer-size
and max-values
parameters to osc:open
).
Return the OSC address pattern stored in the stream
buffer,
and the OSC type tag as secondary value if typetag-p
is t
.
Return t
if the OSC address pattern and the OSC type tag stored in the
stream
buffer are address
and types
.
If necessary or force-p
is t
, update the foreign pointers to the
required values of the OSC message stored in the stream
buffer.
If swap-p
is t
, the byte order of the values is reversed on little
endian machine.
Access a required value of the OSC message stored in the stream
buffer.
The OSC value is specified by the zero-based index
.
Setfable with no buffer bounds checking when the value is a string or
a blob. You can call your bounds checking routine before (SETF osc:value
)
if you are changing the data length out of control. See also :buffer-size
and :max-values
in osc:open
.
Return the foreign pointer to a required value of the OSC message stored
in the stream
buffer. The OSC value is specified by the zero-based index
.
No bounds checking.
Create new symbol macro bindings value-names
to the OSC values of
an osc:stream
with OSC types
during body
.
Example:
(incudine.osc:with-values (a b c) (*oscin* "iii") (msg info "~D ~D ~D" a b c))
Number of the required values of the OSC message stored in the stream
buffer.
Encode a short MIDI message into an OSC value with MIDI message type tag (m).
Adjust the size n
of a zero-padded OSC data. The new size will be a
multiple of four (bytes).
Next: Midifile, Previous: Networking, Up: The Incudine dictionary [Contents][Index]
Create, open and return a stream that is connected to a serial port
with
speed baud-rate
, 8 data bits, no parity checking and one stop-bit.
baud-rate
defaults to 9600.
element-type
is the type specifier character
(default) or unsigned-byte
8.
Example:
(in-package :scratch) (defvar *uno* (open-serial-port "/dev/ttyACM0")) (make-responder *uno* (lambda (x) (when (numberp x) (barrier (:write) (setf (bus 0) (sample (the single-float x)))) nil))) (recv-start *uno* :read-function (lambda (stream) (let ((str (read-line stream nil nil))) (and str (parse-float str))))) ;; stop (recv-stop *uno*) (remove-all-responders *uno*) (remove-receiver *uno*) (close *uno*)
Whether stream
refers to a serial port.
If direction
is :input
or :io
(default), flush data received from
the serial port stream
but not read.
If direction
is :output
or :io
, flush data written to stream
but not
transmitted.
Next: Soundfile, Previous: Serial IO, Up: The Incudine dictionary [Contents][Index]
MIDI file stream type.
MIDI file input stream type.
Return t
if object is of type midifile:input-stream
.
MIDI file output stream type.
Return t
if object is of type midifile:output-stream
.
Create and return a new midifile:stream
.
direction
is :input
(default) or :output
to return a midifile:input-stream
or a midifile:output-stream
respectively.
if-exists
should be one of :error
, :new-version
, :rename
, :rename-and-delete
,
:overwrite
, :append
, :supersede
or nil
. The default is :error
.
If direction
is :output
, the MIDI file format
defaults to 0 and ppqn
(Pulses
Per Quarter Note) defaults to 480.
Whether mf
is an open midifile:stream
.
Close a midifile:stream
.
If mf
is a midifile:output-stream
, write the current track.
Use midifile:open
to create a midifile:stream
. When control leaves the body,
either normally or abnormally, the midifile:stream
is automatically closed.
Read the header of a MIDI file and return four values: format, number of tracks, ppqn-or-smpte-format and ticks-per-frame.
Write the header-chunk of a MIDI file.
Default values for defined keywords:
:FORMAT 0 :NUMBER-OF-TRACKS 1 :PPQN-OR-SMPTE-FORMAT 480 :TICKS-PER-FRAME 0
Read the next event from a midifile:input-stream
and return the
status byte.
Example:
(in-package :scratch) (dsp! oscilla ((keynum fixnum) (velocity fixnum) scaler gate) (with-samples ((freq (tuning-cps *default-tuning* keynum)) (amp (* scaler velocity (sample 1/127)))) (stereo (* (envelope (make-adsr .001 .09 .8 .7) gate 1 #'free) (sine freq amp))))) (defun get-id-by-midi-note (channel keynum) (+ (ash channel 7) keynum 1)) (defun oscillante (status data1 data2) (let ((ch (logand status #xF))) (cond ((midi-note-on-p status) (oscilla data1 data2 1/10 1 :id (get-id-by-midi-note ch data1))) ((midi-note-off-p status) (set-control (get-id-by-midi-note ch data1) :gate 0))))) (defun play-midifile (path) (with-schedule (with-open-midifile (mf path) (loop for st = (midifile:read-event mf) while st when (< st #xF0) do (at (* (midifile:event-seconds mf) *sample-rate*) #'oscillante st (midifile:message-data1 mf) (midifile:message-data2 mf)))))) ;; Note: all the events are scheduled if the value of the configuration ;; variable *RT-EDF-HEAP-SIZE* in ${HOME}/.incudinerc is at least: (with-open-midifile (mf "/path/to/file.mid") (next-power-of-two (loop while (midifile:read-event mf) sum 1))) (rt-start) (play-midifile "/path/to/file.mid") ;; Stop playing before the end if necessary. (flush-pending) (free 0) ;; Write a sound file. (with-logger (:level :info) (bounce-to-disk ("oscilla-test.wav" :channels 2 :duration 60) (play-midifile "/path/to/file.mid")))
Write a MIDI event with the message msg
of size size
encoded into
four bytes to the midifile:output-stream
mf
.
beats
is the absolute time of the message in beats. If the event
precedes the last event, it is added with delta-time zero.
Write a MIDI event with the message stored in the octets data
to the midifile:output-stream
mf
.
beats
is the absolute time of the message in beats. If the event
precedes the last event, it is added with delta-time zero.
The octets data
are optionally bounded by start
and end
.
Write a tempo track to a midifile:output-stream
mf
with the tempo
changes obtained from a incudine:tempo-envelope
.
It fails if the current track contains events at non-zero time.
If the curve of a transition is not :step
, transition-time-step
is the
time in beats between adjacent points during that transition.
transition-time-step
defaults to 1/8.
If write-track-chunk-p
is t
(default), write the track chunk and
return the number (zero based) of the next track, otherwise return
the number of the current track.
write-tempo-track
works with a single time-signature (or two if the
last doesn’t precede the time of the last tempo change). If there
are not location markers between the first and the last tempo changes,
it is also possible to add markers before to write the track chunk.
Example:
(midifile:write-event mf 0 (midifile:string-message 3 "tempo track")) ;; Initial time signature. (midifile:write-event mf 0 (midifile:data #xFF #x58 4 3 2 24 8)) (midifile:write-tempo-track mf tempo-env :write-track-chunk-p nil) ;; WRITE-TRACK-CHUNK-P NIL allows to insert other MIDI messages ;; starting from the time of the last tempo change. [...] ;; Write the track chunk (required if WRITE-TRACK-CHUNK-P is NIL). (midifile:next-track mf)
Encode a short MIDI message into four bytes.
Return the octets of a MIDI tempo change of bpm
beats per minute.
Return the octets of a text-based Meta event of type meta-event-type
.
Return the pathname of the midifile:stream
mf
.
Type designator for a vector of octets.
Return a vector of octets
.
Return the format of a MIDI file.
Return the pulses per quarter note of a MIDI file.
Return two values: smpte-format and ticks-per-frame of a MIDI file.
Return the number of tracks of a MIDI file.
Return the current track of the midifile:stream
mf
.
Return the number (zero based) of the next track
or nil
if obj
is of type midifile:input-stream
and there aren’t other
tracks to read.
Write the current track if obj
is of type midifile:output-stream
.
Write a MIDI End Of Track Meta event with absolute time beats
.
If beats
is 0 (default), write the event with delta time zero.
End Of Track Meta event is automatically added if necessary before to
write a track by calling midifile:next-track
or midifile:close
.
Multiple End Of Track Meta events are ignored.
MIDI file tempo type.
If the MIDI file contains more than one tempo event,
return two lists: the values in bpm
and the delta-times of the changes
in beats (useful to create a incudine:tempo-envelope
structure).
If there aren’t changes, return the tempo in bpm
.
Return the status byte of the MIDI message read from the
midifile:input-stream
mf
.
Return the first data byte of the MIDI message read from the
midifile:input-stream
mf
.
Return the second data byte of the MIDI message read from the
midifile:input-stream
mf
.
Return the length of the MIDI message read from the
midifile:input-stream
mf
.
Return the buffer that contains the MIDI message read from the
midifile:input-stream
mf
and the length of that message in bytes.
Return the time in pulses of the last event read from a
midifile:input-stream
.
Return the delta time in pulses of the last event read from the
midifile:input-stream
mf
.
Return the time in beats of the last event read from a
midifile:input-stream
.
output-type-spec
is the type of the returned value and defaults to
double-float
.
Return the time in seconds of the last event read from a
midifile:input-stream
.
Release the cached adjustable buffers for midifile:stream
.
Next: Profiling, Previous: Midifile, Up: The Incudine dictionary [Contents][Index]
Sound file stream type.
Sound file input stream type.
Return t
if object is of type soundfile:input-stream
.
Sound file output stream type.
Return t
if object is of type soundfile:output-stream
.
Create, open and return a soundfile:stream
that is connected to the
file specified by filename
.
direction
is :input
(default) or :output
to return a soundfile:input-stream
or a soundfile:output-stream
respectively.
if-exists
should be one of :append
, :error
(default), :mix
, :overwrite
or
:supersede
. If it is :supersede
and there is a jump back of the file position
during the output operations on the stream, the writing continues in mix mode).
sample-rate
, channels
, header-type
and data-format
determine the header of
the new sound file and default to *sample-rate*
, 1, *default-header-type*
and *default-data-format*
, respectively. See incudine:bounce-to-disk
for the
list of available header types and data formats.
data-location
is the data start offset in bytes for a hederless file.
buffer-size
is the size of the internal stream buffer and defaults to
*sndfile-buffer-size*
.
Whether sf
is an open soundfile:stream
.
Close a soundfile:stream
.
Use soundfile:open
to create a soundfile:stream
. When control leaves
the body, either normally or abnormally, the soundfile:stream
is
automatically closed.
Update the header of the file connected to the soundfile:output-stream
sf
.
If auto-p
is t
, the file header is updated after each write to the stream.
Turn off the auto header update if auto-p
nil
is explicitly specified.
Return t
if the sound file header is updated, or if the auto header update
is turned on. Otherwise, return nil
.
Read the header of a sound file and return five values: sampling rate, number of frames, number of channels, header type and data format.
Read and return a value from soundfile:stream
sf
at frame
(current
by default) and channel
(0 by default).
If peek-p
is t
(default), don’t increment the frame counter.
If peek-p
is nil
, read forward if forward-p
is t
(default) or backward
if forward-p
is nil
.
If peek-p
is nil
(default), read and return the next value from
soundfile:stream
sf
at channel
(default 0). If peek-p
is t
, return the
value of the current frame.
If peek-p
is nil
, read forward if forward-p
is t
(default) or backward
if forward-p
is nil
.
Fill the internal stream buffer of soundfile:stream
sf
by reading
the next data samples.
If update-status-p
is t
(default), update the status of sf
.
A foreign buffer of type double float pointed to by buffer-pointer
is
filled with the next buffer-size
items read from the soundfile:stream
sf
.
Return the number of items read.
Write value
to soundfile:output-stream
sf
at frame
and channel
(0 by default).
Write buffer-size
values stored in a foreign buffer of type double
float pointed to by buffer-pointer
to the soundfile:output-stream
sf
.
Return the number of the items written.
Whether end of file for soundfile:stream
sf
is reached.
Return the duration in seconds of the sound data in sound file.
Return the number of channels of the sound file.
Return the number of frames of the sound file.
Return the sampling rate of the sound file.
Return the header type of the sound file.
Return the data format of the sound file.
Return the string metadata type
of the sound file.
type
is of type symbol
or string
and should be one of title, copyright,
software, artist, comment, date, album, license, tracknumber or genre.
Setfable.
Return the data location of the sound file filename
.
Return the pathname of the soundfile:stream
mf
.
Return the foreign pointer to the sample data of soundfile:stream
sf
.
Return the data size of the sample data of soundfile:stream
sf
.
Return the stream buffer value of soundfile:stream
sf
specified by index
.
Return the stream buffer index of soundfile:stream
sf
for the first
channel of the current frame.
Return the current frame of soundfile:stream
sf
.
Return the current position in frames of soundfile:stream
sf
.
Setfable.
Return the stream position offset in frames of soundfile:stream
sf
.
Setfable.
Return the maximum amplitude of the sound file infile
.
infile
is of type pathname
or string
.
If channel
is an integer, return the maximum amplitude of that channel
.
Convert the sound file infile
to another format with header-type
and data-format
. The resultant sound file outfile
is overwritten if it
already exists.
The sample data is possibly normalized to normalize
dB or scale-to
[0.0,1.0],
or scaled by scale-by
.
See incudine:bounce-to-disk
for the list of available header types and data
formats.
output-file
is the concatenation of the sound files input-files
.
The input files must have the same sampling rate and number of channels.
output-file
is written with header-type
and data-format
that default to
*default-header-type*
and *default-data-format*
. See incudine:bounce-to-disk
for the list of available header types and data formats.
if-exists
is :error
by default. See soundfile:open
for details.
buffer-size
is the size of the internal stream buffer.
output-file
is the mix of the sound files input-files
.
The input files must have the same sampling rate and number of channels.
output-file
is written with header-type
and data-format
that default to
*default-header-type*
and *default-data-format*
. See incudine:bounce-to-disk
for the list of available header types and data formats.
if-exists
is :error
by default. See soundfile:open
for details.
The mix is possibly normalized to normalize
dB or scale-to
[0.0,1.0],
or scaled by scale-by
.
buffer-size
is the size of the internal stream buffer.
Next: Contributed Modules, Previous: Soundfile, Up: The Incudine dictionary [Contents][Index]
Extend sb-profile:profile
by wrapping profiling code around the
init-time and performance-time functions of the named DSPs.
Wrap profiling code around the functions of a live node
, then call
profile-report
and remove profiling code after max-number-of-calls
to
the wrapped functions, or when the target node is freed.
If the target node was paused, it is internally unpaused for
max-number-of-calls
to the profiled performance-time function.
If the target node is a group node, the paused nodes of that group are not internally unpaused.
Note: the argument name max-number-of-calls
instead of max-samples
in
this context avoids confusion between audio samples and program
execution samples.
Extend sb-profile:unprofile
by unwrapping any profiling code around
the functions of the named DSPs.
See documentation for sb-profile:report
.
Unwrap any profiling code around unreferenced DSP functions and call
sb-profile:reset
.
Next: Emacs Modes, Previous: Profiling, Up: The Incudine dictionary [Contents][Index]
Next: Jack MIDI, Up: Contributed Modules [Contents][Index]
The configuration variables *audio-input-port-name*
and
*audio-output-port-name*
are set to a control-string, or to a
function of one argument (the port number) to get the short name of a
Jack port. The default is “in_~D” for the input ports and “out_~D”
for the output ports. If the function doesn’t return a string, the
port name is the default.
Return the short name of the Jack audio port number
(zero-based),
where direction
is :input
or :output
. Setfable.
Reset the short names of the Jack audio ports.
See also the configuration variables *audio-input-port-name*
and
*audio-output-port-name*
.
Next: PortAudio, Previous: Jack Audio, Up: Contributed Modules [Contents][Index]
Set the configuration variable *enable-jack-midi*
to enable Jack MIDI:
;; Add to ~/.incudinerc (setq *enable-jack-midi* t)
Jack MIDI stream type.
Jack MIDI input stream type.
Return t
if object is of type jackmidi:input-stream
.
Jack MIDI output stream type.
Return t
if object is of type jackmidi:output-stream
.
Create and return a new jackmidi:stream
.
direction
is :input
(default) or :output
to return a jackmidi:input-stream
or a jackmidi:output-stream
respectively.
port-name
defaults to “midi_in” if direction
is :input
or “midi_out”
if direction
is :output
.
Whether stream
is an open stream.
Close a jackmidi:stream
. obj
is a jackmidi:stream
or the
port-name of the stream to close.
Read the events received from a Jack MIDI input stream
into a
vector of octets
. Return the number of the events read.
The header of the event is 12 bytes long: a timestamp (foreign double float) and the length of the MIDI message (foreign uint32).
The MIDI messages are aligned to four bytes.
Example:
(defvar *midiin* (jackmidi:open)) (defvar *buf* (make-array 1024 :element-type '(unsigned-byte 8))) (rt-start) (prog1 (zerop (jackmidi:read *midiin* *buf*)) (print *buf*))
Read the events received from a Jack MIDI input stream
into a
foreign array of size buffer-size
bytes pointed to by buffer-pointer
.
Return the number of events read.
The header of the event is 12 bytes long: a timestamp (foreign double float) and the length of the MIDI message (foreign uint32).
The MIDI messages are aligned to four bytes.
Write the octets data
of a MIDI message into a Jack MIDI output stream
.
start
and end
are the bounding index designators of data
.
Example:
(defvar *midiout* (jackmidi:open :direction :output)) (defvar *msg0* (make-array 6 :element-type '(unsigned-byte 8) :initial-contents '(#xf0 #x7e #x7f #x09 #x01 #xf7))) (rt-start) (at (now) #'jackmidi:write *midiout* *msg0*) (at (now) #'jackmidi:write *midiout* (jackmidi:data #xf0 #x7e #x7f #x09 #x01 #xf7)) (defvar *msg1* (coerce '(144 60 96 128 60 0) 'jackmidi:data)) (at (now) #'jackmidi:write *midiout* *msg1* :end 3) ; note on (at (now) #'jackmidi:write *midiout* *msg1* :start 3 :end 6) ; note off
Write a MIDI event with the message
of size size
encoded into four
bytes to the Jack MIDI output stream
.
Example:
(defvar *midiout* (jackmidi:open :direction :output)) (rt-start) (at (now) #'jackmidi:write-short *midiout* (jackmidi:message 144 60 96) 3)
Write buffer-size
bytes of a MIDI message stored into a foreign
array pointed to by buffer-pointer
to the Jack MIDI output stream
.
Return the Jack MIDI stream with port-name name
.
Return a new list with the opened Jack MIDI streams.
If direction
is :input
or :output
, return the list of the opened input
or output streams, respectively.
Return the port name of a Jack MIDI stream.
Type designator for a vector of octets.
Return a vector of octets
.
Encode a short MIDI message into four bytes.
Decode a MIDI message encoded into four bytes.
Jack MIDI event buffer type.
Create and return a new event-buffer
structure of size size
(1024 by default).
Deallocate the event-buffer
.
Return t
if the event-buffer
is deallocated.
Bind var
to a newly allocated event-buffer
structure with dynamic
extent during body
.
Iterate over the MIDI events of the event-buffer
structure related
to a Jack MIDI input stream
with message-var
bound to each message.
Then result
form is evaluated.
count-form
is evaluated to get the number of events.
If timestamp-var
is non-NIL, it is the variable bound to the timestamp
of each message.
If the setfable state-form
is t
, start receiving from the Jack MIDI
input stream
with message-var
bound to the received MIDI message.
If timestamp-var
is non-NIL, it is the variable bound to the timestamp
of each message.
Optionally, the receiver thread is named thread-name
.
See also incudine:make-responder
and incudine:recv-start
.
Whether the MIDI message msg
is a SysEx.
Return the length of the MIDI SysEx message stored in the buffer of
the MIDI Jack input stream
.
Return the foreign pointer to the MIDI SysEx message stored in the
buffer of the MIDI Jack input stream
.
Return the timestamp of the MIDI SysEx message stored in the buffer
of the MIDI Jack input stream
.
Return the vector of octets stored in the buffer of the MIDI Jack
input stream
and the MIDI SysEx message size.
Create a new vector if octets
is nil
(default).
start
specifies an offset into octets
and marks the beginning position
of that vector.
Next: PortMidi, Previous: Jack MIDI, Up: Contributed Modules [Contents][Index]
Set the configuration variable *audio-driver*
to enable PortAudio:
;; Add to ~/.incudinerc (setq *audio-driver* :portaudio) (setq *frames-per-buffer* ...) (setq *portaudio-input-device* -1) (setq *portaudio-output-device* -1) ;; Latencies for PortAudio stream: ;; positive value: latency in seconds ;; negative value: the absolute value is the latency in number of periods ;; 0: default latency for interactive performance (setq *portaudio-input-latency* 0) (setq *portaudio-output-latency* 0)
Print the index and name of the audio devices to stream
.
stream
defaults to incudine.util:*logger-stream*
.
Set the index of the audio device.
If input
is non-NIL, the indexes of the output and input devices are
output
and input
respectively.
This setting stops the real-time thread.
See portaudio-device-info
.
Return the input or output latency of the PortAudio stream. Setfable.
direction
is :input
or :output
.
If the value is a positive number, it is the latency in seconds.
If the value is a negative number, the absolute value is the latency in number of periods. For example, -2 is
2 * frames_per_buffer / sample_rate [seconds]
If the value is zero, the latency is the default for interactive performance.
During the performance, the value provides the most accurate estimate of
latency available to the implementation, and a new latency setting is ignored
but stored for the next restart (the next rt-start
after rt-stop
).
Next: Sound editor Snd, Previous: PortAudio, Up: Contributed Modules [Contents][Index]
Set the configuration variable *enable-portmidi-output-sample-offset*
to enable timestamp with sample offset for PortMidi output in real-time
thread. Enabled by default if *audio-driver*
is :portaudio
.
Set the configuration variable *midi-input-timeout*
to specify the
number of milliseconds before to test whether MIDI input is available.
Useful with PortMidi because it does not support a blocking read.
;; Add to ~/.incudinerc (setq *enable-portmidi-output-sample-offset* t) ;; low value = low latency but minor CPU time for the system (setq *midi-input-timeout* 8)
All types of PortMidi error conditions inherit from this condition.
Signaled if an object allocation fails.
Subtype of portmidi-error
and storage-condition
.
Signal a portmidi:allocation-error
for object-type
.
Signaled if there is a generic PortMidi error.
Signal a portmidi:error-generic
.
Reinitialize PortMidi and reopen the streams without to create new lisp objects, so the references and bindings (i.e. from receivers, responders, variables, etc) continue to work.
pm:reinitialize
should be called if portmidi:print-devices-info
doesn’t print recently connected plug-and-play MIDI devices.
PortMidi stream type.
PortMidi input stream type.
Return t
if object is of type portmidi:input-stream
.
PortMidi output stream type.
Return t
if object is of type portmidi:output-stream
.
Return the list of the opened streams.
If direction
is :input
or :output
, return the list of the input or
output streams.
Return the portmidi:stream
with port-name
and direction
.
direction
is :input
or :output
.
Return the foreign pointer to the portmidi:stream
.
Return the port name of the portmidi:stream
.
Return the property list related to the foreign struct
portmidi:device-info
for the device id
.
Print the list of the available MIDI devices.
If direction
is :input
or :output
, print the list of the input or
output devices.
The output stream
defaults to *standard-output*
.
Return the id of the MIDI device port-name
.
direction
is :input
or :output
.
Create and return a new portmidi:stream
.
direction
is :input
(default) or :output
to return a portmidi:input-stream
or a portmidi:output-stream
respectively.
If direction
is :output
, latency
is the delay in milliseconds (1 by default)
applied to timestamps to determine when the output should actually occur.
If latency
is zero, timestamps are ignored.
buffer-size
defaults to portmidi:default-sysex-buffer-size
.
driver-info
is a foreign pointer to an optional driver specific data
structure containing additional information for device setup or handle
processing. driver-info
is a foreign null pointer (default) if not used.
time-proc
is a foreign pointer to a procedure that returns time in
milliseconds. If it is the foreign null pointer (default), a default
millisecond timebase (PortTime) is used.
time-info
is a foreign pointer passed to time-proc
and defaults to
the foreign null pointer.
Whether stream
is an open stream.
Close the PortMidi stream
.
Encode a short MIDI message into four bytes.
Decode a MIDI message encoded into four bytes.
PortMidi event buffer type.
Iterate over the events of a event-buffer
with message-var
bound to each
MIDI message received from the PortMidi input stream
, and execute the body
once for each event, then result
form is evaluated.
If timestamp-var
is non-NIL, it is the variable bound to each MIDI timestamp.
If the setfable state-form
is t
, start receiving from the PortMidi
input stream
with message-var
bound to the received MIDI message.
If timestamp-var
is non-NIL, it is the variable bound to the timestamp
of each message.
sleep-time
(1 by default) is the polling timeout in milliseconds.
Optionally, the receiver thread is named thread-name
.
Create and return a new event-buffer
structure of size size
.
size
defaults to portmidi:default-sysex-buffer-size
.
Bind var
to a newly allocated event-buffer
structure with dynamic
extent during body
.
size
defaults to portmidi:default-sysex-buffer-size
.
Deallocate the event buffer created by make-event-buffer
.
Read the events received from a PortMidi input stream
into an
event-buffer
. Return the number of the events read.
Write length
bytes of the MIDI data stored into an event-buffer
to the PortMidi output stream
.
Whether the MIDI message msg
is a SysEx.
Bind ptr-var
to the foreign pointer to the MIDI SysEx message
received from the PortMidi input stream
with dynamic extent during body
.
Return the vector of octets stored in the buffer of the PortMidi
input stream
and the MIDI SysEx message size.
Create a new vector if octets
is nil
(default).
start
specifies an offset into octets
and marks the beginning position
of that vector.
Return the foreign pointer to the PmEvent that contains the received SysEx message.
Return the number of the events starting from the received SysEx message.
Next: Cudere CLM, Previous: PortMidi, Up: Contributed Modules [Contents][Index]
Interface to interact with Snd.
To load incudine-snd
use asdf:load-system
or require
.
Snd command line program name.
Snd command line argument list.
Full path of the temporary soundfile.
All types of error conditions about the sound editor Snd inherit from this condition.
Start Snd.
The string
with optional format-arguments
is evaluated by Snd.
If output-p
is t
(default), return the output of Snd.
Load the scheme file
in Snd.
The optional string s7-env-string
is the s7 environment.
Terminate the Snd process started by run
.
Flush anything waiting on the Snd stream.
Close the Snd stream.
Return t
to enable the interaction through the Emacs’ Snd-Scheme mode.
Setfable.
It requires slime-enable-evaluate-in-emacs
t
on the Emacs side.
Enable the reader syntax used to format and eval s7 forms.
Example:
#s7(let ((snd (open-sound "foo.wav"))) (play snd :wait #t)) ;; => "(let ((snd (open-sound \"foo.wav\"))) (play snd :wait #t))" #s7(quote #.(LOOP REPEAT 8 COLLECT (RANDOM 1.0))) ;; => "(quote ;; (0.5520501 0.4115485 0.35940528 0.0056368113 0.31019592 ;; 0.4214077 0.32522345 0.2879219))" (format nil #s7(new-sound "/tmp/foo.wav" :channels 1 :size ~D) (floor incudine.util:*sample-rate*)) ;; => "(new-sound \"/tmp/foo.wav\" :channels 1 :size 48000)" (snd:eval *) ; => (SOUND 0) #snd(...) is equivalent to (snd:eval #s7(...)) #0snd(...) is equivalent to (snd:eval #s7(...) :output-p nil) hidden side effect: #7s is equivalent to #s7 (defstruct point x y) #s(point) ;; => #S(POINT :X NIL :Y NIL)
If no sound is found that matches the soundfile file
, open that
file in Snd. Otherwise, update the sound.
Mix the file
in Snd by applying the Snd function mix
to the arguments
.
Suppress output if output-p
is nil
.
Define a float-vector in Snd named fvec-name
initialized with the
content of a incudine:buffer
structure, a list, a vector or end
minus
start
values generated by a gen
routine.
The sequence is optionally bounded by start
and end
.
Create a new incudine:buffer
structure by loading the sound
id-or-filename
.
buffer-load-args
are the optional arguments for incudine:buffer-load
.
Create a new incudine:buffer
structure by loading the current selection.
buffer-load-args
are the optional arguments for incudine:buffer-load
.
Create a new incudine:buffer
structure by loading the region region-id
.
buffer-load-args
are the optional arguments for incudine:buffer-load
.
Create a new incudine:buffer
structure by loading the mix mix-id
.
buffer-load-args
are the optional arguments for incudine:buffer-load
.
Create a new incudine:buffer
structure by loading the float-vector
fvec-string
.
buffer-load-args
are the optional arguments for incudine:buffer-load
.
The content of a incudine:buffer
structure is saved in the soundfile file
and opened in Snd.
buffer-save-args
are the arguments for incudine:buffer-save
.
The content of a incudine:buffer
structure is mixed in Snd.
If the first argument in args
is a list, it has the arguments for the
Snd function mix
(file is optional). The rest of the arguments are
passed to incudine:buffer-save
.
Apply function
to each sample of the channel chn
in snd
(id or
filename), starting at sample beg
for dur
samples, replacing the
current value with whatever function
returns.
function
is a procedure of one argument (the current sample), can
return nil
, which means that the data passed in is deleted (replaced by
nothing), or a number which replaces the current sample, or t
which
halts the mapping operation, leaving trailing samples unaffected, or a
sequence the contents of which are spliced into the edited version,
effectively replacing the current sample with any number of samples.
The utility incudine:now
called from function
returns the current
local time.
beg
defaults to 0 and dur
defaults to the full length of the sound.
snd
and chn
default to the currently selected sound.
edpos
defaults to the current edit history position.
See map-channel in Snd.
Apply the amplitude envelope env
, an incudine:envelope
structure,
to the given channel chn
of snd
starting at sample beg
for dur
samples.
beg
defaults to 0 and dur
defaults to the full length of the sound.
snd
and chn
default to the currently selected sound.
edpos
defaults to the current edit history position.
See env-channel in Snd.
Apply the amplitude envelope env
, an incudine:envelope
structure,
to the selection.
See env-selection in Snd.
Apply bounce-to-disk
to outfile
and the arguments args
, then open
outfile
in Snd.
Apply bounce-to-disk
to outfile
and the arguments args
, then mix
outfile
in Snd by calling mix
.
If the first argument in args
is a list, it has the arguments for the
Snd function mix
(without file). The rest of the arguments are passed
to bounce-to-disk
.
Example:
(dsp! hello-snd (c i a o) (stereo (+ (sine c i) (sine a o)))) (bounce-to-snd-mix ("mix-1.wav" '(48000 t)) (hello-snd 1000 .2 1220 .1))
Next: Fluidsynth, Previous: Sound editor Snd, Up: Contributed Modules [Contents][Index]
Incudine version of Bill Schottstaedt’s CLM 2
ftp://ccrma-ftp.stanford.edu/pub/Lisp/clm-5.tar.gz
The original common lisp version uses the run
macro to translate
lisp code in efficient C code. There is a minimal mechanism in
cudere-clm to read and convert
(run (loop ... do (declare ...)) ...)
in “efficient” lisp code (it depends on the body of the loop).
It works with v.ins
, jcrev.ins
, prc-toolkit95.lisp
, and other
instruments with unambiguous types (if it fails, you generally have
to fix some coercions).
However, the run
macro is unnecessary to define new instruments
because they are compiled in lisp (definstrument
also works from REPL).
The new variable *clm-optimize-settings*
is
(optimize speed (safety 0))
by default but it is also possible to write an explicit declaration
after definstrument
or definstrument*
to change that default.
We can set some configuration variables in cudere-clm/clm-init.lisp (ignored by git), for example:
;;; incudine/contrib/cudere-clm/clm-init.lisp (in-package :clm) (setq *clm-file-name* "/tmp/test.wav") (setq *clm-player* "sndplay") ;(setq *clm-player* "sndplay -start ~A -end ~A")
If incudine-snd
is loaded and Snd is started with snd:run
, the sound
file generated by
(with-sound (:to-snd t) ...) ; :to-snd is *to-snd* by default
is automatically opened (the keyword :to-snd
is also used in the
original Snd+CLM).
To load cudere-clm
use asdf:load-system
or require
.
Next: Constants, Up: Cudere CLM [Contents][Index]
Next: Variables, Previous: Conditions, Up: Cudere CLM [Contents][Index]
Next: Definitions, Previous: Constants, Up: Cudere CLM [Contents][Index]
Next: Methods, Previous: Variables, Up: Cudere CLM [Contents][Index]
Next: Utilities, Previous: Definitions, Up: Cudere CLM [Contents][Index]
Next: FFT, Previous: Methods, Up: Cudere CLM [Contents][Index]
Next: Common Music interface, Previous: Utilities, Up: Cudere CLM [Contents][Index]
Next: Generators, Previous: FFT, Up: Cudere CLM [Contents][Index]
Next: Sound I/O, Previous: Common Music interface, Up: Cudere CLM [Contents][Index]
Next: Score, Previous: Generators, Up: Cudere CLM [Contents][Index]
Next: UGens, Previous: Sound I/O, Up: Cudere CLM [Contents][Index]
Previous: Score, Up: Cudere CLM [Contents][Index]
Next: LADSPA plugin, Previous: Cudere CLM, Up: Contributed Modules [Contents][Index]
FluidSynth SoundFont synthesizer interface for Incudine.
To load incudine-fluidsynth
use asdf:load-system
or require
.
Next: Settings, Up: Fluidsynth [Contents][Index]
Next: Synth, Previous: Logging, Up: Fluidsynth [Contents][Index]
Next: MIDI channel messages, Previous: Settings, Up: Fluidsynth [Contents][Index]
Next: SoundFont management, Previous: Synth, Up: Fluidsynth [Contents][Index]
Next: Reverb, Previous: MIDI channel messages, Up: Fluidsynth [Contents][Index]
Next: Chorus, Previous: SoundFont management, Up: Fluidsynth [Contents][Index]
Next: Audio and MIDI channels, Previous: Reverb, Up: Fluidsynth [Contents][Index]
Next: Synthesis parameters, Previous: Chorus, Up: Fluidsynth [Contents][Index]
Next: Tuning, Previous: Audio and MIDI channels, Up: Fluidsynth [Contents][Index]
Next: Misc, Previous: Synthesis parameters, Up: Fluidsynth [Contents][Index]
Next: Synthesizer plugin, Previous: Tuning, Up: Fluidsynth [Contents][Index]
Next: Synthesizer’s interface to handle SoundFont loaders, Previous: Misc, Up: Fluidsynth [Contents][Index]
Previous: Synthesizer plugin, Up: Fluidsynth [Contents][Index]
Next: LV2 plugin, Previous: Fluidsynth, Up: Contributed Modules [Contents][Index]
LADSPA audio plugin interface for Incudine.
To load incudine-ladspa
use asdf:load-system
or require
.
Define a new VUG and the auxiliary function named vug-name
to use
the LADSPA plugin with label
loaded from filename
.
filename
is the namestring of the plugin path, absolute or relative to
ladspa:*ladspa-path*
, with or without type extension.
The control parameter plugin-instance
is set to the plugin instance
during the DSP initialization. It is possible to retrieve the plugin
instance through control-value
. This functionality works only with a
VUG or an inlined UGEN.
All the arguments of the auxiliary function are optional keywords.
If block-size
is not set and the incudine block size changes,
ladspa->vug
should be called again.
If debug-p
is t
, return the lisp form to define the VUG.
Return the new VUG structure.
Example with block size 1:
(set-rt-block-size 1) (ladspa->vug "caps" "Plate" plate-reverb) (dsp! plate-reverb-test (trig-freq input-decay input-scale bw tail damping blend) (with-samples ((in (* (decay (impulse trig-freq) input-decay) (white-noise input-scale)))) ;; PLATE-REVERB returns a frame because there are two outputs. (multiple-sample-bind (l r) (plate-reverb bw tail damping blend in) (out l r))))
Another example with block size greater than 1:
(set-rt-block-size 64) (ladspa->vug "caps" "Plate" plate-reverb) ;; Test with a UGEN. (compile-vug 'plate-reverb 'pointer) (define-vug rev-input ((in pointer)) "Read a block of audio samples from the first Incudine input port." (foreach-frame (setf (f32-ref in current-frame) (coerce (audio-in 0) 'single-float)))) (define-vug rev-output ((out pointer)) "Write two blocks of audio samples to two Incudine output ports." (foreach-frame (out (f32-ref (ptr-ref out 0) current-frame) (f32-ref (ptr-ref out 1) current-frame)))) (dsp! rev-test (bw tail damping blend) (with ((in (make-f32-array (block-size))) (out (cffi:null-pointer))) (declare (pointer out)) (rev-input in) (setf out (plate-reverb bw tail damping blend in)) (rev-output out))) (rev-test .75 .5 .25 .25 :id 8) (set-controls 8 :tail .8 :dumping .1 :blend .5) (free 8)
The alternative is to set a specific block size for the plugin, for example:
(ladspa->vug "cmt" "freeverb3" %freeverb :block-size 64) (define-vug freeverb (input room-size damping wet dry width) (:defaults 0 .5 .5 .3 .7 .5) (with ((inL (make-f32-array 64 :zero-p t)) (inR (make-f32-array 64 :zero-p t)) (out (cffi:null-pointer)) (i 63)) (declare (type pointer out) (type fixnum i)) (foreach-tick (when (= i 63) (setf out (%freeverb inL inR 0 room-size damping wet dry width))) (setf i (logand (1+ i) 63))) (maybe-expand input) (cond ((= current-channel 0) (setf (f32-ref inL i) (coerce input 'single-float))) ((= current-channel 1) (setf (f32-ref inR i) (coerce input 'single-float)))) (if (< current-channel 2) (sample (f32-ref (ptr-ref out current-channel) i)) +sample-zero+))) (dsp! reverb-test ((buf buffer) amp room-size damping wet dry width) (:defaults (incudine-missing-arg "Missing buffer.") 1 .5 .5 .3 .7 .5) (foreach-frame (foreach-channel (cout (* amp (freeverb (buffer-play buf) room-size damping wet dry width)))))) (defvar *buf* (buffer-load "/path/to/soundfile.wav")) (set-rt-block-size 256) (rt-start) (reverb-test *buf* .5 :wet .8) (free 0) (set-rt-block-size 1)
Previous: LADSPA plugin, Up: Contributed Modules [Contents][Index]
LV2 audio plugin interface for Incudine.
To load incudine-lv2
use asdf:load-system
or require
.
Define a new VUG and the auxiliary function named vug-name
to use
the LV2 plugin with uri
.
Initialize the Lilv World if necessary.
The control parameter plugin-instance
is set to the plugin instance
during the DSP initialization. It is possible to retrieve the plugin
instance through control-value
. This functionality works only with a
VUG or an inlined UGEN.
If control-arguments-p
is t
(default), all the LV2 controls are
optional keywords of the auxiliary function. If the LV2 plugin provides
many control ports, lv2->vug
fails with a “Control stack exhausted”
error. In this case, set control-arguments-p
to nil
, retrieve the plugin
instance via control-value
and use vug-foreign:plugin-port-pointer
out
of the DSP.
If the incudine block size changes, lv2->vug
should be called again.
If debug-p
is t
, return the lisp form to define the VUG.
Return the new VUG structure.
Example of a LV2 effect:
(lv2->vug "http://plugin.org.uk/swh-plugins/amp" swh.amp) (dsp! amp-test (gain) (out (swh.amp gain (white-noise))))
Example of a LV2 instrument:
(set-rt-block-size 64) (lv2->vug SYNTH-TEST-URI synth-test) ;; Note: the control parameter PLUGIN could be of type T for simplicity. (dsp! lv2-synth-test ((plugin (or null vug-foreign:plugin-instance))) (:defaults nil) (with ((out (cffi:null-pointer))) (declare (type pointer out)) ;; If the instrument has many control ports, we can use ;; VUG-FOREIGN:PLUGIN-PORT-POINTER out of the DSP. (setf out (synth-test :plugin-instance plugin)) (foreach-frame ;; Plugin with a single audio output port. (stereo (sample (f32-ref out current-frame))) ;; Plugin with multiple audio output ports, for example two: ;; (out (sample (f32-ref (ptr-ref out 0) current-frame)) ;; (sample (f32-ref (ptr-ref out 1) current-frame)))))) (rt-start) (lv2-synth-test :id 123) (defvar *synth-test* (control-value 123 'plugin)) *synth-test* ;; => #<LV2-PLUGIN-INSTANCE ...> (defvar *midiin* (jackmidi:open)) (make-responder *midiin* (lambda (st d1 d2) (lv2:write-event *synth-test* (lv2:midi-message st d1 d2)))) (recv-start *midiin*) (defun set-lv2-control (plugin port-index value) ;; Change the port value in rt-thread. (rt-eval () (setf (f32-ref (vug-foreign:plugin-port-pointer plugin port-index)) (coerce value 'single-float))) value) ;; Read the Turtle description of plugin /path/to/SYNTH-TEST.ttl ;; or run the command lv2info to know the port indices. (set-lv2-control *synth-test* PORT-INDEX 0.1) (f32-ref (vug-foreign:plugin-port-pointer *synth-test* PORT-INDEX)) ;; => 0.1 ;; We can set more port values from nrt-thread with a single ;; memory barrier or CAS. (rt-eval () (set-lv2-control ...) (set-lv2-control ...) ...)
Send an event through an Atom port of a LV2 plugin
. The buffer type
of the Atom port is Atom Sequence.
data
is a short MIDI message encoded into four bytes or a vector of
octets where start
and end
are the optional bounding index designators.
If the plugin has more than one input event port, index
is the array
index of the input event ports.
The event type
is a URID (an integer) obtained from lv2:uri-to-id
.
It is a MIDI event by default.
Return a MIDI message encoded for lv2:write-event
.
Send a bulk tuning dump message as a LV2 MIDI message. It obviously
works if the LV2 synthesizer supports it. The new frequencies are
related to a tuning
structure.
If the plugin has more than one input event port, event-index
is the
array index of the input event ports.
If single-note-tuning-p
is non-NIL, send 128 single note tuning change
messages instead.
The optional checksum-function
requires two arguments: the foreign
buffer containing the MIDI SysEx message and the buffer size in bytes.
It is useful if the manufacturer implements a different checksum.
event-index
, device-id
and program
default to 0.
Get the numeric identifier of a Uniform Resource Identifier, a string that identifies a resource.
Get the Uniform Resource Identifier for a mapped numeric id
obtained from lv2:uri-to-id
.
Example:
(lv2:uri-to-id "http://lv2plug.in/ns/ext/midi#MidiEvent") ;; => 62 (lv2:id-to-uri 62) ;; => "http://lv2plug.in/ns/ext/midi#MidiEvent"
Numeric identifier of http://lv2plug.in/ns/ext/midi#MidiEvent.
Return the NULL-terminated foreign array of LV2 Features supported by Incudine. The foreign array is allocated during the initialization of the Lilv World.
Initialize the Lilv World that represents all Lilv state.
Bind var
to a newly allocated Lilv node of type
with dynamic extent
during body
.
type
is one of :bool
, :float
, :int
, :string
or :uri
.
Create bindings to newly allocated Lilv nodes with dynamic extent
during body
.
bindings
is a list of lists
(var type value)
where var
is the variable bound to a node of type
.
type
is one of :bool
, :float
, :int
, :string
or :uri
.
Iterate over the plugin-classes
with var
bound to each class.
lilv:plugin-class-loop
supports keywords-and-forms
of the loop
macro.
Iterate over the scale-points
with var
bound to each point.
lilv:scale-point-loop
supports keywords-and-forms
of the loop
macro.
Iterate over the uis
with var
bound to each ui
.
lilv:ui-loop
supports keywords-and-forms
of the loop
macro.
Iterate over the nodes
with var
bound to each node.
lilv:node-loop
supports keywords-and-forms
of the loop
macro.
Example:
(lilv:node-loop (n lilv-nodes) if (lilv:node-is-uri n) collect (lilv:node-as-uri n))
Iterate over the plugins
with var
bound to each plugin.
lilv:plugin-loop
supports keywords-and-forms
of the loop
macro.
Example:
(lilv:init-world) (lilv:plugin-loop (p (lilv:world-get-all-plugins lilv:*world*)) collect (lilv:node-as-uri (lilv:plugin-get-uri p)))
Previous: Contributed Modules, Up: The Incudine dictionary [Contents][Index]
Next: Incudine Rego Mode, Up: Emacs Modes [Contents][Index]
The major mode for editing incudine code.
Hook called when a buffer enters Incudine mode.
incudine-scratch
)Switch to Incudine scratch buffer.
incudine-show-repl
)Show REPL in other window.
incudine-repl-clear-buffer
)Clear the REPL buffer.
incudine-rt-start
)Start the real-time thread.
With a positive argument n
, set the new block size to n
before starting.
incudine-rt-stop
)Stop the real-time thread.
incudine-scheduled-events
)Print the number of the scheduled events.
incudine-peak-info
)Display the peak info of a channel (0 by default).
With a non negative argument, display the peak info of that channel.
With a negative argument, reset the meters.
incudine-xruns-info
)Display the number of the occurred xruns and the time in samples of the last xrun.
With a non-NIL argument, set the number of xruns to zero.
incudine-free-node
)Stop to play a node of the graph.
With a negative argument, call incudine:stop
instead of incudine:free
.
With zero argument (default), call incudine:flush-pending
before
incudine:free
.
incudine-pause-node
)Pause node.
With a numeric argument ’n’, pause the node with identifier ’n’.
incudine-unpause-node
)Unpause node.
With a numeric argument ’n’, unpause the node with identifier ’n’.
incudine-live-nodes
)Print the number of the live nodes.
incudine-dump-graph
)Print informations about the graph of nodes.
With a numeric argument ’n’, print info about the group with identifier ’n’.
Type g
in *incudine-node-tree*
buffer to update it.
incudine-gc
)Initiate a garbage collection.
incudine-bytes-consed-in
)Rough estimate of the bytes consed in time
seconds.
incudine-rt-memory-free-size
)Display the free realtime memory.
If the form at point starts with dsp!
or define-ugen
, prompt the
arguments and display the generated code.
Set the logger level to :error
.
Set the logger level to :warn
.
Set the logger level to :info
.
Set the logger level to :debug
.
Set the logger stream to *error-output*
.
Set the logger stream to *standard-output*
.
Set the logger stream to *debug-io*
.
Log messages without timestamp.
Log messages with timestamp in seconds.
Log messages with timestamp in samples.
Eval the function and jump to the next defun.
Eval the function and jump to the previous defun.
Evaluate the current toplevel form.
Jump at the end of the previous defun.
With a numeric argument, do it that many times.
Jump at the end of the next defun.
With a numeric argument, do it that many times.
If the current buffer is not a file buffer, evaluate sexp before point and print value into the current buffer.
If the current buffer is not a file buffer, evaluate sexp before point, save point and print value into the current buffer.
Next: Org Mode, Previous: Incudine Mode, Up: Emacs Modes [Contents][Index]
Major mode for editing incudine rego files.
Incudine rego mode is a derivative of Org mode.
Hook called when a buffer enters Incudine Rego mode.
incudine-regofile-to-function
)Define the function to interpret the edited rego file.
With a C-u
prefix, prompt the function name.
The score statement :score-function-name:
or
:score-local-function-name:
is an alternative method to
set the function name.
incudine-play-regofile
)Eval the edited rego file and schedule the obtained events.
Display the list of events obtained from the edited rego file.
Display the scheduled events obtained from the edited rego file.
Display the expansion of the edited rego file.
If the current line is an include
statement, edit the included
file name, otherwise edit a lisp definition or call find-tag
.
Goto the location of the parent rego file or call tags-loop-continue
.
Next: SES Mode, Previous: Incudine Rego Mode, Up: Emacs Modes [Contents][Index]
Code blocks in Incudine are supported. For example,
(require 'ob-incudine)
enables the execution of Incudine code blocks.
If the tangle
header argument is yes
, the extension of the tangled
file is “cudo”.
The syntax of the function call arguments in Org is
argA=value, argB=value, ...
If we forget this rule and something stops to work, we can use the
interactive function load-incudine-rego-library
to reload the code blocks.
Process the current rego file or the rego-filename
passed as argument.
By default output-filename
is derived from the rego filename with
extension “wav”.
See incudine:bounce-to-disk
for the other defaults.
Example:
;;; test.rego #+begin_src incudine :results silent (dsp! smart-pulses (freq amp (nh fixnum)) (out (buzz freq amp nh))) #+end_src #+call: bounce-to-disk(channels=1, duration=4, sample-rate=44100) #+call: bounce-to-disk(channels=1, header-type="au", data-format="double") #+call: bounce-to-disk(output-filename="break-engine-gen.wav", rego-filename="buonassera-ciccio-systems.rego") #+call: bounce-to-disk(rego-filename="various-systems.rego") | 0 | smart-pulses | 650/3 | .30 | 7 | | 0 | smart-pulses | 5200/3 | .45 | 11 |
If incudine-snd
is loaded and Snd is started with snd:run
, process
the current rego file or the rego-filename
passed as argument, then
open output-filename
in Snd.
By default output-filename
is derived from the rego filename with
extension “wav”.
Previous: Org Mode, Up: Emacs Modes [Contents][Index]
It is possible to create and edit a rego file in SES (Simple Emacs Spreadsheet) mode, because the form feed character marks the beginning of the data area of a SES file and the end of a rego file.
Next: Function Index, Previous: The Incudine dictionary, Up: Incudine [Contents][Index]
Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. https://fsf.org/ Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
The purpose of this License is to make a manual, textbook, or other functional and useful document “free” in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it, with or without modifying it, either commercially or noncommercially. Secondarily, this License preserves for the author and publisher a way to get credit for their work, while not being considered responsible for modifications made by others.
This License is a kind of “copyleft”, which means that derivative works of the document must themselves be free in the same sense. It complements the GNU General Public License, which is a copyleft license designed for free software.
We have designed this License in order to use it for manuals for free software, because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. But this License is not limited to software manuals; it can be used for any textual work, regardless of subject matter or whether it is published as a printed book. We recommend this License principally for works whose purpose is instruction or reference.
This License applies to any manual or other work, in any medium, that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. Such a notice grants a world-wide, royalty-free license, unlimited in duration, to use that work under the conditions stated herein. The “Document”, below, refers to any such manual or work. Any member of the public is a licensee, and is addressed as “you”. You accept the license if you copy, modify or distribute the work in a way requiring permission under copyright law.
A “Modified Version” of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modifications and/or translated into another language.
A “Secondary Section” is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document’s overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. (Thus, if the Document is in part a textbook of mathematics, a Secondary Section may not explain any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them.
The “Invariant Sections” are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice that says that the Document is released under this License. If a section does not fit the above definition of Secondary then it is not allowed to be designated as Invariant. The Document may contain zero Invariant Sections. If the Document does not identify any Invariant Sections then there are none.
The “Cover Texts” are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that the Document is released under this License. A Front-Cover Text may be at most 5 words, and a Back-Cover Text may be at most 25 words.
A “Transparent” copy of the Document means a machine-readable copy, represented in a format whose specification is available to the general public, that is suitable for revising the document straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file format whose markup, or absence of markup, has been arranged to thwart or discourage subsequent modification by readers is not Transparent. An image format is not Transparent if used for any substantial amount of text. A copy that is not “Transparent” is called “Opaque”.
Examples of suitable formats for Transparent copies include plain ASCII without markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming simple HTML, PostScript or PDF designed for human modification. Examples of transparent image formats include PNG, XCF and JPG. Opaque formats include proprietary formats that can be read and edited only by proprietary word processors, SGML or XML for which the DTD and/or processing tools are not generally available, and the machine-generated HTML, PostScript or PDF produced by some word processors for output purposes only.
The “Title Page” means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material this License requires to appear in the title page. For works in formats which do not have any title page as such, “Title Page” means the text near the most prominent appearance of the work’s title, preceding the beginning of the body of the text.
The “publisher” means any person or entity that distributes copies of the Document to the public.
A section “Entitled XYZ” means a named subunit of the Document whose title either is precisely XYZ or contains XYZ in parentheses following text that translates XYZ in another language. (Here XYZ stands for a specific section name mentioned below, such as “Acknowledgements”, “Dedications”, “Endorsements”, or “History”.) To “Preserve the Title” of such a section when you modify the Document means that it remains a section “Entitled XYZ” according to this definition.
The Document may include Warranty Disclaimers next to the notice which states that this License applies to the Document. These Warranty Disclaimers are considered to be included by reference in this License, but only as regards disclaiming warranties: any other implication that these Warranty Disclaimers may have is void and has no effect on the meaning of this License.
You may copy and distribute the Document in any medium, either commercially or noncommercially, provided that this License, the copyright notices, and the license notice saying this License applies to the Document are reproduced in all copies, and that you add no other conditions whatsoever to those of this License. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. However, you may accept compensation in exchange for copies. If you distribute a large enough number of copies you must also follow the conditions in section 3.
You may also lend copies, under the same conditions stated above, and you may publicly display copies.
If you publish printed copies (or copies in media that commonly have printed covers) of the Document, numbering more than 100, and the Document’s license notice requires Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present the full title with all words of the title equally prominent and visible. You may add other material on the covers in addition. Copying with changes limited to the covers, as long as they preserve the title of the Document and satisfy these conditions, can be treated as verbatim copying in other respects.
If the required texts for either cover are too voluminous to fit legibly, you should put the first ones listed (as many as fit reasonably) on the actual cover, and continue the rest onto adjacent pages.
If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy a computer-network location from which the general network-using public has access to download using public-standard network protocols a complete Transparent copy of the Document, free of added material. If you use the latter option, you must take reasonably prudent steps, when you begin distribution of Opaque copies in quantity, to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public.
It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document.
You may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above, provided that you release the Modified Version under precisely this License, with the Modified Version filling the role of the Document, thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. In addition, you must do these things in the Modified Version:
If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modified Version’s license notice. These titles must be distinct from any other section titles.
You may add a section Entitled “Endorsements”, provided it contains nothing but endorsements of your Modified Version by various parties—for example, statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard.
You may add a passage of up to five words as a Front-Cover Text, and a passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. If the Document already includes a cover text for the same cover, previously added by you or by arrangement made by the same entity you are acting on behalf of, you may not add another; but you may replace the old one, on explicit permission from the previous publisher that added the old one.
The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version.
You may combine the Document with other documents released under this License, under the terms defined in section 4 above for modified versions, provided that you include in the combination all of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant Sections of your combined work in its license notice, and that you preserve all their Warranty Disclaimers.
The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be replaced with a single copy. If there are multiple Invariant Sections with the same name but different contents, make the title of each such section unique by adding at the end of it, in parentheses, the name of the original author or publisher of that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work.
In the combination, you must combine any sections Entitled “History” in the various original documents, forming one section Entitled “History”; likewise combine any sections Entitled “Acknowledgements”, and any sections Entitled “Dedications”. You must delete all sections Entitled “Endorsements”.
You may make a collection consisting of the Document and other documents released under this License, and replace the individual copies of this License in the various documents with a single copy that is included in the collection, provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects.
You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted document, and follow this License in all other respects regarding verbatim copying of that document.
A compilation of the Document or its derivatives with other separate and independent documents or works, in or on a volume of a storage or distribution medium, is called an “aggregate” if the copyright resulting from the compilation is not used to limit the legal rights of the compilation’s users beyond what the individual works permit. When the Document is included in an aggregate, this License does not apply to the other works in the aggregate which are not themselves derivative works of the Document.
If the Cover Text requirement of section 3 is applicable to these copies of the Document, then if the Document is less than one half of the entire aggregate, the Document’s Cover Texts may be placed on covers that bracket the Document within the aggregate, or the electronic equivalent of covers if the Document is in electronic form. Otherwise they must appear on printed covers that bracket the whole aggregate.
Translation is considered a kind of modification, so you may distribute translations of the Document under the terms of section 4. Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a translation of this License, and all the license notices in the Document, and any Warranty Disclaimers, provided that you also include the original English version of this License and the original versions of those notices and disclaimers. In case of a disagreement between the translation and the original version of this License or a notice or disclaimer, the original version will prevail.
If a section in the Document is Entitled “Acknowledgements”, “Dedications”, or “History”, the requirement (section 4) to Preserve its Title (section 1) will typically require changing the actual title.
You may not copy, modify, sublicense, or distribute the Document except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, or distribute it is void, and will automatically terminate your rights under this License.
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, receipt of a copy of some or all of the same material does not give you any rights to use it.
The Free Software Foundation may publish new, revised versions of the GNU Free Documentation License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. See https://www.gnu.org/licenses/.
Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this License “or any later version” applies to it, you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation. If the Document specifies that a proxy can decide which future versions of this License can be used, that proxy’s public statement of acceptance of a version permanently authorizes you to choose that version for the Document.
“Massive Multiauthor Collaboration Site” (or “MMC Site”) means any World Wide Web server that publishes copyrightable works and also provides prominent facilities for anybody to edit those works. A public wiki that anybody can edit is an example of such a server. A “Massive Multiauthor Collaboration” (or “MMC”) contained in the site means any set of copyrightable works thus published on the MMC site.
“CC-BY-SA” means the Creative Commons Attribution-Share Alike 3.0 license published by Creative Commons Corporation, a not-for-profit corporation with a principal place of business in San Francisco, California, as well as future copyleft versions of that license published by that same organization.
“Incorporate” means to publish or republish a Document, in whole or in part, as part of another Document.
An MMC is “eligible for relicensing” if it is licensed under this License, and if all works that were first published under this License somewhere other than this MMC, and subsequently incorporated in whole or in part into the MMC, (1) had no cover texts or invariant sections, and (2) were thus incorporated prior to November 1, 2008.
The operator of an MMC Site may republish an MMC contained in the site under CC-BY-SA on the same site at any time before August 1, 2009, provided the MMC is eligible for relicensing.
Next: Variable Index, Previous: GNU Free Documentation License, Up: Incudine [Contents][Index]
Jump to: | A B C D E F G H I J K L M N O P Q R S T U V W |
---|
Jump to: | A B C D E F G H I J K L M N O P Q R S T U V W |
---|
Previous: Function Index, Up: Incudine [Contents][Index]
Jump to: | *
A C F I L N O P S V |
---|
Jump to: | *
A C F I L N O P S V |
---|
The text of the doc-string in defun*
is copied/edited from
the s7.html file provided with the source code:
ftp://ccrma-ftp.stanford.edu/pub/Lisp/s7.tar.gz
The sound editor Snd includes the recommended version of CLM actively maintained and enhanced by the original author Bill Schottstaedt.