beeping-core 2.0.0
C++20 library for encoding and decoding data over sound
Loading...
Searching...
No Matches
BeepingConfig.h
1#ifndef __BEEPINGCONFIG__
2#define __BEEPINGCONFIG__
3
4namespace BEEPING {
5struct BeepingConfig {
6 // Mathematical constants
7 static constexpr float pi = 3.14159265358979323846f;
8 static constexpr float two_pi = 2.f * 3.14159265358979323846f;
9
10 // Timing parameters
11 float durToken = 0.104489796f;
12 float durFade = 0.075f;
13 float tokenAmplitude = 0.7f;
14
15 // Token/tone counts
16 int numTokensAll = 32;
17 int numTonesAll = 9;
18 int numTokensAudible = 32;
19 int numTokensNonAudible = 32;
20 int numTonesAudibleMultiTone = 9;
21 int numTonesNonAudibleMultiTone = 9;
22
23 // Frequency offsets (computed by compute_config)
24 int nBinsOffsetForAudibleMultiTone = 12;
25 float freqOffsetForAudibleMultiTone = 258.398442f;
26 int nBinsOffsetForNonAudibleMultiTone = 4;
27 float freqOffsetForNonAudibleMultiTone = 86.1328141638f;
28
29 // Adaptive inaudible base frequency (computed by compute_config)
30 // At 44.1k+: 17800 Hz. At lower rates: drops to fit under Nyquist.
31 float inaudibleBaseFreq = 17800.f;
32
33 // Synth parameters (used internally by encoders)
34 float synthVolume = 0.f;
35
36 // Front door tokens
37 char frontDoorTokens[2] = {'1', 'o'};
38};
39
40// Pure function: computes derived config from FFT size and sample rate
41BeepingConfig compute_config(int windowSize, float sampleRate);
42
43} // namespace BEEPING
44
45#endif // __BEEPINGCONFIG__