Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
sample_pool.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <cstdint>
5#include <limits>
6#include <span>
7#include <vector>
8
11
12namespace pulp::audio {
13
14inline constexpr std::uint32_t kInvalidSamplePoolId =
16
22
24 bool valid = false;
26 std::uint32_t entry_index = 0;
27 const PublishedSampleStore* store = nullptr;
29};
30
32public:
33 SamplePool() = default;
34
35 static bool entry_valid(const SamplePoolEntry& entry) noexcept;
36
37 // Control/background-thread only. Copies and may allocate. Entries borrow
38 // PublishedSampleStore instances; owners must keep those stores alive,
39 // prepared, and not destructively reset/released/reprepared while any
40 // realtime reader can resolve from this pool. Replace sample contents via
41 // generation-safe publication, then publish a new pool snapshot when the
42 // pool should resolve to a new view.
43 bool configure(std::span<const SamplePoolEntry> entries);
44 void clear() noexcept;
45
46 std::span<const SamplePoolEntry> entries() const noexcept { return entries_; }
47 bool empty() const noexcept { return entries_.empty(); }
48 std::size_t size() const noexcept { return entries_.size(); }
49
50 // RT-safe when the pool is immutable for the duration of the call and the
51 // borrowed PublishedSampleStore lifetimes are externally guaranteed.
52 SamplePoolResolution resolve(std::uint32_t sample_id) const noexcept;
53
54 static const float* channel_data(const SamplePoolResolution& resolution,
55 std::uint32_t channel) noexcept;
56 static bool populate_channel_ptrs(const SamplePoolResolution& resolution,
57 const float** channel_ptrs,
58 std::size_t channel_capacity) noexcept;
59
60private:
61 std::vector<SamplePoolEntry> entries_;
62};
63
64} // namespace pulp::audio
Definition published_sample_store.hpp:28
SamplePoolResolution resolve(std::uint32_t sample_id) const noexcept
static bool populate_channel_ptrs(const SamplePoolResolution &resolution, const float **channel_ptrs, std::size_t channel_capacity) noexcept
void clear() noexcept
static const float * channel_data(const SamplePoolResolution &resolution, std::uint32_t channel) noexcept
bool empty() const noexcept
Definition sample_pool.hpp:47
std::size_t size() const noexcept
Definition sample_pool.hpp:48
static bool entry_valid(const SamplePoolEntry &entry) noexcept
std::span< const SamplePoolEntry > entries() const noexcept
Definition sample_pool.hpp:46
bool configure(std::span< const SamplePoolEntry > entries)
Definition analyzer_provider.hpp:12
constexpr std::uint32_t kInvalidSamplePoolId
Definition sample_pool.hpp:14
constexpr std::uint32_t kInvalidSampleId
Definition sample_identity.hpp:8
STL namespace.
Definition sample_slot_bank.hpp:22
Definition sample_pool.hpp:17
const PublishedSampleStore * store
Definition sample_pool.hpp:19
std::uint32_t sample_id
Definition sample_pool.hpp:18
PublishedSampleView view
Definition sample_pool.hpp:20
Definition sample_pool.hpp:23
std::uint32_t entry_index
Definition sample_pool.hpp:26
std::uint32_t sample_id
Definition sample_pool.hpp:25
const PublishedSampleStore * store
Definition sample_pool.hpp:27
bool valid
Definition sample_pool.hpp:24
PublishedSampleView view
Definition sample_pool.hpp:28