1,831 changes: 1,831 additions & 0 deletions include/lilv/lilv.h

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions include/lilv_config.h
@@ -0,0 +1,40 @@
#ifndef _LILV_CONFIG_H_
#define _LILV_CONFIG_H_

#define LILV_INTERNAL

#define HAVE_FILENO 1
#define SERD_VERSION "0.23.0"
#define HAVE_SERD 1
#define SORD_VERSION "0.15.1"
#define HAVE_SORD 1
#define SRATOM_VERSION "0.4.10"
#define HAVE_SRATOM 1

#define HAVE_CLOCK_GETTIME 1
#define LILV_VERSION "0.22.1"

#ifdef __WIN32__
# define LILV_PATH_SEP ";"
# define LILV_DIR_SEP "\\"
#else
# define LILV_PATH_SEP ":"
# define LILV_DIR_SEP "/"
# define HAVE_FLOCK 1
#endif

#if defined(__APPLE__)
# define LILV_DEFAULT_LV2_PATH "~/.lv2:~/Library/Audio/Plug-Ins/LV2:/Library/Audio/Plug-Ins/LV2"
#elif defined(__HAIKU__)
# define HAVE_POSIX_MEMALIGN 1
# define LILV_DEFAULT_LV2_PATH "~/.lv2:/boot/common/add-ons/lv2"
#elif defined(__WIN32__)
//# define LILV_DEFAULT_LV2_PATH "%APPDATA%\\LV2;%COMMONPROGRAMFILES%\\LV2;%CommonProgramFiles(x86)%\\LV2"
# define LILV_DEFAULT_LV2_PATH "%APPDATA%\\LV2;%COMMONPROGRAMFILES%\\LV2"
#else
# define LILV_DEFAULT_LV2_PATH "~/.lv2:/usr/lib/lv2:/usr/local/lib/lv2"
# define HAVE_POSIX_MEMALIGN 1
# define HAVE_POSIX_FADVISE 1
#endif

#endif /* _LILV_CONFIG_H_ */
254 changes: 254 additions & 0 deletions include/lv2/lv2plug.in/ns/ext/atom/atom.h
@@ -0,0 +1,254 @@
/*
Copyright 2008-2014 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/**
@defgroup atom Atom
A generic value container and several data types, see
<http://lv2plug.in/ns/ext/atom> for details.
@{
*/

#ifndef LV2_ATOM_H
#define LV2_ATOM_H

#include <stdint.h>
#include <stddef.h>

#define LV2_ATOM_URI "http://lv2plug.in/ns/ext/atom"
#define LV2_ATOM_PREFIX LV2_ATOM_URI "#"

#define LV2_ATOM__Atom LV2_ATOM_PREFIX "Atom"
#define LV2_ATOM__AtomPort LV2_ATOM_PREFIX "AtomPort"
#define LV2_ATOM__Blank LV2_ATOM_PREFIX "Blank"
#define LV2_ATOM__Bool LV2_ATOM_PREFIX "Bool"
#define LV2_ATOM__Chunk LV2_ATOM_PREFIX "Chunk"
#define LV2_ATOM__Double LV2_ATOM_PREFIX "Double"
#define LV2_ATOM__Event LV2_ATOM_PREFIX "Event"
#define LV2_ATOM__Float LV2_ATOM_PREFIX "Float"
#define LV2_ATOM__Int LV2_ATOM_PREFIX "Int"
#define LV2_ATOM__Literal LV2_ATOM_PREFIX "Literal"
#define LV2_ATOM__Long LV2_ATOM_PREFIX "Long"
#define LV2_ATOM__Number LV2_ATOM_PREFIX "Number"
#define LV2_ATOM__Object LV2_ATOM_PREFIX "Object"
#define LV2_ATOM__Path LV2_ATOM_PREFIX "Path"
#define LV2_ATOM__Property LV2_ATOM_PREFIX "Property"
#define LV2_ATOM__Resource LV2_ATOM_PREFIX "Resource"
#define LV2_ATOM__Sequence LV2_ATOM_PREFIX "Sequence"
#define LV2_ATOM__Sound LV2_ATOM_PREFIX "Sound"
#define LV2_ATOM__String LV2_ATOM_PREFIX "String"
#define LV2_ATOM__Tuple LV2_ATOM_PREFIX "Tuple"
#define LV2_ATOM__URI LV2_ATOM_PREFIX "URI"
#define LV2_ATOM__URID LV2_ATOM_PREFIX "URID"
#define LV2_ATOM__Vector LV2_ATOM_PREFIX "Vector"
#define LV2_ATOM__atomTransfer LV2_ATOM_PREFIX "atomTransfer"
#define LV2_ATOM__beatTime LV2_ATOM_PREFIX "beatTime"
#define LV2_ATOM__bufferType LV2_ATOM_PREFIX "bufferType"
#define LV2_ATOM__childType LV2_ATOM_PREFIX "childType"
#define LV2_ATOM__eventTransfer LV2_ATOM_PREFIX "eventTransfer"
#define LV2_ATOM__frameTime LV2_ATOM_PREFIX "frameTime"
#define LV2_ATOM__supports LV2_ATOM_PREFIX "supports"
#define LV2_ATOM__timeUnit LV2_ATOM_PREFIX "timeUnit"

#define LV2_ATOM_REFERENCE_TYPE 0

