Switchboard Extension SDK
Toggle main menu visibility
Loading...
Searching...
No Matches
SwitchboardCore.hpp
1
//
2
// SwitchboardCore.hpp
3
// SwitchboardSDK
4
//
5
// Created by Balázs Kiss on 2022. 02. 22..
6
// Copyright © 2022. Synervoz Inc. All rights reserved.
7
//
8
9
#pragma once
10
11
#include "SwitchboardVersion.hpp"
12
#include <switchboard_core/Platform.hpp>
13
14
#include <algorithm>
15
#include <atomic>
16
#include <cassert>
17
#include <cstdio>
18
#include <cstdlib>
19
#include <cstring>
20
#include <memory>
21
#include <string>
22
23
// MARK: - Types
24
25
// Check if data sizes are standard
26
static_assert
(
sizeof
(char) == 1);
27
static_assert
(
sizeof
(short) == 2);
28
static_assert
(
sizeof
(int) == 4);
29
static_assert
(
sizeof
(
long
long) == 8);
30
31
// Define fixed-size data types
32
using
int8 = char;
33
using
uint8 =
unsigned
char;
34
using
int16 = int16_t;
35
using
uint16 = uint16_t;
36
using
int64 = int64_t;
37
using
uint64 = uint64_t;
38
using
uint = uint32_t;
39
40
// MARK: - Constants
41
42
namespace
switchboard::constants {
43
44
static
constexpr
uint DEFAULT_SAMPLERATE = 44100;
45
static
constexpr
uint MAX_SAMPLERATE = 48000;
46
static
constexpr
uint MAX_BUFFER_DURATION_MS = 1000;
47
static
constexpr
uint MAX_NUMBER_OF_FRAMES = MAX_SAMPLERATE * MAX_BUFFER_DURATION_MS / 1000;
48
// ~85ms@48kHz or ~93ms@44.1kHz
49
static
constexpr
uint LEGACY_MAX_NUMBER_OF_FRAMES = 4096;
50
51
static
constexpr
uint NUM_CHANNELS_UNDEFINED = 0;
52
static
constexpr
uint MONO = 1;
53
static
constexpr
uint STEREO = 2;
54
static
constexpr
uint QUAD = 4;
55
56
static
constexpr
uint LEFT = 0;
57
static
constexpr
uint RIGHT = 1;
58
59
static
constexpr
uint SAMPLE_RATE_UNDEFINED = 0;
60
static
constexpr
uint SAMPLE_RATE_8KHz = 8000;
61
static
constexpr
uint SAMPLE_RATE_10KHz = 10000;
62
static
constexpr
uint SAMPLE_RATE_16KHz = 16000;
63
static
constexpr
uint SAMPLE_RATE_24KHz = 24000;
64
static
constexpr
uint SAMPLE_RATE_44_1KHz = 44100;
65
static
constexpr
uint SAMPLE_RATE_48KHz = 48000;
66
67
}
68
69
// MARK: - Preprocessor directives
70
71
// Web-specific defines
72
#if defined(SWITCHBOARD_WEB)
73
#include <emscripten.h>
74
#else
75
#endif
76
77
#if NETWORKING_ENABLED && SWITCHBOARD_LICENSE_VALIDATION_ENABLED
78
#define LICENSE_VALIDATION_ENABLED true
79
#else
80
#define LICENSE_VALIDATION_ENABLED false
81
#endif
82
83
#if !defined(M_PI)
84
#define M_PI 3.1415926535897932384626433832
85
#endif
86
87
#if !defined(M_PI_2)
88
#define M_PI_2 (M_PI / 2)
89
#endif
90
91
#if defined(__has_cpp_attribute) && __has_cpp_attribute(clang::nonblocking)
92
#define NONBLOCKING [[clang::nonblocking]]
93
#else
94
#define NONBLOCKING
95
#endif
SwitchboardSDK
include
switchboard_core
SwitchboardCore.hpp
Generated by
1.17.0