Pulp
1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
au_v2_instrument_entry.hpp
Go to the documentation of this file.
1
#pragma once
2
3
// AU v2 instrument entry point generator
4
// For synths/samplers that receive MIDI and produce audio (aumu type)
5
//
6
// Usage (in one .cpp file per AU instrument plugin):
7
// #include "my_synth.hpp"
8
// #include <pulp/format/au_v2_instrument_entry.hpp>
9
// PULP_AU_INSTRUMENT(MySynthAU, my_namespace::create_my_synth)
10
11
// Apple-only: wraps AudioUnitSDK. No-op on non-Apple so the header stays
12
// self-contained on the Linux header-hygiene check.
13
#if defined(__APPLE__)
14
15
#include <
pulp/format/au_v2_instrument.hpp
>
16
#include <
pulp/format/registry.hpp
>
17
#include <AudioUnitSDK/AUPlugInDispatch.h>
18
#include <AudioUnitSDK/ComponentBase.h>
19
20
// Generate an AU v2 instrument entry point.
21
// ClassName determines the factory function name: ClassNameFactory
22
// factory_fn is the ProcessorFactory function
23
#define PULP_AU_INSTRUMENT(ClassName, factory_fn) \
24
PULP_REGISTER_PLUGIN(factory_fn) \
25
class ClassName : public pulp::format::au::PulpAUInstrument { \
26
public: \
27
explicit ClassName(AudioComponentInstance ci) : PulpAUInstrument(ci) {} \
28
}; \
29
AUSDK_COMPONENT_ENTRY(ausdk::AUMusicDeviceFactory, ClassName)
30
31
// ── Multi-plugin bundle variant ──────────────────────────────────────────
32
// One binary hosts many instruments (`aumu`). Binds each component to its own
33
// factory lexically (via the factory-taking PulpAUInstrument ctor), so the
34
// base-ctor output-element probe and processor construction never consult the
35
// legacy global slot, and registers a KEYED entry (which never touches that
36
// global). Expand once per component; N per binary is legal. The trailing arg
37
// is a PluginRegistration braced-init carrying id + AU codes (WITHOUT
38
// `.factory` — bound from factory_fn, see PULP_AU_BUNDLE_ENTRY_); it is
39
// variadic so its internal commas survive the preprocessor.
40
#define PULP_AU_BUNDLE_INSTRUMENT(ClassName, factory_fn, ...) \
41
namespace { \
42
struct ClassName##_Registrar { \
43
ClassName##_Registrar() { \
44
::pulp::format::PluginRegistration reg __VA_ARGS__; \
45
reg.factory = factory_fn; \
46
::pulp::format::register_plugin(reg); \
47
} \
48
} ClassName##_registrar_; \
49
} \
50
class ClassName : public pulp::format::au::PulpAUInstrument { \
51
public: \
52
explicit ClassName(AudioComponentInstance ci) \
53
: PulpAUInstrument(ci, factory_fn) {} \
54
}; \
55
AUSDK_COMPONENT_ENTRY(ausdk::AUMusicDeviceFactory, ClassName)
56
57
#endif
// defined(__APPLE__)
au_v2_instrument.hpp
registry.hpp
core
format
include
pulp
format
au_v2_instrument_entry.hpp
Generated by
1.15.0