#ifdef __cplusplus
extern "C" {
#endif

/** This expression will fail to compile if double does not fit in 64 bits. */
typedef char lv2_atom_assert_double_fits_in_64_bits[
((sizeof(double) <= sizeof(uint64_t)) * 2) - 1];

/**
Return a pointer to the contents of an Atom. The "contents" of an atom
is the data past the complete type-specific header.
@param type The type of the atom, e.g. LV2_Atom_String.
@param atom A variable-sized atom.
*/
#define LV2_ATOM_CONTENTS(type, atom) \
((void*)((uint8_t*)(atom) + sizeof(type)))

/**
Const version of LV2_ATOM_CONTENTS.
*/
#define LV2_ATOM_CONTENTS_CONST(type, atom) \
((const void*)((const uint8_t*)(atom) + sizeof(type)))

/**
Return a pointer to the body of an Atom. The "body" of an atom is the
data just past the LV2_Atom head (i.e. the same offset for all types).
*/
#define LV2_ATOM_BODY(atom) LV2_ATOM_CONTENTS(LV2_Atom, atom)

/**
Const version of LV2_ATOM_BODY.
*/
#define LV2_ATOM_BODY_CONST(atom) LV2_ATOM_CONTENTS_CONST(LV2_Atom, atom)

/** The header of an atom:Atom. */
typedef struct {
uint32_t size; /**< Size in bytes, not including type and size. */
uint32_t type; /**< Type of this atom (mapped URI). */
} LV2_Atom;

/** An atom:Int or atom:Bool. May be cast to LV2_Atom. */
typedef struct {
LV2_Atom atom; /**< Atom header. */
int32_t body; /**< Integer value. */
} LV2_Atom_Int;

/** An atom:Long. May be cast to LV2_Atom. */
typedef struct {
LV2_Atom atom; /**< Atom header. */
int64_t body; /**< Integer value. */
} LV2_Atom_Long;

/** An atom:Float. May be cast to LV2_Atom. */
typedef struct {
LV2_Atom atom; /**< Atom header. */
float body; /**< Floating point value. */
} LV2_Atom_Float;

/** An atom:Double. May be cast to LV2_Atom. */
typedef struct {
LV2_Atom atom; /**< Atom header. */
double body; /**< Floating point value. */
} LV2_Atom_Double;

/** An atom:Bool. May be cast to LV2_Atom. */
typedef LV2_Atom_Int LV2_Atom_Bool;

/** An atom:URID. May be cast to LV2_Atom. */
typedef struct {
LV2_Atom atom; /**< Atom header. */
uint32_t body; /**< URID. */
} LV2_Atom_URID;

/** An atom:String. May be cast to LV2_Atom. */
typedef struct {
LV2_Atom atom; /**< Atom header. */
/* Contents (a null-terminated UTF-8 string) follow here. */
} LV2_Atom_String;

/** The body of an atom:Literal. */
typedef struct {
uint32_t datatype; /**< Datatype URID. */
uint32_t lang; /**< Language URID. */
/* Contents (a null-terminated UTF-8 string) follow here. */
} LV2_Atom_Literal_Body;

/** An atom:Literal. May be cast to LV2_Atom. */
typedef struct {
LV2_Atom atom; /**< Atom header. */
LV2_Atom_Literal_Body body; /**< Body. */
} LV2_Atom_Literal;

/** An atom:Tuple. May be cast to LV2_Atom. */
typedef struct {
LV2_Atom atom; /**< Atom header. */
/* Contents (a series of complete atoms) follow here. */
} LV2_Atom_Tuple;

/** The body of an atom:Vector. */
typedef struct {
uint32_t child_size; /**< The size of each element in the vector. */
uint32_t child_type; /**< The type of each element in the vector. */
/* Contents (a series of packed atom bodies) follow here. */
} LV2_Atom_Vector_Body;

/** An atom:Vector. May be cast to LV2_Atom. */
typedef struct {
LV2_Atom atom; /**< Atom header. */
LV2_Atom_Vector_Body body; /**< Body. */
} LV2_Atom_Vector;

/** The body of an atom:Property (e.g. in an atom:Object). */
typedef struct {
uint32_t key; /**< Key (predicate) (mapped URI). */
uint32_t context; /**< Context URID (may be, and generally is, 0). */
LV2_Atom value; /**< Value atom header. */
/* Value atom body follows here. */
} LV2_Atom_Property_Body;

/** An atom:Property. May be cast to LV2_Atom. */
typedef struct {
LV2_Atom atom; /**< Atom header. */
LV2_Atom_Property_Body body; /**< Body. */
} LV2_Atom_Property;

/** The body of an atom:Object. May be cast to LV2_Atom. */
typedef struct {
uint32_t id; /**< URID, or 0 for blank. */
uint32_t otype; /**< Type URID (same as rdf:type, for fast dispatch). */
/* Contents (a series of property bodies) follow here. */
} LV2_Atom_Object_Body;

/** An atom:Object. May be cast to LV2_Atom. */
typedef struct {
LV2_Atom atom; /**< Atom header. */
LV2_Atom_Object_Body body; /**< Body. */
} LV2_Atom_Object;

/** The header of an atom:Event. Note this type is NOT an LV2_Atom. */
typedef struct {
/** Time stamp. Which type is valid is determined by context. */
union {
int64_t frames; /**< Time in audio frames. */
double beats; /**< Time in beats. */
} time;
LV2_Atom body; /**< Event body atom header. */
/* Body atom contents follow here. */
} LV2_Atom_Event;

/**
The body of an atom:Sequence (a sequence of events).
The unit field is either a URID that described an appropriate time stamp
type, or may be 0 where a default stamp type is known. For
LV2_Descriptor::run(), the default stamp type is audio frames.
The contents of a sequence is a series of LV2_Atom_Event, each aligned
to 64-bits, e.g.:
<pre>
| Event 1 (size 6) | Event 2
| | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|FRAMES |SUBFRMS|TYPE |SIZE |DATADATADATAPAD|FRAMES |SUBFRMS|...
</pre>
*/
typedef struct {
uint32_t unit; /**< URID of unit of event time stamps. */
uint32_t pad; /**< Currently unused. */
/* Contents (a series of events) follow here. */
} LV2_Atom_Sequence_Body;

/** An atom:Sequence. */
typedef struct {
LV2_Atom atom; /**< Atom header. */
LV2_Atom_Sequence_Body body; /**< Body. */
} LV2_Atom_Sequence;

/**
@}
*/

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /* LV2_ATOM_H */
709 changes: 709 additions & 0 deletions include/lv2/lv2plug.in/ns/ext/atom/forge.h

Large diffs are not rendered by default.

453 changes: 453 additions & 0 deletions include/lv2/lv2plug.in/ns/ext/atom/util.h

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions include/lv2/lv2plug.in/ns/ext/buf-size/buf-size.h
@@ -0,0 +1,44 @@
/*
Copyright 2007-2012 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#ifndef LV2_BUF_SIZE_H
#define LV2_BUF_SIZE_H

/**
@defgroup buf-size Buffer Size
Access to, and restrictions on, buffer sizes; see
<http://lv2plug.in/ns/ext/buf-size> for details.
@{
*/

#define LV2_BUF_SIZE_URI "http://lv2plug.in/ns/ext/buf-size"
#define LV2_BUF_SIZE_PREFIX LV2_BUF_SIZE_URI "#"

#define LV2_BUF_SIZE__boundedBlockLength LV2_BUF_SIZE_PREFIX "boundedBlockLength"
#define LV2_BUF_SIZE__fixedBlockLength LV2_BUF_SIZE_PREFIX "fixedBlockLength"
#define LV2_BUF_SIZE__maxBlockLength LV2_BUF_SIZE_PREFIX "maxBlockLength"
#define LV2_BUF_SIZE__minBlockLength LV2_BUF_SIZE_PREFIX "minBlockLength"
#define LV2_BUF_SIZE__nominalBlockLength LV2_BUF_SIZE_PREFIX "nominalBlockLength"
#define LV2_BUF_SIZE__powerOf2BlockLength LV2_BUF_SIZE_PREFIX "powerOf2BlockLength"
#define LV2_BUF_SIZE__sequenceSize LV2_BUF_SIZE_PREFIX "sequenceSize"

/**
@}
*/

#endif /* LV2_BUF_SIZE_H */
67 changes: 67 additions & 0 deletions include/lv2/lv2plug.in/ns/ext/data-access/data-access.h
@@ -0,0 +1,67 @@
/*
LV2 Data Access Extension
Copyright 2008-2011 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/**
@defgroup data-access Data Access
Access to plugin extension_data() for UIs, see
<http://lv2plug.in/ns/ext/data-acess> for details.
@{
*/

#ifndef LV2_DATA_ACCESS_H
#define LV2_DATA_ACCESS_H

#define LV2_DATA_ACCESS_URI "http://lv2plug.in/ns/ext/data-access"

#ifdef __cplusplus
extern "C" {
#endif

/**
The data field of the LV2_Feature for this extension.
To support this feature the host must pass an LV2_Feature struct to the
instantiate method with URI "http://lv2plug.in/ns/ext/data-access"
and data pointed to an instance of this struct.
*/
typedef struct {
/**
A pointer to a method the UI can call to get data (of a type specified
by some other extension) from the plugin.
This call never is never guaranteed to return anything, UIs should
degrade gracefully if direct access to the plugin data is not possible
(in which case this function will return NULL).
This is for access to large data that can only possibly work if the UI
and plugin are running in the same process. For all other things, use
the normal LV2 UI communication system.
*/
const void* (*data_access)(const char* uri);
} LV2_Extension_Data_Feature;

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /* LV2_DATA_ACCESS_H */

/**
@}
*/
150 changes: 150 additions & 0 deletions include/lv2/lv2plug.in/ns/ext/dynmanifest/dynmanifest.h
@@ -0,0 +1,150 @@
/*
Dynamic manifest specification for LV2
Copyright 2008-2011 Stefano D'Angelo <zanga.mail@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/**
@defgroup dynmanifest Dynamic Manifest
Support for dynamic data generation, see
<http://lv2plug.in/ns/ext/dynmanifest> for details.
@{
*/

#ifndef LV2_DYN_MANIFEST_H_INCLUDED
#define LV2_DYN_MANIFEST_H_INCLUDED

#include <stdio.h>

#include "lv2/lv2plug.in/ns/lv2core/lv2.h"

#define LV2_DYN_MANIFEST_URI "http://lv2plug.in/ns/ext/dynmanifest"

#ifdef __cplusplus
extern "C" {
#endif

/**
Dynamic manifest generator handle.
This handle indicates a particular status of a dynamic manifest generator.
The host MUST NOT attempt to interpret it and, unlikely LV2_Handle, it is
NOT even valid to compare this to NULL. The dynamic manifest generator MAY
use it to reference internal data.
*/
typedef void * LV2_Dyn_Manifest_Handle;

/**
Generate the dynamic manifest.
@param handle Pointer to an uninitialized dynamic manifest generator handle.
@param features NULL terminated array of LV2_Feature structs which represent
the features the host supports. The dynamic manifest generator may refuse to
(re)generate the dynamic manifest if required features are not found here
(however hosts SHOULD NOT use this as a discovery mechanism, instead of
reading the static manifest file). This array must always exist; if a host
has no features, it MUST pass a single element array containing NULL.
@return 0 on success, otherwise a non-zero error code. The host SHOULD
evaluate the result of the operation by examining the returned value and
MUST NOT try to interpret the value of handle.
*/
int lv2_dyn_manifest_open(LV2_Dyn_Manifest_Handle * handle,
const LV2_Feature *const * features);

/**
Fetch a "list" of subject URIs described in the dynamic manifest.
The dynamic manifest generator has to fill the resource only with the needed
triples to make the host aware of the "objects" it wants to expose. For
example, if the plugin library exposes a regular LV2 plugin, it should
output only a triple like the following:
<http://www.example.com/plugin/uri> a lv2:Plugin .
The objects that are elegible for exposure are those that would need to be
represented by a subject node in a static manifest.
@param handle Dynamic manifest generator handle.
@param fp FILE * identifying the resource the host has to set up for the
dynamic manifest generator. The host MUST pass a writable, empty resource to
this function, and the dynamic manifest generator MUST ONLY perform write
operations on it at the end of the stream (e.g., using only fprintf(),
fwrite() and similar).
@return 0 on success, otherwise a non-zero error code.
*/
int lv2_dyn_manifest_get_subjects(LV2_Dyn_Manifest_Handle handle,
FILE * fp);

/**
Function that fetches data related to a specific URI.
The dynamic manifest generator has to fill the resource with data related to
object represented by the given URI. For example, if the library exposes a
regular LV2 plugin whose URI, as retrieved by the host using
lv2_dyn_manifest_get_subjects() is http://www.example.com/plugin/uri, it
should output something like:
<pre>
<http://www.example.com/plugin/uri>
a lv2:Plugin ;
doap:name "My Plugin" ;
lv2:binary <mylib.so> ;
etc:etc "..." .
</pre>
@param handle Dynamic manifest generator handle.
@param fp FILE * identifying the resource the host has to set up for the
dynamic manifest generator. The host MUST pass a writable resource to this
function, and the dynamic manifest generator MUST ONLY perform write
operations on it at the current position of the stream (e.g. using only
fprintf(), fwrite() and similar).
@param uri URI to get data about (in the "plain" form, i.e., absolute URI
without Turtle prefixes).
@return 0 on success, otherwise a non-zero error code.
*/
int lv2_dyn_manifest_get_data(LV2_Dyn_Manifest_Handle handle,
FILE * fp,
const char * uri);

/**
Function that ends the operations on the dynamic manifest generator.
This function SHOULD be used by the dynamic manifest generator to perform
cleanup operations, etc.
Once this function is called, referring to handle will cause undefined
behavior.
@param handle Dynamic manifest generator handle.
*/
void lv2_dyn_manifest_close(LV2_Dyn_Manifest_Handle handle);

#ifdef __cplusplus
}
#endif

#endif /* LV2_DYN_MANIFEST_H_INCLUDED */

/**
@}
*/
265 changes: 265 additions & 0 deletions include/lv2/lv2plug.in/ns/ext/event/event-helpers.h
@@ -0,0 +1,265 @@
/*
Copyright 2008-2014 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/**
@file event-helpers.h Helper functions for the LV2 Event extension
<http://lv2plug.in/ns/ext/event>.
*/

#ifndef LV2_EVENT_HELPERS_H
#define LV2_EVENT_HELPERS_H

#include <stdint.h>
#include <stdlib.h>
#include <string.h>

#include "lv2/lv2plug.in/ns/ext/event/event.h"

#ifdef __cplusplus
extern "C" {
#else
# include <stdbool.h>
#endif

/** @file
* Helper functions for the LV2 Event extension
* <http://lv2plug.in/ns/ext/event>.
*
* These functions are provided for convenience only, use of them is not
* required for supporting lv2ev (i.e. the events extension is defined by the
* raw buffer format described in lv2_event.h and NOT by this API).
*
* Note that these functions are all static inline which basically means:
* do not take the address of these functions. */


/** Pad a size to 64 bits (for event sizes) */
static inline uint16_t
lv2_event_pad_size(uint16_t size)
{
return (uint16_t)(size + 7U) & (uint16_t)(~7U);
}


/** Initialize (empty, reset..) an existing event buffer.
* The contents of buf are ignored entirely and overwritten, except capacity
* which is unmodified. */
static inline void
lv2_event_buffer_reset(LV2_Event_Buffer* buf,
uint16_t stamp_type,
uint8_t* data)
{
buf->data = data;
buf->header_size = sizeof(LV2_Event_Buffer);
buf->stamp_type = stamp_type;
buf->event_count = 0;
buf->size = 0;
}


/** Allocate a new, empty event buffer. */
static inline LV2_Event_Buffer*
lv2_event_buffer_new(uint32_t capacity, uint16_t stamp_type)
{
const size_t size = sizeof(LV2_Event_Buffer) + capacity;
LV2_Event_Buffer* buf = (LV2_Event_Buffer*)malloc(size);
if (buf != NULL) {
buf->capacity = capacity;
lv2_event_buffer_reset(buf, stamp_type, (uint8_t *)(buf + 1));
return buf;
} else {
return NULL;
}
}


/** An iterator over an LV2_Event_Buffer.
*
* Multiple simultaneous read iterators over a single buffer is fine,
* but changing the buffer invalidates all iterators (e.g. RW Lock). */
typedef struct {
LV2_Event_Buffer* buf;
uint32_t offset;
} LV2_Event_Iterator;


/** Reset an iterator to point to the start of `buf`.
* @return True if `iter` is valid, otherwise false (buffer is empty) */
static inline bool
lv2_event_begin(LV2_Event_Iterator* iter,
LV2_Event_Buffer* buf)
{
iter->buf = buf;
iter->offset = 0;
return (buf->size > 0);
}


/** Check if `iter` is valid.
* @return True if `iter` is valid, otherwise false (past end of buffer) */
static inline bool
lv2_event_is_valid(LV2_Event_Iterator* iter)
{
return (iter->buf && (iter->offset < iter->buf->size));
}


/** Advance `iter` forward one event.
* `iter` must be valid.
* @return True if `iter` is valid, otherwise false (reached end of buffer) */
static inline bool
lv2_event_increment(LV2_Event_Iterator* iter)
{
if (!lv2_event_is_valid(iter)) {
return false;
}

LV2_Event* const ev = (LV2_Event*)(
(uint8_t*)iter->buf->data + iter->offset);

iter->offset += lv2_event_pad_size(
(uint16_t)((uint16_t)sizeof(LV2_Event) + ev->size));

return true;
}


/** Dereference an event iterator (get the event currently pointed at).
* `iter` must be valid.
* `data` if non-NULL, will be set to point to the contents of the event
* returned.
* @return A Pointer to the event `iter` is currently pointing at, or NULL
* if the end of the buffer is reached (in which case `data` is
* also set to NULL). */
static inline LV2_Event*
lv2_event_get(LV2_Event_Iterator* iter,
uint8_t** data)
{
if (!lv2_event_is_valid(iter)) {
return NULL;
}

LV2_Event* const ev = (LV2_Event*)(
(uint8_t*)iter->buf->data + iter->offset);

if (data)
*data = (uint8_t*)ev + sizeof(LV2_Event);

return ev;
}


/** Write an event at `iter`.
* The event (if any) pointed to by `iter` will be overwritten, and `iter`
* incremented to point to the following event (i.e. several calls to this
* function can be done in sequence without twiddling iter in-between).
* @return True if event was written, otherwise false (buffer is full). */
static inline bool
lv2_event_write(LV2_Event_Iterator* iter,
uint32_t frames,
uint32_t subframes,
uint16_t type,
uint16_t size,
const uint8_t* data)
{
if (!iter->buf)
return false;

if (iter->buf->capacity - iter->buf->size < sizeof(LV2_Event) + size)
return false;

LV2_Event* const ev = (LV2_Event*)(
(uint8_t*)iter->buf->data + iter->offset);

ev->frames = frames;
ev->subframes = subframes;
ev->type = type;
ev->size = size;
memcpy((uint8_t*)ev + sizeof(LV2_Event), data, size);
++iter->buf->event_count;

size = lv2_event_pad_size((uint16_t)(sizeof(LV2_Event) + size));
iter->buf->size += size;
iter->offset += size;

return true;
}


/** Reserve space for an event in the buffer and return a pointer to
the memory where the caller can write the event data, or NULL if there
is not enough room in the buffer. */
static inline uint8_t*
lv2_event_reserve(LV2_Event_Iterator* iter,
uint32_t frames,
uint32_t subframes,
uint16_t type,
uint16_t size)
{
const uint16_t total_size = (uint16_t)(sizeof(LV2_Event) + size);
if (iter->buf->capacity - iter->buf->size < total_size)
return NULL;

LV2_Event* const ev = (LV2_Event*)(
(uint8_t*)iter->buf->data + iter->offset);

ev->frames = frames;
ev->subframes = subframes;
ev->type = type;
ev->size = size;
++iter->buf->event_count;

const uint16_t padded_size = lv2_event_pad_size(total_size);
iter->buf->size += padded_size;
iter->offset += padded_size;

return (uint8_t*)ev + sizeof(LV2_Event);
}


/** Write an event at `iter`.
* The event (if any) pointed to by `iter` will be overwritten, and `iter`
* incremented to point to the following event (i.e. several calls to this
* function can be done in sequence without twiddling iter in-between).
* @return True if event was written, otherwise false (buffer is full). */
static inline bool
lv2_event_write_event(LV2_Event_Iterator* iter,
const LV2_Event* ev,
const uint8_t* data)
{
const uint16_t total_size = (uint16_t)(sizeof(LV2_Event) + ev->size);
if (iter->buf->capacity - iter->buf->size < total_size)
return false;

LV2_Event* const write_ev = (LV2_Event*)(
(uint8_t*)iter->buf->data + iter->offset);

*write_ev = *ev;
memcpy((uint8_t*)write_ev + sizeof(LV2_Event), data, ev->size);
++iter->buf->event_count;

const uint16_t padded_size = lv2_event_pad_size(total_size);
iter->buf->size += padded_size;
iter->offset += padded_size;

return true;
}

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /* LV2_EVENT_HELPERS_H */
292 changes: 292 additions & 0 deletions include/lv2/lv2plug.in/ns/ext/event/event.h
@@ -0,0 +1,292 @@
/*
Copyright 2008-2011 David Robillard <http://drobilla.net>
Copyright 2006-2007 Lars Luthman <lars.luthman@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/**
@defgroup event Event
Generic time-stamped events, see <http://lv2plug.in/ns/ext/event> for
details.
@{
*/

#ifndef LV2_EVENT_H
#define LV2_EVENT_H

#define LV2_EVENT_URI "http://lv2plug.in/ns/ext/event"
#define LV2_EVENT_PREFIX LV2_EVENT_URI "#"

#define LV2_EVENT__Event LV2_EVENT_PREFIX "Event"
#define LV2_EVENT__EventPort LV2_EVENT_PREFIX "EventPort"
#define LV2_EVENT__FrameStamp LV2_EVENT_PREFIX "FrameStamp"
#define LV2_EVENT__TimeStamp LV2_EVENT_PREFIX "TimeStamp"
#define LV2_EVENT__generatesTimeStamp LV2_EVENT_PREFIX "generatesTimeStamp"
#define LV2_EVENT__generic LV2_EVENT_PREFIX "generic"
#define LV2_EVENT__inheritsEvent LV2_EVENT_PREFIX "inheritsEvent"
#define LV2_EVENT__inheritsTimeStamp LV2_EVENT_PREFIX "inheritsTimeStamp"
#define LV2_EVENT__supportsEvent LV2_EVENT_PREFIX "supportsEvent"
#define LV2_EVENT__supportsTimeStamp LV2_EVENT_PREFIX "supportsTimeStamp"

#define LV2_EVENT_AUDIO_STAMP 0

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
The best Pulses Per Quarter Note for tempo-based uint32_t timestamps.
Equal to 2^12 * 5 * 7 * 9 * 11 * 13 * 17, which is evenly divisble
by all integers from 1 through 18 inclusive, and powers of 2 up to 2^12.
*/
static const uint32_t LV2_EVENT_PPQN = 3136573440U;

/**
An LV2 event (header only).
LV2 events are generic time-stamped containers for any type of event.
The type field defines the format of a given event's contents.
This struct defines the header of an LV2 event. An LV2 event is a single
chunk of POD (plain old data), usually contained in a flat buffer (see
LV2_EventBuffer below). Unless a required feature says otherwise, hosts may
assume a deep copy of an LV2 event can be created safely using a simple:
memcpy(ev_copy, ev, sizeof(LV2_Event) + ev->size); (or equivalent)
*/
typedef struct {
/**
The frames portion of timestamp. The units used here can optionally be
set for a port (with the lv2ev:timeUnits property), otherwise this is
audio frames, corresponding to the sample_count parameter of the LV2 run
method (e.g. frame 0 is the first frame for that call to run).
*/
uint32_t frames;

/**
The sub-frames portion of timestamp. The units used here can optionally
be set for a port (with the lv2ev:timeUnits property), otherwise this is
1/(2^32) of an audio frame.
*/
uint32_t subframes;

/**
The type of this event, as a number which represents some URI
defining an event type. This value MUST be some value previously
returned from a call to the uri_to_id function defined in the LV2
URI map extension (see lv2_uri_map.h).
There are special rules which must be followed depending on the type
of an event. If the plugin recognizes an event type, the definition
of that event type will describe how to interpret the event, and
any required behaviour. Otherwise, if the type is 0, this event is a
non-POD event and lv2_event_unref MUST be called if the event is
'dropped' (see above). Even if the plugin does not understand an event,
it may pass the event through to an output by simply copying (and NOT
calling lv2_event_unref). These rules are designed to allow for generic
event handling plugins and large non-POD events, but with minimal hassle
on simple plugins that "don't care" about these more advanced features.
*/
uint16_t type;

/**
The size of the data portion of this event in bytes, which immediately
follows. The header size (12 bytes) is not included in this value.
*/
uint16_t size;

/* size bytes of data follow here */
} LV2_Event;


/**
A buffer of LV2 events (header only).
Like events (which this contains) an event buffer is a single chunk of POD:
the entire buffer (including contents) can be copied with a single memcpy.
The first contained event begins sizeof(LV2_EventBuffer) bytes after the
start of this struct.
After this header, the buffer contains an event header (defined by struct
LV2_Event), followed by that event's contents (padded to 64 bits), followed
by another header, etc:
| | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | |
|FRAMES |SUBFRMS|TYP|LEN|DATA..DATA..PAD|FRAMES | ...
*/
typedef struct {
/**
The contents of the event buffer. This may or may not reside in the
same block of memory as this header, plugins must not assume either.
The host guarantees this points to at least capacity bytes of allocated
memory (though only size bytes of that are valid events).
*/
uint8_t* data;

/**
The size of this event header in bytes (including everything).
This is to allow for extending this header in the future without
breaking binary compatibility. Whenever this header is copied,
it MUST be done using this field (and NOT the sizeof this struct).
*/
uint16_t header_size;

/**
The type of the time stamps for events in this buffer.
As a special exception, '0' always means audio frames and subframes
(1/UINT32_MAX'th of a frame) in the sample rate passed to instantiate.
INPUTS: The host must set this field to the numeric ID of some URI
defining the meaning of the frames/subframes fields of contained events
(obtained by the LV2 URI Map uri_to_id function with the URI of this
extension as the 'map' argument, see lv2_uri_map.h). The host must
never pass a plugin a buffer which uses a stamp type the plugin does not
'understand'. The value of this field must never change, except when
connect_port is called on the input port, at which time the host MUST
have set the stamp_type field to the value that will be used for all
subsequent run calls.
OUTPUTS: The plugin may set this to any value that has been returned
from uri_to_id with the URI of this extension for a 'map' argument.
When connected to a buffer with connect_port, output ports MUST set this
field to the type of time stamp they will be writing. On any call to
connect_port on an event input port, the plugin may change this field on
any output port, it is the responsibility of the host to check if any of
these values have changed and act accordingly.
*/
uint16_t stamp_type;

/**
The number of events in this buffer.
INPUTS: The host must set this field to the number of events contained
in the data buffer before calling run(). The plugin must not change
this field.
OUTPUTS: The plugin must set this field to the number of events it has
written to the buffer before returning from run(). Any initial value
should be ignored by the plugin.
*/
uint32_t event_count;

/**
The size of the data buffer in bytes.
This is set by the host and must not be changed by the plugin.
The host is allowed to change this between run() calls.
*/
uint32_t capacity;

/**
The size of the initial portion of the data buffer containing data.
INPUTS: The host must set this field to the number of bytes used
by all events it has written to the buffer (including headers)
before calling the plugin's run().
The plugin must not change this field.
OUTPUTS: The plugin must set this field to the number of bytes
used by all events it has written to the buffer (including headers)
before returning from run().
Any initial value should be ignored by the plugin.
*/
uint32_t size;
} LV2_Event_Buffer;


/**
Opaque pointer to host data.
*/
typedef void* LV2_Event_Callback_Data;


/**
Non-POD events feature.
To support this feature the host must pass an LV2_Feature struct to the
plugin's instantiate method with URI "http://lv2plug.in/ns/ext/event"
and data pointed to an instance of this struct. Note this feature
is not mandatory to support the event extension.
*/
typedef struct {
/**
Opaque pointer to host data.
The plugin MUST pass this to any call to functions in this struct.
Otherwise, it must not be interpreted in any way.
*/
LV2_Event_Callback_Data callback_data;

/**
Take a reference to a non-POD event.
If a plugin receives an event with type 0, it means the event is a
pointer to some object in memory and not a flat sequence of bytes
in the buffer. When receiving a non-POD event, the plugin already
has an implicit reference to the event. If the event is stored AND
passed to an output, lv2_event_ref MUST be called on that event.
If the event is only stored OR passed through, this is not necessary
(as the plugin already has 1 implicit reference).
@param event An event received at an input that will not be copied to
an output or stored in any way.
@param context The calling context. Like event types, this is a mapped
URI, see lv2_context.h. Simple plugin with just a run() method should
pass 0 here (the ID of the 'standard' LV2 run context). The host
guarantees that this function is realtime safe iff the context is
realtime safe.
PLUGINS THAT VIOLATE THESE RULES MAY CAUSE CRASHES AND MEMORY LEAKS.
*/
uint32_t (*lv2_event_ref)(LV2_Event_Callback_Data callback_data,
LV2_Event* event);

/**
Drop a reference to a non-POD event.
If a plugin receives an event with type 0, it means the event is a
pointer to some object in memory and not a flat sequence of bytes
in the buffer. If the plugin does not pass the event through to
an output or store it internally somehow, it MUST call this function
on the event (more information on using non-POD events below).
@param event An event received at an input that will not be copied to an
output or stored in any way.
@param context The calling context. Like event types, this is a mapped
URI, see lv2_context.h. Simple plugin with just a run() method should
pass 0 here (the ID of the 'standard' LV2 run context). The host
guarantees that this function is realtime safe iff the context is
realtime safe.
PLUGINS THAT VIOLATE THESE RULES MAY CAUSE CRASHES AND MEMORY LEAKS.
*/
uint32_t (*lv2_event_unref)(LV2_Event_Callback_Data callback_data,
LV2_Event* event);
} LV2_Event_Feature;

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /* LV2_EVENT_H */

/**
@}
*/
36 changes: 36 additions & 0 deletions include/lv2/lv2plug.in/ns/ext/instance-access/instance-access.h
@@ -0,0 +1,36 @@
/*
LV2 Instance Access Extension
Copyright 2008-2012 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/**
@defgroup instance-access Instance Access
Access to the LV2_Handle of a plugin for UIs; see
<http://lv2plug.in/ns/ext/instance-access> for details.
@{
*/

#ifndef LV2_INSTANCE_ACCESS_H
#define LV2_INSTANCE_ACCESS_H

#define LV2_INSTANCE_ACCESS_URI "http://lv2plug.in/ns/ext/instance-access"

#endif /* LV2_INSTANCE_ACCESS_H */

/**
@}
*/
107 changes: 107 additions & 0 deletions include/lv2/lv2plug.in/ns/ext/log/log.h
@@ -0,0 +1,107 @@
/*
Copyright 2012 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/**
@defgroup log Log
Interface for plugins to log via the host; see
<http://lv2plug.in/ns/ext/log> for details.
@{
*/

#ifndef LV2_LOG_H
#define LV2_LOG_H

#define LV2_LOG_URI "http://lv2plug.in/ns/ext/log"
#define LV2_LOG_PREFIX LV2_LOG_URI "#"

#define LV2_LOG__Entry LV2_LOG_PREFIX "Entry"
#define LV2_LOG__Error LV2_LOG_PREFIX "Error"
#define LV2_LOG__Note LV2_LOG_PREFIX "Note"
#define LV2_LOG__Trace LV2_LOG_PREFIX "Trace"
#define LV2_LOG__Warning LV2_LOG_PREFIX "Warning"
#define LV2_LOG__log LV2_LOG_PREFIX "log"

#include <stdarg.h>

#include "lv2/lv2plug.in/ns/ext/urid/urid.h"

#ifdef __cplusplus
extern "C" {
#endif

#ifdef __GNUC__
/** Allow type checking of printf-like functions. */
# define LV2_LOG_FUNC(fmt, arg1) __attribute__((format(printf, fmt, arg1)))
#else
# define LV2_LOG_FUNC(fmt, arg1)
#endif

/**
Opaque data to host data for LV2_Log_Log.
*/
typedef void* LV2_Log_Handle;

/**
Log feature (LV2_LOG__log)
*/
typedef struct _LV2_Log {
/**
Opaque pointer to host data.
This MUST be passed to methods in this struct whenever they are called.
Otherwise, it must not be interpreted in any way.
*/
LV2_Log_Handle handle;

/**
Log a message, passing format parameters directly.
The API of this function matches that of the standard C printf function,
except for the addition of the first two parameters. This function may
be called from any non-realtime context, or from any context if `type`
is @ref LV2_LOG__Trace.
*/
LV2_LOG_FUNC(3, 4)
int (*printf)(LV2_Log_Handle handle,
LV2_URID type,
const char* fmt, ...);

/**
Log a message, passing format parameters in a va_list.
The API of this function matches that of the standard C vprintf
function, except for the addition of the first two parameters. This
function may be called from any non-realtime context, or from any
context if `type` is @ref LV2_LOG__Trace.
*/
LV2_LOG_FUNC(3, 0)
int (*vprintf)(LV2_Log_Handle handle,
LV2_URID type,
const char* fmt,
va_list ap);
} LV2_Log_Log;

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /* LV2_LOG_H */

/**
@}
*/
160 changes: 160 additions & 0 deletions include/lv2/lv2plug.in/ns/ext/log/logger.h
@@ -0,0 +1,160 @@
/*
Copyright 2012-2013 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/**
@defgroup logger Logger
@ingroup log
Convenience API for easy logging in plugin code. This API provides simple
wrappers for logging from a plugin, which automatically fall back to
printing to stderr if host support is unavailabe.
@{
*/

#ifndef LV2_ATOM_LOGGER_H
#define LV2_ATOM_LOGGER_H

#include <stdio.h>
#include <string.h>

#include "lv2/lv2plug.in/ns/ext/log/log.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
Logger convenience API state.
*/
typedef struct {
LV2_Log_Log* log;

LV2_URID Error;
LV2_URID Note;
LV2_URID Trace;
LV2_URID Warning;
} LV2_Log_Logger;

/**
Set `map` as the URI map for `logger`.
This affects the message type URIDs (Error, Warning, etc) which are passed
to the log's print functions.
*/
static inline void
lv2_log_logger_set_map(LV2_Log_Logger* logger, LV2_URID_Map* map)
{
if (map) {
logger->Error = map->map(map->handle, LV2_LOG__Error);
logger->Note = map->map(map->handle, LV2_LOG__Note);
logger->Trace = map->map(map->handle, LV2_LOG__Trace);
logger->Warning = map->map(map->handle, LV2_LOG__Warning);
} else {
logger->Error = logger->Note = logger->Trace = logger->Warning = 0;
}
}

/**
Initialise `logger`.
URIs will be mapped using `map` and stored, a reference to `map` itself is
not held. Both `map` and `log` may be NULL when unsupported by the host,
in which case the implementation will fall back to printing to stderr.
*/
static inline void
lv2_log_logger_init(LV2_Log_Logger* logger,
LV2_URID_Map* map,
LV2_Log_Log* log)
{
logger->log = log;
lv2_log_logger_set_map(logger, map);
}

/**
Log a message to the host, or stderr if support is unavailable.
*/
LV2_LOG_FUNC(3, 0)
static inline int
lv2_log_vprintf(LV2_Log_Logger* logger,
LV2_URID type,
const char* fmt,
va_list args)
{
if (logger && logger->log) {
return logger->log->vprintf(logger->log->handle, type, fmt, args);
} else {
return vfprintf(stderr, fmt, args);
}
}

/** Log an error via lv2_log_vprintf(). */
LV2_LOG_FUNC(2, 3)
static inline int
lv2_log_error(LV2_Log_Logger* logger, const char* fmt, ...)
{
va_list args;
va_start(args, fmt);
const int ret = lv2_log_vprintf(logger, logger->Error, fmt, args);
va_end(args);
return ret;
}

/** Log a note via lv2_log_vprintf(). */
LV2_LOG_FUNC(2, 3)
static inline int
lv2_log_note(LV2_Log_Logger* logger, const char* fmt, ...)
{
va_list args;
va_start(args, fmt);
const int ret = lv2_log_vprintf(logger, logger->Note, fmt, args);
va_end(args);
return ret;
}

/** Log a trace via lv2_log_vprintf(). */
LV2_LOG_FUNC(2, 3)
static inline int
lv2_log_trace(LV2_Log_Logger* logger, const char* fmt, ...)
{
va_list args;
va_start(args, fmt);
const int ret = lv2_log_vprintf(logger, logger->Trace, fmt, args);
va_end(args);
return ret;
}

/** Log a warning via lv2_log_vprintf(). */
LV2_LOG_FUNC(2, 3)
static inline int
lv2_log_warning(LV2_Log_Logger* logger, const char* fmt, ...)
{
va_list args;
va_start(args, fmt);
const int ret = lv2_log_vprintf(logger, logger->Warning, fmt, args);
va_end(args);
return ret;
}

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /* LV2_LOG_LOGGER_H */

/**
@}
*/
232 changes: 232 additions & 0 deletions include/lv2/lv2plug.in/ns/ext/midi/midi.h
@@ -0,0 +1,232 @@
/*
Copyright 2012 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/**
@defgroup midi MIDI
Definitions of standard MIDI messages, see <http://lv2plug.in/ns/ext/midi>
for details.
*/

#ifndef LV2_MIDI_H
#define LV2_MIDI_H

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#else
# include <stdbool.h>
#endif

#define LV2_MIDI_URI "http://lv2plug.in/ns/ext/midi"
#define LV2_MIDI_PREFIX LV2_MIDI_URI "#"

#define LV2_MIDI__ActiveSense LV2_MIDI_PREFIX "ActiveSense"
#define LV2_MIDI__Aftertouch LV2_MIDI_PREFIX "Aftertouch"
#define LV2_MIDI__Bender LV2_MIDI_PREFIX "Bender"
#define LV2_MIDI__ChannelPressure LV2_MIDI_PREFIX "ChannelPressure"
#define LV2_MIDI__Chunk LV2_MIDI_PREFIX "Chunk"
#define LV2_MIDI__Clock LV2_MIDI_PREFIX "Clock"
#define LV2_MIDI__Continue LV2_MIDI_PREFIX "Continue"
#define LV2_MIDI__Controller LV2_MIDI_PREFIX "Controller"
#define LV2_MIDI__MidiEvent LV2_MIDI_PREFIX "MidiEvent"
#define LV2_MIDI__NoteOff LV2_MIDI_PREFIX "NoteOff"
#define LV2_MIDI__NoteOn LV2_MIDI_PREFIX "NoteOn"
#define LV2_MIDI__ProgramChange LV2_MIDI_PREFIX "ProgramChange"
#define LV2_MIDI__QuarterFrame LV2_MIDI_PREFIX "QuarterFrame"
#define LV2_MIDI__Reset LV2_MIDI_PREFIX "Reset"
#define LV2_MIDI__SongPosition LV2_MIDI_PREFIX "SongPosition"
#define LV2_MIDI__SongSelect LV2_MIDI_PREFIX "SongSelect"
#define LV2_MIDI__Start LV2_MIDI_PREFIX "Start"
#define LV2_MIDI__Stop LV2_MIDI_PREFIX "Stop"
#define LV2_MIDI__SystemCommon LV2_MIDI_PREFIX "SystemCommon"
#define LV2_MIDI__SystemExclusive LV2_MIDI_PREFIX "SystemExclusive"
#define LV2_MIDI__SystemMessage LV2_MIDI_PREFIX "SystemMessage"
#define LV2_MIDI__SystemRealtime LV2_MIDI_PREFIX "SystemRealtime"
#define LV2_MIDI__Tick LV2_MIDI_PREFIX "Tick"
#define LV2_MIDI__TuneRequest LV2_MIDI_PREFIX "TuneRequest"
#define LV2_MIDI__VoiceMessage LV2_MIDI_PREFIX "VoiceMessage"
#define LV2_MIDI__benderValue LV2_MIDI_PREFIX "benderValue"
#define LV2_MIDI__binding LV2_MIDI_PREFIX "binding"
#define LV2_MIDI__byteNumber LV2_MIDI_PREFIX "byteNumber"
#define LV2_MIDI__channel LV2_MIDI_PREFIX "channel"
#define LV2_MIDI__chunk LV2_MIDI_PREFIX "chunk"
#define LV2_MIDI__controllerNumber LV2_MIDI_PREFIX "controllerNumber"
#define LV2_MIDI__controllerValue LV2_MIDI_PREFIX "controllerValue"
#define LV2_MIDI__noteNumber LV2_MIDI_PREFIX "noteNumber"
#define LV2_MIDI__pressure LV2_MIDI_PREFIX "pressure"
#define LV2_MIDI__programNumber LV2_MIDI_PREFIX "programNumber"
#define LV2_MIDI__property LV2_MIDI_PREFIX "property"
#define LV2_MIDI__songNumber LV2_MIDI_PREFIX "songNumber"
#define LV2_MIDI__songPosition LV2_MIDI_PREFIX "songPosition"
#define LV2_MIDI__status LV2_MIDI_PREFIX "status"
#define LV2_MIDI__statusMask LV2_MIDI_PREFIX "statusMask"
#define LV2_MIDI__velocity LV2_MIDI_PREFIX "velocity"

/**
MIDI Message Type.
This includes both voice messages (which have a channel) and system messages
(which do not), as well as a sentinel value for invalid messages. To get
the type of a message suitable for use in a switch statement, use
lv2_midi_get_type() on the status byte.
*/
typedef enum {
LV2_MIDI_MSG_INVALID = 0, /**< Invalid Message */
LV2_MIDI_MSG_NOTE_OFF = 0x80, /**< Note Off */
LV2_MIDI_MSG_NOTE_ON = 0x90, /**< Note On */
LV2_MIDI_MSG_NOTE_PRESSURE = 0xA0, /**< Note Pressure */
LV2_MIDI_MSG_CONTROLLER = 0xB0, /**< Controller */
LV2_MIDI_MSG_PGM_CHANGE = 0xC0, /**< Program Change */
LV2_MIDI_MSG_CHANNEL_PRESSURE = 0xD0, /**< Channel Pressure */
LV2_MIDI_MSG_BENDER = 0xE0, /**< Pitch Bender */
LV2_MIDI_MSG_SYSTEM_EXCLUSIVE = 0xF0, /**< System Exclusive Begin */
LV2_MIDI_MSG_MTC_QUARTER = 0xF1, /**< MTC Quarter Frame */
LV2_MIDI_MSG_SONG_POS = 0xF2, /**< Song Position */
LV2_MIDI_MSG_SONG_SELECT = 0xF3, /**< Song Select */
LV2_MIDI_MSG_TUNE_REQUEST = 0xF6, /**< Tune Request */
LV2_MIDI_MSG_CLOCK = 0xF8, /**< Clock */
LV2_MIDI_MSG_START = 0xFA, /**< Start */
LV2_MIDI_MSG_CONTINUE = 0xFB, /**< Continue */
LV2_MIDI_MSG_STOP = 0xFC, /**< Stop */
LV2_MIDI_MSG_ACTIVE_SENSE = 0xFE, /**< Active Sensing */
LV2_MIDI_MSG_RESET = 0xFF /**< Reset */
} LV2_Midi_Message_Type;

/**
Standard MIDI Controller Numbers.
*/
typedef enum {
LV2_MIDI_CTL_MSB_BANK = 0x00, /**< Bank Selection */
LV2_MIDI_CTL_MSB_MODWHEEL = 0x01, /**< Modulation */
LV2_MIDI_CTL_MSB_BREATH = 0x02, /**< Breath */
LV2_MIDI_CTL_MSB_FOOT = 0x04, /**< Foot */
LV2_MIDI_CTL_MSB_PORTAMENTO_TIME = 0x05, /**< Portamento Time */
LV2_MIDI_CTL_MSB_DATA_ENTRY = 0x06, /**< Data Entry */
LV2_MIDI_CTL_MSB_MAIN_VOLUME = 0x07, /**< Main Volume */
LV2_MIDI_CTL_MSB_BALANCE = 0x08, /**< Balance */
LV2_MIDI_CTL_MSB_PAN = 0x0A, /**< Panpot */
LV2_MIDI_CTL_MSB_EXPRESSION = 0x0B, /**< Expression */
LV2_MIDI_CTL_MSB_EFFECT1 = 0x0C, /**< Effect1 */
LV2_MIDI_CTL_MSB_EFFECT2 = 0x0D, /**< Effect2 */
LV2_MIDI_CTL_MSB_GENERAL_PURPOSE1 = 0x10, /**< General Purpose 1 */
LV2_MIDI_CTL_MSB_GENERAL_PURPOSE2 = 0x11, /**< General Purpose 2 */
LV2_MIDI_CTL_MSB_GENERAL_PURPOSE3 = 0x12, /**< General Purpose 3 */
LV2_MIDI_CTL_MSB_GENERAL_PURPOSE4 = 0x13, /**< General Purpose 4 */
LV2_MIDI_CTL_LSB_BANK = 0x20, /**< Bank Selection */
LV2_MIDI_CTL_LSB_MODWHEEL = 0x21, /**< Modulation */
LV2_MIDI_CTL_LSB_BREATH = 0x22, /**< Breath */
LV2_MIDI_CTL_LSB_FOOT = 0x24, /**< Foot */
LV2_MIDI_CTL_LSB_PORTAMENTO_TIME = 0x25, /**< Portamento Time */
LV2_MIDI_CTL_LSB_DATA_ENTRY = 0x26, /**< Data Entry */
LV2_MIDI_CTL_LSB_MAIN_VOLUME = 0x27, /**< Main Volume */
LV2_MIDI_CTL_LSB_BALANCE = 0x28, /**< Balance */
LV2_MIDI_CTL_LSB_PAN = 0x2A, /**< Panpot */
LV2_MIDI_CTL_LSB_EXPRESSION = 0x2B, /**< Expression */
LV2_MIDI_CTL_LSB_EFFECT1 = 0x2C, /**< Effect1 */
LV2_MIDI_CTL_LSB_EFFECT2 = 0x2D, /**< Effect2 */
LV2_MIDI_CTL_LSB_GENERAL_PURPOSE1 = 0x30, /**< General Purpose 1 */
LV2_MIDI_CTL_LSB_GENERAL_PURPOSE2 = 0x31, /**< General Purpose 2 */
LV2_MIDI_CTL_LSB_GENERAL_PURPOSE3 = 0x32, /**< General Purpose 3 */
LV2_MIDI_CTL_LSB_GENERAL_PURPOSE4 = 0x33, /**< General Purpose 4 */
LV2_MIDI_CTL_SUSTAIN = 0x40, /**< Sustain Pedal */
LV2_MIDI_CTL_PORTAMENTO = 0x41, /**< Portamento */
LV2_MIDI_CTL_SOSTENUTO = 0x42, /**< Sostenuto */
LV2_MIDI_CTL_SOFT_PEDAL = 0x43, /**< Soft Pedal */
LV2_MIDI_CTL_LEGATO_FOOTSWITCH = 0x44, /**< Legato Foot Switch */
LV2_MIDI_CTL_HOLD2 = 0x45, /**< Hold2 */
LV2_MIDI_CTL_SC1_SOUND_VARIATION = 0x46, /**< SC1 Sound Variation */
LV2_MIDI_CTL_SC2_TIMBRE = 0x47, /**< SC2 Timbre */
LV2_MIDI_CTL_SC3_RELEASE_TIME = 0x48, /**< SC3 Release Time */
LV2_MIDI_CTL_SC4_ATTACK_TIME = 0x49, /**< SC4 Attack Time */
LV2_MIDI_CTL_SC5_BRIGHTNESS = 0x4A, /**< SC5 Brightness */
LV2_MIDI_CTL_SC6 = 0x4B, /**< SC6 */
LV2_MIDI_CTL_SC7 = 0x4C, /**< SC7 */
LV2_MIDI_CTL_SC8 = 0x4D, /**< SC8 */
LV2_MIDI_CTL_SC9 = 0x4E, /**< SC9 */
LV2_MIDI_CTL_SC10 = 0x4F, /**< SC10 */
LV2_MIDI_CTL_GENERAL_PURPOSE5 = 0x50, /**< General Purpose 5 */
LV2_MIDI_CTL_GENERAL_PURPOSE6 = 0x51, /**< General Purpose 6 */
LV2_MIDI_CTL_GENERAL_PURPOSE7 = 0x52, /**< General Purpose 7 */
LV2_MIDI_CTL_GENERAL_PURPOSE8 = 0x53, /**< General Purpose 8 */
LV2_MIDI_CTL_PORTAMENTO_CONTROL = 0x54, /**< Portamento Control */
LV2_MIDI_CTL_E1_REVERB_DEPTH = 0x5B, /**< E1 Reverb Depth */
LV2_MIDI_CTL_E2_TREMOLO_DEPTH = 0x5C, /**< E2 Tremolo Depth */
LV2_MIDI_CTL_E3_CHORUS_DEPTH = 0x5D, /**< E3 Chorus Depth */
LV2_MIDI_CTL_E4_DETUNE_DEPTH = 0x5E, /**< E4 Detune Depth */
LV2_MIDI_CTL_E5_PHASER_DEPTH = 0x5F, /**< E5 Phaser Depth */
LV2_MIDI_CTL_DATA_INCREMENT = 0x60, /**< Data Increment */
LV2_MIDI_CTL_DATA_DECREMENT = 0x61, /**< Data Decrement */
LV2_MIDI_CTL_NRPN_LSB = 0x62, /**< Non-registered Parameter Number */
LV2_MIDI_CTL_NRPN_MSB = 0x63, /**< Non-registered Parameter Number */
LV2_MIDI_CTL_RPN_LSB = 0x64, /**< Registered Parameter Number */
LV2_MIDI_CTL_RPN_MSB = 0x65, /**< Registered Parameter Number */
LV2_MIDI_CTL_ALL_SOUNDS_OFF = 0x78, /**< All Sounds Off */
LV2_MIDI_CTL_RESET_CONTROLLERS = 0x79, /**< Reset Controllers */
LV2_MIDI_CTL_LOCAL_CONTROL_SWITCH = 0x7A, /**< Local Control Switch */
LV2_MIDI_CTL_ALL_NOTES_OFF = 0x7B, /**< All Notes Off */
LV2_MIDI_CTL_OMNI_OFF = 0x7C, /**< Omni Off */
LV2_MIDI_CTL_OMNI_ON = 0x7D, /**< Omni On */
LV2_MIDI_CTL_MONO1 = 0x7E, /**< Mono1 */
LV2_MIDI_CTL_MONO2 = 0x7F /**< Mono2 */
} LV2_Midi_Controller;

/**
Return true iff `msg` is a MIDI voice message (which has a channel).
*/
static inline bool
lv2_midi_is_voice_message(const uint8_t* msg) {
return msg[0] >= 0x80 && msg[0] < 0xF0;
}

/**
Return true iff `msg` is a MIDI system message (which has no channel).
*/
static inline bool
lv2_midi_is_system_message(const uint8_t* msg) {
switch (msg[0]) {
case 0xF4: case 0xF5: case 0xF7: case 0xF9: case 0xFD:
return false;
default:
return (msg[0] & 0xF0) == 0xF0;
}
}

/**
Return the type of a MIDI message.
@param msg Pointer to the start (status byte) of a MIDI message.
*/
static inline LV2_Midi_Message_Type
lv2_midi_message_type(const uint8_t* msg) {
if (lv2_midi_is_voice_message(msg)) {
return (LV2_Midi_Message_Type)(msg[0] & 0xF0);
} else if (lv2_midi_is_system_message(msg)) {
return (LV2_Midi_Message_Type)msg[0];
} else {
return LV2_MIDI_MSG_INVALID;
}
}

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /* LV2_MIDI_H */

/**
@}
*/
42 changes: 42 additions & 0 deletions include/lv2/lv2plug.in/ns/ext/morph/morph.h
@@ -0,0 +1,42 @@
/*
Copyright 2012 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/**
@defgroup morph Morph
Ports that can dynamically change type, see <http://lv2plug.in/ns/ext/morph>
for details.
@{
*/

#ifndef LV2_MORPH_H
#define LV2_MORPH_H

#define LV2_MORPH_URI "http://lv2plug.in/ns/ext/morph"
#define LV2_MORPH_PREFIX LV2_MORPH_URI "#"

#define LV2_MORPH__AutoMorphPort LV2_MORPH_PREFIX "AutoMorphPort"
#define LV2_MORPH__MorphPort LV2_MORPH_PREFIX "MorphPort"
#define LV2_MORPH__interface LV2_MORPH_PREFIX "interface"
#define LV2_MORPH__supportsType LV2_MORPH_PREFIX "supportsType"
#define LV2_MORPH__currentType LV2_MORPH_PREFIX "currentType"

#endif /* LV2_MORPH_H */

/**
@}
*/
145 changes: 145 additions & 0 deletions include/lv2/lv2plug.in/ns/ext/options/options.h
@@ -0,0 +1,145 @@
/*
Copyright 2012 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/**
@defgroup options Options
Instantiation time options, see <http://lv2plug.in/ns/ext/options> for
details.
@{
*/

#ifndef LV2_OPTIONS_H
#define LV2_OPTIONS_H

#include <stdint.h>

#include "lv2/lv2plug.in/ns/ext/urid/urid.h"
#include "lv2/lv2plug.in/ns/lv2core/lv2.h"

#define LV2_OPTIONS_URI "http://lv2plug.in/ns/ext/options"
#define LV2_OPTIONS_PREFIX LV2_OPTIONS_URI "#"

#define LV2_OPTIONS__Option LV2_OPTIONS_PREFIX "Option"
#define LV2_OPTIONS__interface LV2_OPTIONS_PREFIX "interface"
#define LV2_OPTIONS__options LV2_OPTIONS_PREFIX "options"
#define LV2_OPTIONS__requiredOption LV2_OPTIONS_PREFIX "requiredOption"
#define LV2_OPTIONS__supportedOption LV2_OPTIONS_PREFIX "supportedOption"

#ifdef __cplusplus
extern "C" {
#endif

/**
The context of an Option, which defines the subject it applies to.
*/
typedef enum {
/**
This option applies to the instance itself. The subject must be
ignored.
*/
LV2_OPTIONS_INSTANCE,

/**
This option applies to some named resource. The subject is a URI mapped
to an integer (a LV2_URID, like the key)
*/
LV2_OPTIONS_RESOURCE,

/**
This option applies to some blank node. The subject is a blank node
identifier, which is valid only within the current local scope.
*/
LV2_OPTIONS_BLANK,

/**
This option applies to a port on the instance. The subject is the
port's index.
*/
LV2_OPTIONS_PORT
} LV2_Options_Context;

/**
An option.
This is a property with a subject, also known as a triple or statement.
This struct is useful anywhere a statement needs to be passed where no
memory ownership issues are present (since the value is a const pointer).
Options can be passed to an instance via the feature LV2_OPTIONS__options
with data pointed to an array of options terminated by a zeroed option, or
accessed/manipulated using LV2_Options_Interface.
*/
typedef struct _LV2_Options_Option {
LV2_Options_Context context; /**< Context (type of subject). */
uint32_t subject; /**< Subject. */
LV2_URID key; /**< Key (property). */
uint32_t size; /**< Size of value in bytes. */
LV2_URID type; /**< Type of value (datatype). */
const void* value; /**< Pointer to value (object). */
} LV2_Options_Option;

/** A status code for option functions. */
typedef enum {
LV2_OPTIONS_SUCCESS = 0, /**< Completed successfully. */
LV2_OPTIONS_ERR_UNKNOWN = 1, /**< Unknown error. */
LV2_OPTIONS_ERR_BAD_SUBJECT = 1 << 1, /**< Invalid/unsupported subject. */
LV2_OPTIONS_ERR_BAD_KEY = 1 << 2, /**< Invalid/unsupported key. */
LV2_OPTIONS_ERR_BAD_VALUE = 1 << 3 /**< Invalid/unsupported value. */
} LV2_Options_Status;

/**
Interface for dynamically setting options (LV2_OPTIONS__interface).
*/
typedef struct _LV2_Options_Interface {
/**
Get the given options.
Each element of the passed options array MUST have type, subject, and
key set. All other fields (size, type, value) MUST be initialised to
zero, and are set to the option value if such an option is found.
This function is in the "instantiation" LV2 threading class, so no other
instance functions may be called concurrently.
@return Bitwise OR of LV2_Options_Status values.
*/
uint32_t (*get)(LV2_Handle instance,
LV2_Options_Option* options);

/**
Set the given options.
This function is in the "instantiation" LV2 threading class, so no other
instance functions may be called concurrently.
@return Bitwise OR of LV2_Options_Status values.
*/
uint32_t (*set)(LV2_Handle instance,
const LV2_Options_Option* options);
} LV2_Options_Interface;

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /* LV2_OPTIONS_H */

/**
@}
*/
62 changes: 62 additions & 0 deletions include/lv2/lv2plug.in/ns/ext/parameters/parameters.h
@@ -0,0 +1,62 @@
/*
Copyright 2012 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/**
@defgroup parameters Parameters
Common parameters for audio processing, see
<http://lv2plug.in/ns/ext/parameters>.
@{
*/

#ifndef LV2_PARAMETERS_H
#define LV2_PARAMETERS_H

#define LV2_PARAMETERS_URI "http://lv2plug.in/ns/ext/parameters"
#define LV2_PARAMETERS_PREFIX LV2_PARAMETERS_URI "#"

#define LV2_PARAMETERS__CompressorControls LV2_PARAMETERS_PREFIX "CompressorControls"
#define LV2_PARAMETERS__ControlGroup LV2_PARAMETERS_PREFIX "ControlGroup"
#define LV2_PARAMETERS__EnvelopeControls LV2_PARAMETERS_PREFIX "EnvelopeControls"
#define LV2_PARAMETERS__FilterControls LV2_PARAMETERS_PREFIX "FilterControls"
#define LV2_PARAMETERS__OscillatorControls LV2_PARAMETERS_PREFIX "OscillatorControls"
#define LV2_PARAMETERS__amplitude LV2_PARAMETERS_PREFIX "amplitude"
#define LV2_PARAMETERS__attack LV2_PARAMETERS_PREFIX "attack"
#define LV2_PARAMETERS__bypass LV2_PARAMETERS_PREFIX "bypass"
#define LV2_PARAMETERS__cutoffFrequency LV2_PARAMETERS_PREFIX "cutoffFrequency"
#define LV2_PARAMETERS__decay LV2_PARAMETERS_PREFIX "decay"
#define LV2_PARAMETERS__delay LV2_PARAMETERS_PREFIX "delay"
#define LV2_PARAMETERS__dryLevel LV2_PARAMETERS_PREFIX "dryLevel"
#define LV2_PARAMETERS__frequency LV2_PARAMETERS_PREFIX "frequency"
#define LV2_PARAMETERS__gain LV2_PARAMETERS_PREFIX "gain"
#define LV2_PARAMETERS__hold LV2_PARAMETERS_PREFIX "hold"
#define LV2_PARAMETERS__pulseWidth LV2_PARAMETERS_PREFIX "pulseWidth"
#define LV2_PARAMETERS__ratio LV2_PARAMETERS_PREFIX "ratio"
#define LV2_PARAMETERS__release LV2_PARAMETERS_PREFIX "release"
#define LV2_PARAMETERS__resonance LV2_PARAMETERS_PREFIX "resonance"
#define LV2_PARAMETERS__sampleRate LV2_PARAMETERS_PREFIX "sampleRate"
#define LV2_PARAMETERS__sustain LV2_PARAMETERS_PREFIX "sustain"
#define LV2_PARAMETERS__threshold LV2_PARAMETERS_PREFIX "threshold"
#define LV2_PARAMETERS__waveform LV2_PARAMETERS_PREFIX "waveform"
#define LV2_PARAMETERS__wetDryRatio LV2_PARAMETERS_PREFIX "wetDryRatio"
#define LV2_PARAMETERS__wetLevel LV2_PARAMETERS_PREFIX "wetLevel"

#endif /* LV2_PARAMETERS_H */

/**
@}
*/
65 changes: 65 additions & 0 deletions include/lv2/lv2plug.in/ns/ext/patch/patch.h
@@ -0,0 +1,65 @@
/*
Copyright 2012 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/**
@defgroup patch Patch
Messages for accessing and manipulating properties, see
<http://lv2plug.in/ns/ext/patch> for details.
Note the patch extension is purely data, this header merely defines URIs for
convenience.
@{
*/

#ifndef LV2_PATCH_H
#define LV2_PATCH_H

#define LV2_PATCH_URI "http://lv2plug.in/ns/ext/patch"
#define LV2_PATCH_PREFIX LV2_PATCH_URI "#"

#define LV2_PATCH__Ack LV2_PATCH_PREFIX "Ack"
#define LV2_PATCH__Delete LV2_PATCH_PREFIX "Delete"
#define LV2_PATCH__Copy LV2_PATCH_PREFIX "Copy"
#define LV2_PATCH__Error LV2_PATCH_PREFIX "Error"
#define LV2_PATCH__Get LV2_PATCH_PREFIX "Get"
#define LV2_PATCH__Message LV2_PATCH_PREFIX "Message"
#define LV2_PATCH__Move LV2_PATCH_PREFIX "Move"
#define LV2_PATCH__Patch LV2_PATCH_PREFIX "Patch"
#define LV2_PATCH__Post LV2_PATCH_PREFIX "Post"
#define LV2_PATCH__Put LV2_PATCH_PREFIX "Put"
#define LV2_PATCH__Request LV2_PATCH_PREFIX "Request"
#define LV2_PATCH__Response LV2_PATCH_PREFIX "Response"
#define LV2_PATCH__Set LV2_PATCH_PREFIX "Set"
#define LV2_PATCH__add LV2_PATCH_PREFIX "add"
#define LV2_PATCH__body LV2_PATCH_PREFIX "body"
#define LV2_PATCH__destination LV2_PATCH_PREFIX "destination"
#define LV2_PATCH__property LV2_PATCH_PREFIX "property"
#define LV2_PATCH__readable LV2_PATCH_PREFIX "readable"
#define LV2_PATCH__remove LV2_PATCH_PREFIX "remove"
#define LV2_PATCH__request LV2_PATCH_PREFIX "request"
#define LV2_PATCH__subject LV2_PATCH_PREFIX "subject"
#define LV2_PATCH__sequenceNumber LV2_PATCH_PREFIX "sequenceNumber"
#define LV2_PATCH__value LV2_PATCH_PREFIX "value"
#define LV2_PATCH__wildcard LV2_PATCH_PREFIX "wildcard"
#define LV2_PATCH__writable LV2_PATCH_PREFIX "writable"

#endif /* LV2_PATCH_H */

/**
@}
*/
71 changes: 71 additions & 0 deletions include/lv2/lv2plug.in/ns/ext/port-groups/port-groups.h
@@ -0,0 +1,71 @@
/*
Copyright 2012 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/**
@defgroup port-groups Port Groups
Multi-channel groups of LV2 ports, see
<http://lv2plug.in/ns/ext/port-groups> for details.
@{
*/

#ifndef LV2_PORT_GROUPS_H
#define LV2_PORT_GROUPS_H

#define LV2_PORT_GROUPS_URI "http://lv2plug.in/ns/ext/port-groups"
#define LV2_PORT_GROUPS_PREFIX LV2_PORT_GROUPS_URI "#"

#define LV2_PORT_GROUPS__DiscreteGroup LV2_PORT_GROUPS_PREFIX "DiscreteGroup"
#define LV2_PORT_GROUPS__Element LV2_PORT_GROUPS_PREFIX "Element"
#define LV2_PORT_GROUPS__FivePointOneGroup LV2_PORT_GROUPS_PREFIX "FivePointOneGroup"
#define LV2_PORT_GROUPS__FivePointZeroGroup LV2_PORT_GROUPS_PREFIX "FivePointZeroGroup"
#define LV2_PORT_GROUPS__FourPointZeroGroup LV2_PORT_GROUPS_PREFIX "FourPointZeroGroup"
#define LV2_PORT_GROUPS__Group LV2_PORT_GROUPS_PREFIX "Group"
#define LV2_PORT_GROUPS__InputGroup LV2_PORT_GROUPS_PREFIX "InputGroup"
#define LV2_PORT_GROUPS__MidSideGroup LV2_PORT_GROUPS_PREFIX "MidSideGroup"
#define LV2_PORT_GROUPS__MonoGroup LV2_PORT_GROUPS_PREFIX "MonoGroup"
#define LV2_PORT_GROUPS__OutputGroup LV2_PORT_GROUPS_PREFIX "OutputGroup"
#define LV2_PORT_GROUPS__SevenPointOneGroup LV2_PORT_GROUPS_PREFIX "SevenPointOneGroup"
#define LV2_PORT_GROUPS__SevenPointOneWideGroup LV2_PORT_GROUPS_PREFIX "SevenPointOneWideGroup"
#define LV2_PORT_GROUPS__SixPointOneGroup LV2_PORT_GROUPS_PREFIX "SixPointOneGroup"
#define LV2_PORT_GROUPS__StereoGroup LV2_PORT_GROUPS_PREFIX "StereoGroup"
#define LV2_PORT_GROUPS__ThreePointZeroGroup LV2_PORT_GROUPS_PREFIX "ThreePointZeroGroup"
#define LV2_PORT_GROUPS__center LV2_PORT_GROUPS_PREFIX "center"
#define LV2_PORT_GROUPS__centerLeft LV2_PORT_GROUPS_PREFIX "centerLeft"
#define LV2_PORT_GROUPS__centerRight LV2_PORT_GROUPS_PREFIX "centerRight"
#define LV2_PORT_GROUPS__element LV2_PORT_GROUPS_PREFIX "element"
#define LV2_PORT_GROUPS__group LV2_PORT_GROUPS_PREFIX "group"
#define LV2_PORT_GROUPS__left LV2_PORT_GROUPS_PREFIX "left"
#define LV2_PORT_GROUPS__lowFrequencyEffects LV2_PORT_GROUPS_PREFIX "lowFrequencyEffects"
#define LV2_PORT_GROUPS__mainInput LV2_PORT_GROUPS_PREFIX "mainInput"
#define LV2_PORT_GROUPS__mainOutput LV2_PORT_GROUPS_PREFIX "mainOutput"
#define LV2_PORT_GROUPS__rearCenter LV2_PORT_GROUPS_PREFIX "rearCenter"
#define LV2_PORT_GROUPS__rearLeft LV2_PORT_GROUPS_PREFIX "rearLeft"
#define LV2_PORT_GROUPS__rearRight LV2_PORT_GROUPS_PREFIX "rearRight"
#define LV2_PORT_GROUPS__right LV2_PORT_GROUPS_PREFIX "right"
#define LV2_PORT_GROUPS__side LV2_PORT_GROUPS_PREFIX "side"
#define LV2_PORT_GROUPS__sideChainOf LV2_PORT_GROUPS_PREFIX "sideChainOf"
#define LV2_PORT_GROUPS__sideLeft LV2_PORT_GROUPS_PREFIX "sideLeft"
#define LV2_PORT_GROUPS__sideRight LV2_PORT_GROUPS_PREFIX "sideRight"
#define LV2_PORT_GROUPS__source LV2_PORT_GROUPS_PREFIX "source"
#define LV2_PORT_GROUPS__subGroupOf LV2_PORT_GROUPS_PREFIX "subGroupOf"

#endif /* LV2_PORT_GROUPS_H */

/**
@}
*/
48 changes: 48 additions & 0 deletions include/lv2/lv2plug.in/ns/ext/port-props/port-props.h
@@ -0,0 +1,48 @@
/*
Copyright 2012 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/**
@defgroup port-props Port Properties
Various port properties.
@{
*/

#ifndef LV2_PORT_PROPS_H
#define LV2_PORT_PROPS_H

#define LV2_PORT_PROPS_URI "http://lv2plug.in/ns/ext/port-props"
#define LV2_PORT_PROPS_PREFIX LV2_PORT_PROPS_URI "#"

#define LV2_PORT_PROPS__causesArtifacts LV2_PORT_PROPS_PREFIX "causesArtifacts"
#define LV2_PORT_PROPS__continuousCV LV2_PORT_PROPS_PREFIX "continuousCV"
#define LV2_PORT_PROPS__discreteCV LV2_PORT_PROPS_PREFIX "discreteCV"
#define LV2_PORT_PROPS__displayPriority LV2_PORT_PROPS_PREFIX "displayPriority"
#define LV2_PORT_PROPS__expensive LV2_PORT_PROPS_PREFIX "expensive"
#define LV2_PORT_PROPS__hasStrictBounds LV2_PORT_PROPS_PREFIX "hasStrictBounds"
#define LV2_PORT_PROPS__logarithmic LV2_PORT_PROPS_PREFIX "logarithmic"
#define LV2_PORT_PROPS__notAutomatic LV2_PORT_PROPS_PREFIX "notAutomatic"
#define LV2_PORT_PROPS__notOnGUI LV2_PORT_PROPS_PREFIX "notOnGUI"
#define LV2_PORT_PROPS__rangeSteps LV2_PORT_PROPS_PREFIX "rangeSteps"
#define LV2_PORT_PROPS__supportsStrictBounds LV2_PORT_PROPS_PREFIX "supportsStrictBounds"
#define LV2_PORT_PROPS__trigger LV2_PORT_PROPS_PREFIX "trigger"

#endif /* LV2_PORT_PROPS_H */

/**
@}
*/
41 changes: 41 additions & 0 deletions include/lv2/lv2plug.in/ns/ext/presets/presets.h
@@ -0,0 +1,41 @@
/*
Copyright 2012 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/**
@defgroup presets Presets
Presets for plugins, see <http://lv2plug.in/ns/ext/presets> for details.
@{
*/

#ifndef LV2_PRESETS_H
#define LV2_PRESETS_H

#define LV2_PRESETS_URI "http://lv2plug.in/ns/ext/presets"
#define LV2_PRESETS_PREFIX LV2_PRESETS_URI "#"

#define LV2_PRESETS__Bank LV2_PRESETS_PREFIX "Bank"
#define LV2_PRESETS__Preset LV2_PRESETS_PREFIX "Preset"
#define LV2_PRESETS__bank LV2_PRESETS_PREFIX "bank"
#define LV2_PRESETS__preset LV2_PRESETS_PREFIX "preset"
#define LV2_PRESETS__value LV2_PRESETS_PREFIX "value"

#endif /* LV2_PRESETS_H */

/**
@}
*/
84 changes: 84 additions & 0 deletions include/lv2/lv2plug.in/ns/ext/resize-port/resize-port.h
@@ -0,0 +1,84 @@
/*
Copyright 2007-2012 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/**
@defgroup resize-port Resize Port
Dynamically sized LV2 port buffers.
@{
*/

#ifndef LV2_RESIZE_PORT_H
#define LV2_RESIZE_PORT_H

#include <stddef.h>
#include <stdint.h>

#define LV2_RESIZE_PORT_URI "http://lv2plug.in/ns/ext/resize-port"
#define LV2_RESIZE_PORT_PREFIX LV2_RESIZE_PORT_URI "#"

#define LV2_RESIZE_PORT__asLargeAs LV2_RESIZE_PORT_PREFIX "asLargeAs"
#define LV2_RESIZE_PORT__minimumSize LV2_RESIZE_PORT_PREFIX "minimumSize"
#define LV2_RESIZE_PORT__resize LV2_RESIZE_PORT_PREFIX "resize"

#ifdef __cplusplus
extern "C" {
#else
# include <stdbool.h>
#endif

/** A status code for state functions. */
typedef enum {
LV2_RESIZE_PORT_SUCCESS = 0, /**< Completed successfully. */
LV2_RESIZE_PORT_ERR_UNKNOWN = 1, /**< Unknown error. */
LV2_RESIZE_PORT_ERR_NO_SPACE = 2 /**< Insufficient space. */
} LV2_Resize_Port_Status;

typedef void* LV2_Resize_Port_Feature_Data;

/** Host feature to allow plugins to resize their port buffers. */
typedef struct {
LV2_Resize_Port_Feature_Data data;

/**
Resize a port buffer to at least `size` bytes.
This function MAY return an error, in which case the port buffer was not
resized and the port is still connected to the same location. Plugins
MUST gracefully handle this situation.
This function is in the audio threading class.
The host MUST preserve the contents of the port buffer when resizing.
Plugins MAY resize a port many times in a single run callback. Hosts
SHOULD make this as inexpensive as possible.
*/
LV2_Resize_Port_Status (*resize)(LV2_Resize_Port_Feature_Data data,
uint32_t index,
size_t size);
} LV2_Resize_Port_Resize;

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /* LV2_RESIZE_PORT_H */

/**
@}
*/
362 changes: 362 additions & 0 deletions include/lv2/lv2plug.in/ns/ext/state/state.h
@@ -0,0 +1,362 @@
/*
Copyright 2010-2012 David Robillard <http://drobilla.net>
Copyright 2010 Leonard Ritter <paniq@paniq.org>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/**
@defgroup state State
An interface for LV2 plugins to save and restore state, see
<http://lv2plug.in/ns/ext/state> for details.
@{
*/

#ifndef LV2_STATE_H
#define LV2_STATE_H

#include <stddef.h>
#include <stdint.h>

#include "lv2/lv2plug.in/ns/lv2core/lv2.h"

#define LV2_STATE_URI "http://lv2plug.in/ns/ext/state"
#define LV2_STATE_PREFIX LV2_STATE_URI "#"

#define LV2_STATE__State LV2_STATE_PREFIX "State"
#define LV2_STATE__interface LV2_STATE_PREFIX "interface"
#define LV2_STATE__loadDefaultState LV2_STATE_PREFIX "loadDefaultState"
#define LV2_STATE__makePath LV2_STATE_PREFIX "makePath"
#define LV2_STATE__mapPath LV2_STATE_PREFIX "mapPath"
#define LV2_STATE__state LV2_STATE_PREFIX "state"
#define LV2_STATE__threadSafeRestore LV2_STATE_PREFIX "threadSafeRestore"

#ifdef __cplusplus
extern "C" {
#else
# include <stdbool.h>
#endif

typedef void* LV2_State_Handle;
typedef void* LV2_State_Map_Path_Handle;
typedef void* LV2_State_Make_Path_Handle;

/**
Flags describing value characteristics.
These flags are used along with the value's type URI to determine how to
(de-)serialise the value data, or whether it is even possible to do so.
*/
typedef enum {
/**
Plain Old Data.
Values with this flag contain no pointers or references to other areas
of memory. It is safe to copy POD values with a simple memcpy and store
them for the duration of the process. A POD value is not necessarily
safe to trasmit between processes or machines (e.g. filenames are POD),
see LV2_STATE_IS_PORTABLE for details.
Implementations MUST NOT attempt to copy or serialise a non-POD value if
they do not understand its type (and thus know how to correctly do so).
*/
LV2_STATE_IS_POD = 1,

/**
Portable (architecture independent) data.
Values with this flag are in a format that is usable on any
architecture. A portable value saved on one machine can be restored on
another machine regardless of architecture. The format of portable
values MUST NOT depend on architecture-specific properties like
endianness or alignment. Portable values MUST NOT contain filenames.
*/
LV2_STATE_IS_PORTABLE = 1 << 1,

/**
Native data.
This flag is used by the host to indicate that the saved data is only
going to be used locally in the currently running process (e.g. for
instance duplication or snapshots), so the plugin should use the most
efficient representation possible and not worry about serialisation
and portability.
*/
LV2_STATE_IS_NATIVE = 1 << 2
} LV2_State_Flags;

/** A status code for state functions. */
typedef enum {
LV2_STATE_SUCCESS = 0, /**< Completed successfully. */
LV2_STATE_ERR_UNKNOWN = 1, /**< Unknown error. */
LV2_STATE_ERR_BAD_TYPE = 2, /**< Failed due to unsupported type. */
LV2_STATE_ERR_BAD_FLAGS = 3, /**< Failed due to unsupported flags. */
LV2_STATE_ERR_NO_FEATURE = 4, /**< Failed due to missing features. */
LV2_STATE_ERR_NO_PROPERTY = 5, /**< Failed due to missing property. */
LV2_STATE_ERR_NO_SPACE = 6 /**< Failed due to insufficient space. */
} LV2_State_Status;

/**
A host-provided function to store a property.
@param handle Must be the handle passed to LV2_State_Interface.save().
@param key The key to store `value` under (URID).
@param value Pointer to the value to be stored.
@param size The size of `value` in bytes.
@param type The type of `value` (URID).
@param flags LV2_State_Flags for `value`.
@return 0 on success, otherwise a non-zero error code.
The host passes a callback of this type to LV2_State_Interface.save(). This
callback is called repeatedly by the plugin to store all the properties that
describe its current state.
DO NOT INVENT NONSENSE URI SCHEMES FOR THE KEY. Best is to use keys from
existing vocabularies. If nothing appropriate is available, use http URIs
that point to somewhere you can host documents so documentation can be made
resolvable (e.g. a child of the plugin or project URI). If this is not
possible, invent a URN scheme, e.g. urn:myproj:whatever. The plugin MUST
NOT pass an invalid URI key.
The host MAY fail to store a property for whatever reason, but SHOULD
store any property that is LV2_STATE_IS_POD and LV2_STATE_IS_PORTABLE.
Implementations SHOULD use the types from the LV2 Atom extension
(http://lv2plug.in/ns/ext/atom) wherever possible. The plugin SHOULD
attempt to fall-back and avoid the error if possible.
Note that `size` MUST be > 0, and `value` MUST point to a valid region of
memory `size` bytes long (this is required to make restore unambiguous).
The plugin MUST NOT attempt to use this function outside of the
LV2_State_Interface.restore() context.
*/
typedef LV2_State_Status (*LV2_State_Store_Function)(
LV2_State_Handle handle,
uint32_t key,
const void* value,
size_t size,
uint32_t type,
uint32_t flags);

/**
A host-provided function to retrieve a property.
@param handle Must be the handle passed to LV2_State_Interface.restore().
@param key The key of the property to retrieve (URID).
@param size (Output) If non-NULL, set to the size of the restored value.
@param type (Output) If non-NULL, set to the type of the restored value.
@param flags (Output) If non-NULL, set to the flags for the restored value.
@return A pointer to the restored value (object), or NULL if no value
has been stored under `key`.
A callback of this type is passed by the host to
LV2_State_Interface.restore(). This callback is called repeatedly by the
plugin to retrieve any properties it requires to restore its state.
The returned value MUST remain valid until LV2_State_Interface.restore()
returns. The plugin MUST NOT attempt to use this function, or any value
returned from it, outside of the LV2_State_Interface.restore() context.
*/
typedef const void* (*LV2_State_Retrieve_Function)(
LV2_State_Handle handle,
uint32_t key,
size_t* size,
uint32_t* type,
uint32_t* flags);

/**
LV2 Plugin State Interface.
When the plugin's extension_data is called with argument
LV2_STATE__interface, the plugin MUST return an LV2_State_Interface
structure, which remains valid for the lifetime of the plugin.
The host can use the contained function pointers to save and restore the
state of a plugin instance at any time, provided the threading restrictions
of the functions are met.
Stored data is only guaranteed to be compatible between instances of plugins
with the same URI (i.e. if a change to a plugin would cause a fatal error
when restoring state saved by a previous version of that plugin, the plugin
URI MUST change just as it must when ports change incompatibly). Plugin
authors should consider this possibility, and always store sensible data
with meaningful types to avoid such problems in the future.
*/
typedef struct _LV2_State_Interface {
/**
Save plugin state using a host-provided `store` callback.
@param instance The instance handle of the plugin.
@param store The host-provided store callback.
@param handle An opaque pointer to host data which MUST be passed as the
handle parameter to `store` if it is called.
@param flags Flags describing desired properties of this save. These
flags may be used to determine the most appropriate values to store.
@param features Extensible parameter for passing any additional
features to be used for this save.
The plugin is expected to store everything necessary to completely
restore its state later. Plugins SHOULD store simple POD data whenever
possible, and consider the possibility of state being restored much
later on a different machine.
The `handle` pointer and `store` function MUST NOT be used
beyond the scope of save().
This function has its own special threading class: it may not be called
concurrently with any "Instantiation" function, but it may be called
concurrently with functions in any other class, unless the definition of
that class prohibits it (e.g. it may not be called concurrently with a
"Discovery" function, but it may be called concurrently with an "Audio"
function. The plugin is responsible for any locking or lock-free
techniques necessary to make this possible.
Note that in the simple case where state is only modified by restore(),
there are no synchronization issues since save() is never called
concurrently with restore() (though run() may read it during a save).
Plugins that dynamically modify state while running, however, must take
care to do so in such a way that a concurrent call to save() will save a
consistent representation of plugin state for a single instant in time.
*/
LV2_State_Status (*save)(LV2_Handle instance,
LV2_State_Store_Function store,
LV2_State_Handle handle,
uint32_t flags,
const LV2_Feature *const * features);

/**
Restore plugin state using a host-provided `retrieve` callback.
@param instance The instance handle of the plugin.
@param retrieve The host-provided retrieve callback.
@param handle An opaque pointer to host data which MUST be passed as the
handle parameter to `retrieve` if it is called.
@param flags Currently unused.
@param features Extensible parameter for passing any additional
features to be used for this restore.
The plugin MAY assume a restored value was set by a previous call to
LV2_State_Interface.save() by a plugin with the same URI.
The plugin MUST gracefully fall back to a default value when a value can
not be retrieved. This allows the host to reset the plugin state with
an empty map.
The `handle` pointer and `store` function MUST NOT be used
beyond the scope of restore().
This function is in the "Instantiation" threading class as defined by
LV2. This means it MUST NOT be called concurrently with any other
function on the same plugin instance.
*/
LV2_State_Status (*restore)(LV2_Handle instance,
LV2_State_Retrieve_Function retrieve,
LV2_State_Handle handle,
uint32_t flags,
const LV2_Feature *const * features);
} LV2_State_Interface;

/**
Feature data for state:mapPath (@ref LV2_STATE__mapPath).
*/
typedef struct {
/**
Opaque host data.
*/
LV2_State_Map_Path_Handle handle;

/**
Map an absolute path to an abstract path for use in plugin state.
@param handle MUST be the `handle` member of this struct.
@param absolute_path The absolute path of a file.
@return An abstract path suitable for use in plugin state.
The plugin MUST use this function to map any paths that will be stored
in plugin state. The returned value is an abstract path which MAY not
be an actual file system path; absolute_path() MUST be used to map
it to an actual path in order to use the file.
Plugins MUST NOT make any assumptions about abstract paths except that
they can be mapped back to the absolute path of the "same" file (though
not necessarily the same original path) using absolute_path().
This function may only be called within the context of
LV2_State_Interface methods. The caller is responsible for freeing the
returned value with free().
*/
char* (*abstract_path)(LV2_State_Map_Path_Handle handle,
const char* absolute_path);

/**
Map an abstract path from plugin state to an absolute path.
@param handle MUST be the `handle` member of this struct.
@param abstract_path An abstract path (e.g. a path from plugin state).
@return An absolute file system path.
The plugin MUST use this function in order to actually open or otherwise
use any paths loaded from plugin state.
This function may only be called within the context of
LV2_State_Interface methods. The caller is responsible for freeing the
returned value with free().
*/
char* (*absolute_path)(LV2_State_Map_Path_Handle handle,
const char* abstract_path);
} LV2_State_Map_Path;

/**
Feature data for state:makePath (@ref LV2_STATE__makePath).
*/
typedef struct {
/**
Opaque host data.
*/
LV2_State_Make_Path_Handle handle;

/**
Return a path the plugin may use to create a new file.
@param handle MUST be the `handle` member of this struct.
@param path The path of the new file within a namespace unique to this
plugin instance.
@return The absolute path to use for the new file.
This function can be used by plugins to create files and directories,
either at state saving time (if this feature is passed to
LV2_State_Interface.save()) or any time (if this feature is passed to
LV2_Descriptor.instantiate()).
The host MUST do whatever is necessary for the plugin to be able to
create a file at the returned path (e.g. using fopen), including
creating any leading directories.
If this function is passed to LV2_Descriptor.instantiate(), it may be
called from any non-realtime context. If it is passed to
LV2_State_Interface.save(), it may only be called within the dynamic
scope of that function call.
The caller is responsible for freeing the returned value with free().
*/
char* (*path)(LV2_State_Make_Path_Handle handle,
const char* path);
} LV2_State_Make_Path;

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /* LV2_STATE_H */

/**
@}
*/
53 changes: 53 additions & 0 deletions include/lv2/lv2plug.in/ns/ext/time/time.h
@@ -0,0 +1,53 @@
/*
Copyright 2011 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/**
@defgroup time Time
Properties for describing time, see <http://lv2plug.in/ns/ext/time> for
details.
Note the time extension is purely data, this header merely defines URIs for
convenience.
@{
*/

#ifndef LV2_TIME_H
#define LV2_TIME_H

#define LV2_TIME_URI "http://lv2plug.in/ns/ext/time"
#define LV2_TIME_PREFIX LV2_TIME_URI "#"

#define LV2_TIME__Time LV2_TIME_PREFIX "Time"
#define LV2_TIME__Position LV2_TIME_PREFIX "Position"
#define LV2_TIME__Rate LV2_TIME_PREFIX "Rate"
#define LV2_TIME__position LV2_TIME_PREFIX "position"
#define LV2_TIME__barBeat LV2_TIME_PREFIX "barBeat"
#define LV2_TIME__bar LV2_TIME_PREFIX "bar"
#define LV2_TIME__beat LV2_TIME_PREFIX "beat"
#define LV2_TIME__beatUnit LV2_TIME_PREFIX "beatUnit"
#define LV2_TIME__beatsPerBar LV2_TIME_PREFIX "beatsPerBar"
#define LV2_TIME__beatsPerMinute LV2_TIME_PREFIX "beatsPerMinute"
#define LV2_TIME__frame LV2_TIME_PREFIX "frame"
#define LV2_TIME__framesPerSecond LV2_TIME_PREFIX "framesPerSecond"
#define LV2_TIME__speed LV2_TIME_PREFIX "speed"

/**
@}
*/

#endif /* LV2_TIME_H */