Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
channel_set.hpp
Go to the documentation of this file.
1#pragma once
2
3// Named channel layouts for surround and immersive audio.
4// Maps channel indices to speaker positions.
5
6#include <string>
7#include <string_view>
8#include <vector>
9#include <cstdint>
10
11namespace pulp::audio {
12
31
33struct ChannelSet {
34 std::string name;
35 std::vector<Speaker> speakers;
36
37 uint32_t size() const { return static_cast<uint32_t>(speakers.size()); }
38
39 bool operator==(const ChannelSet& other) const {
40 return speakers == other.speakers;
41 }
42
43 // ── Standard layouts ────────────────────────────────────────────────
44
45 static ChannelSet mono() {
46 return {"Mono", {Speaker::FrontCenter}};
47 }
48
49 static ChannelSet stereo() {
50 return {"Stereo", {Speaker::FrontLeft, Speaker::FrontRight}};
51 }
52
56
61
66
71
77
87
89 static ChannelSet discrete(uint32_t num_channels) {
90 ChannelSet cs;
91 cs.name = "Discrete " + std::to_string(num_channels);
92 cs.speakers.resize(num_channels, Speaker::Discrete);
93 return cs;
94 }
95
97 static ChannelSet from_channel_count(uint32_t count) {
98 switch (count) {
99 case 1: return mono();
100 case 2: return stereo();
101 case 3: return lrc();
102 case 4: return quad();
103 case 5: return surround_5_0();
104 case 6: return surround_5_1();
105 case 8: return surround_7_1();
106 case 12: return surround_7_1_4();
107 default: return discrete(count);
108 }
109 }
110
112 static ChannelSet from_name(std::string_view name);
113};
114
116std::string speaker_name(Speaker speaker);
117
118} // namespace pulp::audio
Definition analyzer_provider.hpp:12
Speaker
Speaker position identifiers.
Definition channel_set.hpp:14
@ FrontRight
Definition channel_set.hpp:16
@ SideRight
Definition channel_set.hpp:22
@ FrontLeft
Definition channel_set.hpp:15
@ Discrete
Definition channel_set.hpp:29
@ LFE
Definition channel_set.hpp:18
@ SideLeft
Definition channel_set.hpp:21
@ TopBackRight
Definition channel_set.hpp:26
@ TopCenter
Definition channel_set.hpp:27
@ BackRight
Definition channel_set.hpp:20
@ BackLeft
Definition channel_set.hpp:19
@ FrontCenter
Definition channel_set.hpp:17
@ TopBackLeft
Definition channel_set.hpp:25
@ TopFrontRight
Definition channel_set.hpp:24
@ TopFrontLeft
Definition channel_set.hpp:23
std::string speaker_name(Speaker speaker)
Get the speaker name as a string (e.g., "Front Left", "LFE").
Named channel layout — maps channel indices to speaker positions.
Definition channel_set.hpp:33
uint32_t size() const
Definition channel_set.hpp:37
static ChannelSet from_channel_count(uint32_t count)
Get a standard layout by channel count (best guess).
Definition channel_set.hpp:97
static ChannelSet surround_5_1()
Definition channel_set.hpp:67
static ChannelSet quad()
Definition channel_set.hpp:57
static ChannelSet surround_7_1()
Definition channel_set.hpp:72
static ChannelSet from_name(std::string_view name)
Get a standard layout by name.
static ChannelSet surround_5_0()
Definition channel_set.hpp:62
static ChannelSet lrc()
Definition channel_set.hpp:53
static ChannelSet surround_7_1_4()
Definition channel_set.hpp:78
std::vector< Speaker > speakers
Definition channel_set.hpp:35
static ChannelSet stereo()
Definition channel_set.hpp:49
static ChannelSet mono()
Definition channel_set.hpp:45
static ChannelSet discrete(uint32_t num_channels)
Create a discrete (unnamed) channel set with N channels.
Definition channel_set.hpp:89
std::string name
Definition channel_set.hpp:34
bool operator==(const ChannelSet &other) const
Definition channel_set.hpp:39