Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
au_factory_presets.hpp
Go to the documentation of this file.
1#pragma once
2
16
19#if defined(__APPLE__)
20
21#include <AudioToolbox/AudioToolbox.h>
22#include <CoreFoundation/CoreFoundation.h>
23
25#include <pulp/state/store.hpp>
26
27#include <cstddef>
28#include <filesystem>
29#include <memory>
30#include <string>
31#include <vector>
32
34
44std::filesystem::path factory_presets_dir_for_binary(const std::filesystem::path& binary);
45
48std::filesystem::path loaded_bundle_factory_presets_dir();
49
57 public:
58 FactoryPresetTable() = default;
60
63
68 void bind(state::StateStore& store, const std::string& manufacturer,
69 const std::string& plugin_name);
70
74 void set_directory(const std::filesystem::path& dir);
75
77 std::size_t size() const noexcept {
78 return entries_.size();
79 }
80
82 std::string name_at(std::size_t index) const;
83
96 bool load(std::size_t index);
97
101 const AUPreset* preset_at(std::size_t index) const noexcept;
102
108 OSStatus copy_presets(CFArrayRef* out_data) const;
109
112 return presets_.get();
113 }
114
115 private:
116 void rebuild();
117 void clear_entries() noexcept;
118
119 // The PresetManager holds the StateStore reference; the table itself
120 // never touches the store directly.
121 std::unique_ptr<state::PresetManager> presets_;
122 // Parallel arrays, same order and length: `entries_[i].presetName` is a
123 // +1 CFStringRef this table releases, and `infos_[i]` is the preset
124 // `load(i)` reads.
125 std::vector<AUPreset> entries_;
126 std::vector<state::PresetInfo> infos_;
127};
128
129} // namespace pulp::format::au
130
131#endif // __APPLE__
std::size_t size() const noexcept
Number of factory presets the host can select.
Definition au_factory_presets.hpp:77
state::PresetManager * preset_manager() noexcept
The PresetManager behind the table, or null before bind.
Definition au_factory_presets.hpp:111
OSStatus copy_presets(CFArrayRef *out_data) const
AUBase::GetPresets.
FactoryPresetTable(const FactoryPresetTable &)=delete
bool load(std::size_t index)
Load preset index into the bound StateStore.
std::string name_at(std::size_t index) const
UTF-8 display name of preset index, or empty when out of range.
const AUPreset * preset_at(std::size_t index) const noexcept
The canonical AUPreset for index, owned by this table.
void bind(state::StateStore &store, const std::string &manufacturer, const std::string &plugin_name)
Bind to the plug-in's StateStore and identity, and scan the bundle the adapter was loaded from.
void set_directory(const std::filesystem::path &dir)
Re-point discovery at dir and rebuild the table.
FactoryPresetTable & operator=(const FactoryPresetTable &)=delete
Built-in preset manager for Pulp plugins.
Definition preset_manager.hpp:60
Centralized parameter storage with lock-free value access.
Definition store.hpp:164
Apple-only: the whole header is gated on APPLE so it stays an empty no-op on the Linux header-hygiene...
Definition au_factory_presets.hpp:33
std::filesystem::path factory_presets_dir_for_binary(const std::filesystem::path &binary)
Map a plug-in binary's path to the folder holding its factory presets.
std::filesystem::path loaded_bundle_factory_presets_dir()
factory_presets_dir_for_binary applied to the image this code is linked into.
@ vector
a block of samples for a scope-style display
Definition editor_host.hpp:237
SequencerStateChannel is the audio-safe transport for a plugin's structured NON-parameter state: the ...
Definition audio_device_manager.hpp:48
STL namespace.
Built-in preset management — save/load/delete/rename/import.