clap

CLAP Audio Plugin API
Log | Files | Refs | README | LICENSE

commit a324d51a75567bd5fbc10e260b2ed542940ffe89
parent c3b21b3dc67ba0c4907d7c747c44abb7c99f57a3
Author: Alexandre BIQUE <bique.alexandre@gmail.com>
Date:   Tue, 29 Jun 2021 14:10:42 +0200

Get rid of macros

Diffstat:
Mexamples/host/plugin-host.cc | 13++++++-------
Minclude/clap/clap.h | 5++---
Minclude/clap/events.h | 2+-
Minclude/clap/ext/audio-ports.h | 2+-
Minclude/clap/ext/draft/check-for-update.h | 2+-
Minclude/clap/ext/draft/event-filter.h | 2+-
Minclude/clap/ext/draft/file-reference.h | 2+-
Minclude/clap/ext/draft/midi-mappings.h | 2+-
Minclude/clap/ext/draft/note-name.h | 2+-
Minclude/clap/ext/draft/preset-load.h | 2+-
Minclude/clap/ext/draft/quick-controls.h | 2+-
Minclude/clap/ext/draft/thread-pool.h | 2+-
Minclude/clap/ext/draft/track-info.h | 2+-
Minclude/clap/ext/draft/tuning.h | 2+-
Minclude/clap/ext/draft/vst2-convert.h | 2+-
Minclude/clap/ext/draft/vst3-convert.h | 2+-
Minclude/clap/ext/event-loop.h | 3++-
Minclude/clap/ext/gui-cocoa.h | 2+-
Minclude/clap/ext/gui-free-standing.h | 2+-
Minclude/clap/ext/gui-win32.h | 2+-
Minclude/clap/ext/gui-x11.h | 2+-
Minclude/clap/ext/gui.h | 10++++------
Minclude/clap/ext/latency.h | 2+-
Minclude/clap/ext/log.h | 2+-
Minclude/clap/ext/params.h | 2+-
Minclude/clap/ext/render.h | 2+-
Minclude/clap/ext/state.h | 2+-
Minclude/clap/ext/thread-check.h | 2+-
Minclude/clap/macros.h | 17-----------------
Ainclude/clap/version.h | 35+++++++++++++++++++++++++++++++++++
30 files changed, 73 insertions(+), 58 deletions(-)

diff --git a/examples/host/plugin-host.cc b/examples/host/plugin-host.cc @@ -136,9 +136,9 @@ bool PluginHost::load(const QString &path, int pluginIndex) { } if (desc->clap_version != CLAP_VERSION) { - qWarning() << "incompatible clap version: " << CLAP_VERSION_MAJ(desc->clap_version) << "." - << CLAP_VERSION_MIN(desc->clap_version) << "." - << CLAP_VERSION_REV(desc->clap_version); + qWarning() << "incompatible clap version: " << clap_version_major(desc->clap_version) << "." + << clap_version_minor(desc->clap_version) << "." + << clap_version_revision(desc->clap_version); return false; } @@ -547,10 +547,9 @@ void PluginHost::processCC(int sampleOffset, int channel, int cc, int value) { ev.type = CLAP_EVENT_MIDI; ev.time = sampleOffset; - ev.midi.data[0] = 0; - ev.midi.data[1] = 0xB0 | channel; - ev.midi.data[2] = cc; - ev.midi.data[3] = value; + ev.midi.data[0] = 0xB0 | channel; + ev.midi.data[1] = cc; + ev.midi.data[2] = value; evIn_.push_back(ev); } diff --git a/include/clap/clap.h b/include/clap/clap.h @@ -31,14 +31,13 @@ #include "events.h" #include "macros.h" +#include "version.h" #include "string-sizes.h" #ifdef __cplusplus extern "C" { #endif -#define CLAP_VERSION CLAP_VERSION_MAKE(0, 6, 0) - ///////////// // PROCESS // ///////////// @@ -143,7 +142,7 @@ enum { typedef int32_t clap_plugin_type; typedef struct clap_plugin_descriptor { - int32_t clap_version; // initialized to CLAP_VERSION + clap_version clap_version; // initialized to CLAP_VERSION const char *id; // eg: "com.u-he.diva" const char *name; // eg: "Diva" diff --git a/include/clap/events.h b/include/clap/events.h @@ -21,7 +21,7 @@ enum { typedef int32_t clap_event_type; typedef uint32_t clap_id; -#define CLAP_INVALID_ID UINT32_MAX +static const clap_id CLAP_INVALID_ID = UINT32_MAX; /** Note On/Off event. */ typedef struct clap_event_note { diff --git a/include/clap/ext/audio-ports.h b/include/clap/ext/audio-ports.h @@ -33,7 +33,7 @@ extern "C" { /// Plugin with very complex configuration possibilities should let the user configure the ports /// from the plugin GUI, and call @ref clap_host_audio_ports.rescan(CLAP_AUDIO_PORTS_RESCAN_ALL). -#define CLAP_EXT_AUDIO_PORTS "clap/audio-ports" +static const char CLAP_EXT_AUDIO_PORTS[] = "clap/audio-ports"; typedef struct clap_audio_port_info { clap_id id; // stable identifier diff --git a/include/clap/ext/draft/check-for-update.h b/include/clap/ext/draft/check-for-update.h @@ -6,7 +6,7 @@ extern "C" { #include "../../clap.h" -#define CLAP_EXT_CHECK_FOR_UPDATE "clap/draft/check_for_update" +static const char CLAP_EXT_CHECK_FOR_UPDATE[] = "clap/draft/check_for_update"; typedef struct clap_check_for_update_info { const char *version; diff --git a/include/clap/ext/draft/event-filter.h b/include/clap/ext/draft/event-filter.h @@ -6,7 +6,7 @@ extern "C" { #include "../../clap.h" -#define CLAP_EXT_EVENT_FILTER "clap/draft/event_filter" +static const char CLAP_EXT_EVENT_FILTER[] = "clap/draft/event_filter"; // This extension lets the host know which event types the plugin is interested // in. diff --git a/include/clap/ext/draft/file-reference.h b/include/clap/ext/draft/file-reference.h @@ -3,7 +3,7 @@ #include "../../clap.h" #include "../../hash.h" -#define CLAP_EXT_FILE_REFERENCE "clap/file-reference" +static const char CLAP_EXT_FILE_REFERENCE[] = "clap/file-reference"; #ifdef __cplusplus extern "C" { diff --git a/include/clap/ext/draft/midi-mappings.h b/include/clap/ext/draft/midi-mappings.h @@ -6,7 +6,7 @@ extern "C" { #endif -#define CLAP_EXT_MIDI_MAPPINGS "clap/draft/midi-mappings" +static const char CLAP_EXT_MIDI_MAPPINGS[] = "clap/draft/midi-mappings"; enum { CLAP_MIDI_MAPPING_CC7, diff --git a/include/clap/ext/draft/note-name.h b/include/clap/ext/draft/note-name.h @@ -6,7 +6,7 @@ extern "C" { #include "../../clap.h" -#define CLAP_EXT_NOTE_NAME "clap/draft/note-name" +static const char CLAP_EXT_NOTE_NAME[] = "clap/draft/note-name"; typedef struct clap_note_name { char name[CLAP_NAME_SIZE]; diff --git a/include/clap/ext/draft/preset-load.h b/include/clap/ext/draft/preset-load.h @@ -6,7 +6,7 @@ extern "C" { #include "../../clap.h" -#define CLAP_EXT_PRESET_LOAD "clap/draft/preset-load" +static const char CLAP_EXT_PRESET_LOAD[] = "clap/draft/preset-load"; typedef struct clap_plugin_preset_load { // Loads a preset in the plugin native preset file format from a path. diff --git a/include/clap/ext/draft/quick-controls.h b/include/clap/ext/draft/quick-controls.h @@ -6,7 +6,7 @@ extern "C" { #endif -#define CLAP_EXT_QUICK_CONTROLS "clap/draft/quick-controls" +static const char CLAP_EXT_QUICK_CONTROLS[] = "clap/draft/quick-controls"; enum { CLAP_QUICK_CONTROLS_COUNT = 8 }; diff --git a/include/clap/ext/draft/thread-pool.h b/include/clap/ext/draft/thread-pool.h @@ -36,7 +36,7 @@ extern "C" { /// } /// @endcode -#define CLAP_EXT_THREAD_POOL "clap/draft/thread-pool" +static const char CLAP_EXT_THREAD_POOL[] = "clap/draft/thread-pool"; typedef struct clap_plugin_thread_pool { // Called by the thread pool diff --git a/include/clap/ext/draft/track-info.h b/include/clap/ext/draft/track-info.h @@ -8,7 +8,7 @@ extern "C" { #endif -#define CLAP_EXT_TRACK_INFO "clap/draft/track-info" +static const char CLAP_EXT_TRACK_INFO[] = "clap/draft/track-info"; typedef struct clap_track_info { clap_id id; diff --git a/include/clap/ext/draft/tuning.h b/include/clap/ext/draft/tuning.h @@ -6,7 +6,7 @@ extern "C" { #include "../../clap.h" -#define CLAP_EXT_TUNING "clap/draft/tuning" +static const char CLAP_EXT_TUNING[] = "clap/draft/tuning"; // This extension provides a dynamic tuning table to the plugin. typedef struct clap_host_tuning { diff --git a/include/clap/ext/draft/vst2-convert.h b/include/clap/ext/draft/vst2-convert.h @@ -7,7 +7,7 @@ extern "C" { #endif -#define CLAP_EXT_VST2_CONVERT "clap/draft/vst2-convert" +static const char CLAP_EXT_VST2_CONVERT[] = "clap/draft/vst2-convert"; typedef struct clap_plugin_vst2_convert { // Copies the name and VST2 plugin id that we can convert from. diff --git a/include/clap/ext/draft/vst3-convert.h b/include/clap/ext/draft/vst3-convert.h @@ -7,7 +7,7 @@ extern "C" { #endif -#define CLAP_EXT_VST3_CONVERT "clap/draft/vst3-convert" +static const char CLAP_EXT_VST3_CONVERT[] = "clap/draft/vst3-convert"; typedef struct clap_plugin_vst3_convert { // Copies the name and VST3 plugin id that we can convert from. diff --git a/include/clap/ext/event-loop.h b/include/clap/ext/event-loop.h @@ -1,13 +1,14 @@ #pragma once #include <stddef.h> + #ifdef __cplusplus extern "C" { #endif #include "../clap.h" -#define CLAP_EXT_EVENT_LOOP "clap/event-loop" +static const char CLAP_EXT_EVENT_LOOP[] = "clap/event-loop"; #ifdef _WIN32 typedef void *clap_fd; diff --git a/include/clap/ext/gui-cocoa.h b/include/clap/ext/gui-cocoa.h @@ -6,7 +6,7 @@ extern "C" { #include "../clap.h" -#define CLAP_EXT_GUI_COCOA "clap/gui-cocoa" +static const char CLAP_EXT_GUI_COCOA[] = "clap/gui-cocoa"; typedef struct clap_plugin_gui_cocoa { // [main-thread] diff --git a/include/clap/ext/gui-free-standing.h b/include/clap/ext/gui-free-standing.h @@ -2,7 +2,7 @@ #include "../clap.h" -#define CLAP_EXT_GUI_FREE_STANDING "clap/gui-free-standing" +static const char CLAP_EXT_GUI_FREE_STANDING[] = "clap/gui-free-standing"; #ifdef __cplusplus extern "C" { diff --git a/include/clap/ext/gui-win32.h b/include/clap/ext/gui-win32.h @@ -6,7 +6,7 @@ extern "C" { #endif -#define CLAP_EXT_GUI_WIN32 "clap/gui-win32" +static const char CLAP_EXT_GUI_WIN32[] = "clap/gui-win32"; // we don't want to include windows.h from this file. typedef void *clap_hwnd; diff --git a/include/clap/ext/gui-x11.h b/include/clap/ext/gui-x11.h @@ -2,7 +2,7 @@ #include "../clap.h" -#define CLAP_EXT_GUI_X11 "clap/gui-x11" +static const char CLAP_EXT_GUI_X11[] = "clap/gui-x11"; #ifdef __cplusplus extern "C" { diff --git a/include/clap/ext/gui.h b/include/clap/ext/gui.h @@ -1,9 +1,8 @@ -#ifndef CLAP_EXT_GUI_H -#define CLAP_EXT_GUI_H +#pragma once #include "../clap.h" -#define CLAP_EXT_GUI "clap/gui" +static const char CLAP_EXT_GUI[] = "clap/gui"; #ifdef __cplusplus extern "C" { @@ -37,6 +36,4 @@ typedef struct clap_host_gui { #ifdef __cplusplus } -#endif - -#endif /* !CLAP_EXT_GUI_H */ +#endif +\ No newline at end of file diff --git a/include/clap/ext/latency.h b/include/clap/ext/latency.h @@ -7,7 +7,7 @@ extern "C" { #endif -#define CLAP_EXT_LATENCY "clap/latency" +static const char CLAP_EXT_LATENCY[] = "clap/latency"; // The audio ports scan has to be done while the plugin is deactivated. typedef struct clap_plugin_latency { diff --git a/include/clap/ext/log.h b/include/clap/ext/log.h @@ -6,7 +6,7 @@ extern "C" { #include "../clap.h" -#define CLAP_EXT_LOG "clap/log" +static const char CLAP_EXT_LOG[] = "clap/log"; enum { CLAP_LOG_DEBUG = 0, diff --git a/include/clap/ext/params.h b/include/clap/ext/params.h @@ -71,7 +71,7 @@ extern "C" { /// - if a parameter is created with an id that may have been used before, call: /// - clap_host_params.clear(host, param_id, CLAP_PARAM_CLEAR_ALL) -#define CLAP_EXT_PARAMS "clap/params" +static const char CLAP_EXT_PARAMS[] = "clap/params"; enum { // Is this param stepped? (integer values only) diff --git a/include/clap/ext/render.h b/include/clap/ext/render.h @@ -2,7 +2,7 @@ #include "../clap.h" -#define CLAP_EXT_RENDER "clap/render" +static const char CLAP_EXT_RENDER[] = "clap/render"; #ifdef __cplusplus extern "C" { diff --git a/include/clap/ext/state.h b/include/clap/ext/state.h @@ -3,7 +3,7 @@ #include "../clap.h" #include "../stream.h" -#define CLAP_EXT_STATE "clap/state" +static const char CLAP_EXT_STATE[] = "clap/state"; #ifdef __cplusplus extern "C" { diff --git a/include/clap/ext/thread-check.h b/include/clap/ext/thread-check.h @@ -6,7 +6,7 @@ extern "C" { #include "../clap.h" -#define CLAP_EXT_THREAD_CHECK "clap/thread-check" +static const char CLAP_EXT_THREAD_CHECK[] = "clap/thread-check"; // This interface is useful to do runtime checks and make // sure that the functions are called on the correct threads. diff --git a/include/clap/macros.h b/include/clap/macros.h @@ -1,18 +1,5 @@ #pragma once -#include <stdint.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#define CLAP_VERSION_MAKE(Major, Minor, Revision) \ - ((((Major)&0xfff) << 20) | (((Minor)&0xfff) << 8) | ((Revision)&0xff)) - -#define CLAP_VERSION_MAJ(Version) (((Version) >> 20) & 0xfff) -#define CLAP_VERSION_MIN(Version) (((Version) >> 8) & 0xfff) -#define CLAP_VERSION_REV(Version) ((Version)&0xff) - // Define CLAP_EXPORT #if defined _WIN32 || defined __CYGWIN__ # ifdef __GNUC__ @@ -26,8 +13,4 @@ extern "C" { # else # define CLAP_EXPORT # endif -#endif - -#ifdef __cplusplus -} #endif \ No newline at end of file diff --git a/include/clap/version.h b/include/clap/version.h @@ -0,0 +1,34 @@ +#pragma once + +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef uint32_t clap_version; + +static inline clap_version clap_version_make(uint32_t major, uint32_t minor, uint32_t revision) { + return (((major & 0xfff) << 20) | ((minor & 0xfff) << 8) | (revision & 0xff)); +} + +static inline uint32_t clap_version_major(clap_version version) +{ + return ((version) >> 20) & 0xfff; +} + +static inline uint32_t clap_version_minor(clap_version version) +{ + return ((version) >> 8) & 0xfff; +} + +static inline uint32_t clap_version_revision(clap_version version) +{ + return version & 0xff; +} + +static const clap_version CLAP_VERSION = clap_version_make(0, 6, 0); + +#ifdef __cplusplus +} +#endif +\ No newline at end of file