-
Notifications
You must be signed in to change notification settings - Fork 1
/
Record.cpp
651 lines (500 loc) · 20 KB
/
Record.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
//
// by Weikton 05.09.23
//
#include "../main.h"
#include "Record.h"
#include "PluginConfig.h"
// buffer queue player interfaces
static SLAndroidSimpleBufferQueueItf bqPlayerBufferQueue;
static SLObjectItf bqPlayerObject = NULL;
static SLPlayItf bqPlayerPlay;
static SLVolumeItf bqPlayerVolume;
static SLPlaybackRateItf bqPlayerPlayBack;
static SLObjectItf outputMixObject = NULL;
void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bufferQueue, void *context)
{
LogVoice("bqPlayerCallback");
}
bool Record::Init(const uint32_t bitrate) noexcept
{
if(Record::initStatus)
return false;
if(BASS_IsStarted() == 0)
return false;
LogVoice("[sv:dbg:record:init] : module initializing...");
Record::deviceNamesList.clear();
Record::deviceNumbersList.clear();
{
BASS_DEVICEINFO devInfo {};
for(int devNumber { 0 }; BASS_RecordGetDeviceInfo(devNumber, &devInfo); ++devNumber)
{
const bool deviceEnabled = devInfo.flags & BASS_DEVICE_ENABLED;
const bool deviceLoopback = devInfo.flags & BASS_DEVICE_LOOPBACK;
const uint32_t deviceType = devInfo.flags & BASS_DEVICE_TYPE_MASK;
LogVoice("[sv:dbg:record:init] : device detect "
"[ id(%d) enabled(%hhu) loopback(%hhu) name(%s) type(0x%x) ]",
devNumber, deviceEnabled, deviceLoopback, devInfo.name != nullptr
? devInfo.name : "none", deviceType);
if(deviceEnabled && !deviceLoopback && devInfo.name != nullptr)
{
try
{
Record::deviceNumbersList.emplace_back(devNumber);
Record::deviceNamesList.emplace_back(devInfo.name);
}
catch(const std::exception& exception)
{
LogVoice("[sv:err:record:init] : failed to add device");
return false;
}
}
}
}
Memory::ScopeExit deviceListsResetScope { [] { Record::usedDeviceIndex = -1;
Record::deviceNamesList.clear();
Record::deviceNumbersList.clear(); } };
if(Record::deviceNamesList.empty() || Record::deviceNumbersList.empty())
{
LogVoice("[sv:inf:record:init] : failed to find microphone");
return false;
}
{
int opusErrorCode { -1 };
Record::encoder = opus_encoder_create(SV::kFrequency, 1,
OPUS_APPLICATION_VOIP, &opusErrorCode);
if(Record::encoder == nullptr || opusErrorCode < 0)
{
LogVoice("[sv:err:record:init] : failed to "
"create encoder (code:%d)", opusErrorCode);
return false;
}
}
Memory::ScopeExit encoderResetScope { [] { opus_encoder_destroy(Record::encoder); } };
if(const auto error = opus_encoder_ctl(Record::encoder,
OPUS_SET_BITRATE(bitrate)); error < 0)
{
LogVoice("[sv:err:record:init] : failed to "
"set bitrate for encoder (code:%d)", error);
return false;
}
if(const auto error = opus_encoder_ctl(Record::encoder,
OPUS_SET_SIGNAL(OPUS_SIGNAL_VOICE)); error < 0)
{
LogVoice("[sv:err:record:init] : failed to "
"set audiosignal type for encoder (code:%d)", error);
return false;
}
if(const auto error = opus_encoder_ctl(Record::encoder,
OPUS_SET_COMPLEXITY(10)); error < 0)
{
LogVoice("[sv:err:record:init] : failed to "
"set complexity for encoder (code:%d)", error);
return false;
}
if(const auto error = opus_encoder_ctl(Record::encoder,
OPUS_SET_PREDICTION_DISABLED(0)); error < 0)
{
LogVoice("[sv:err:record:init] : failed to "
"enable prediction for encoder (code:%d)", error);
return false;
}
if(const auto error = opus_encoder_ctl(Record::encoder,
OPUS_SET_LSB_DEPTH(8)); error < 0)
{
LogVoice("[sv:err:record:init] : failed to "
"set lsb depth for encoder (code:%d)", error);
return false;
}
if(const auto error = opus_encoder_ctl(Record::encoder,
OPUS_SET_FORCE_CHANNELS(1)); error < 0)
{
LogVoice("[sv:err:record:init] : failed to "
"set count channels for encoder (code:%d)", error);
return false;
}
if(const auto error = opus_encoder_ctl(Record::encoder,
OPUS_SET_DTX(0)); error < 0)
{
LogVoice("[sv:err:record:init] : failed to "
"set dtx for encoder (code:%d)", error);
return false;
}
if(const auto error = opus_encoder_ctl(Record::encoder,
OPUS_SET_INBAND_FEC(1)); error < 0)
{
LogVoice("[sv:err:record:init] : failed to "
"set inband fec for encoder (code:%d)", error);
return false;
}
if(const auto error = opus_encoder_ctl(Record::encoder,
OPUS_SET_PACKET_LOSS_PERC(10)); error < 0)
{
LogVoice("[sv:err:record:init] : failed to set "
"packet loss percent for encoder (code:%d)", error);
return false;
}
Record::usedDeviceIndex = -1;
if(PluginConfig::IsRecordLoaded() && !PluginConfig::GetDeviceName().empty())
{
for(std::size_t i { 0 }; i < Record::deviceNamesList.size(); ++i)
{
if(Record::deviceNamesList[i] == PluginConfig::GetDeviceName())
{
Record::usedDeviceIndex = i;
break;
}
}
}
bool initRecordStatus = BASS_RecordInit(Record::usedDeviceIndex != -1 ?
Record::deviceNumbersList[Record::usedDeviceIndex] : -1);
if(!initRecordStatus && Record::usedDeviceIndex != -1)
{
initRecordStatus = BASS_RecordInit(Record::usedDeviceIndex = -1);
}
if(initRecordStatus && Record::usedDeviceIndex == -1)
{
for(std::size_t i { 0 }; i < Record::deviceNumbersList.size(); ++i)
{
if(Record::deviceNumbersList[i] == BASS_RecordGetDevice())
{
Record::usedDeviceIndex = i;
break;
}
}
}
Memory::ScopeExit recordResetScope { [] { BASS_RecordFree(); } };
if(!initRecordStatus || Record::usedDeviceIndex == -1)
{
LogVoice("[sv:err:record:init] : failed to "
"init device (code:%d)", BASS_ErrorGetCode());
return false;
}
if(!PluginConfig::IsRecordLoaded())
{
PluginConfig::SetDeviceName(Record::deviceNamesList[Record::usedDeviceIndex]);
}
Record::recordChannel = BASS_RecordStart(SV::kFrequency2, 1,
BASS_RECORD_PAUSE, nullptr, nullptr);
if(Record::recordChannel == NULL)
{
LogVoice("[sv:err:record:init] : failed to create record "
"stream (code:%d)", BASS_ErrorGetCode());
return false;
}
Memory::ScopeExit channelResetScope { [] { BASS_ChannelStop(Record::recordChannel); } };
Record::checkChannel = BASS_StreamCreate(SV::kFrequency2, 1,
NULL, STREAMPROC_PUSH, nullptr);
if(Record::checkChannel == NULL)
{
LogVoice("[sv:err:record:init] : failed to create "
"check stream (code:%d)", BASS_ErrorGetCode());
return false;
}
BASS_ChannelSetAttribute(Record::checkChannel, BASS_ATTRIB_VOL, 4.f);
int iSamplingSize = 44100;
Record::speexEchoState = speex_echo_state_init(SV::kFrameSizeInSamples, SV::kFrameSizeInBytes);
speex_echo_ctl(Record::speexEchoState, SPEEX_ECHO_SET_SAMPLING_RATE, &iSamplingSize);
speexPreprocessState = speex_preprocess_state_init(SV::kFrameSizeInSamples, iSamplingSize);
speex_preprocess_ctl(speexPreprocessState, SPEEX_PREPROCESS_SET_ECHO_STATE, speexEchoState);
/*
// create engine
SLresult result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
if(result != SL_RESULT_SUCCESS)
{
LogVoice("[sv:err:record:init] : failed to create "
"engine");
return false;
}
// realize the engine
result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
if(result != SL_RESULT_SUCCESS)
{
LogVoice("[sv:err:record:init] : failed to realize "
"engine");
return false;
}
// create output mix, with environmental reverb specified as a non-required interface
const SLInterfaceID idss[1] = { SL_IID_PLAYBACKRATE };
const SLboolean reqss[1] = { SL_BOOLEAN_FALSE };
result = (*engineEngine)->CreateOutputMix(engineEngine, &outputMixObject, 1, idss, reqss);
assert(SL_RESULT_SUCCESS == result);
// realize the output mix
result = (*outputMixObject)->Realize(outputMixObject, SL_BOOLEAN_FALSE);
assert(SL_RESULT_SUCCESS == result);
// configure audio source
SLDataLocator_AndroidSimpleBufferQueue loc_bufq = { SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE, 2 };
SLDataFormat_PCM format_pcm = { SL_DATAFORMAT_PCM, 1, SL_SAMPLINGRATE_44_1, SL_PCMSAMPLEFORMAT_FIXED_16, SL_PCMSAMPLEFORMAT_FIXED_16, SL_SPEAKER_FRONT_CENTER, SL_BYTEORDER_LITTLEENDIAN };
SLDataSource audioSrcs = { &loc_bufq, &format_pcm };
// configure audio sink
SLDataLocator_OutputMix loc_outmix = { SL_DATALOCATOR_OUTPUTMIX, outputMixObject };
SLDataSink audioSnks = { &loc_outmix, NULL };
// create audio player
const SLInterfaceID ids[4] = { SL_IID_PLAYBACKRATE, SL_IID_BUFFERQUEUE, SL_IID_VOLUME, SL_IID_ANDROIDCONFIGURATION };
const SLboolean reqs[4] = { SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE };
result = (*engineEngine)->CreateAudioPlayer(engineEngine, &bqPlayerObject, &audioSrcs, &audioSnks, 4, ids, reqs);
assert(SL_RESULT_SUCCESS == result);
// realize the player
result = (*bqPlayerObject)->Realize(bqPlayerObject, SL_BOOLEAN_FALSE);
assert(SL_RESULT_SUCCESS == result);
// get the configure interface
SLAndroidConfigurationItf playerConfig;
result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_ANDROIDCONFIGURATION, &playerConfig);
assert(SL_RESULT_SUCCESS == result);
// get the play interface
result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_PLAY, &bqPlayerPlay);
assert(SL_RESULT_SUCCESS == result);
// get the buffer queue interface
result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_BUFFERQUEUE, &bqPlayerBufferQueue);
assert(SL_RESULT_SUCCESS == result);
// get the playback rate interface
result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_PLAYBACKRATE, &bqPlayerPlayBack);
assert(SL_RESULT_SUCCESS == result);
// get the volume interface
result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_VOLUME, &bqPlayerVolume);
assert(SL_RESULT_SUCCESS == result);
// set stream to voice call
SLint32 streamType = SL_ANDROID_STREAM_VOICE;
result = (*playerConfig)->SetConfiguration(playerConfig, SL_ANDROID_KEY_STREAM_TYPE, &streamType, sizeof(SLint32));
assert(SL_RESULT_SUCCESS == result);
// register callback on the buffer queue
result = (*bqPlayerBufferQueue)->RegisterCallback(bqPlayerBufferQueue, bqPlayerCallback, NULL);
assert(SL_RESULT_SUCCESS == result);
// set the player's state to playing
result = (*bqPlayerPlay)->SetPlayState(bqPlayerPlay, SL_PLAYSTATE_PLAYING);
assert(SL_RESULT_SUCCESS == result);
float fVolume = 1.f;
// get min & max volume
SLmillibel minVolume = SL_MILLIBEL_MIN;
SLmillibel maxVolume = SL_MILLIBEL_MIN;
result = (*bqPlayerVolume)->GetMaxVolumeLevel(bqPlayerVolume, &maxVolume);
assert(SL_RESULT_SUCCESS == result);
SLmillibel volume = minVolume + (SLmillibel)(((float)(maxVolume - minVolume)) * fVolume);
// set the player's volume
result = (*bqPlayerVolume)->SetVolumeLevel(bqPlayerVolume, volume);
assert(SL_RESULT_SUCCESS == result);
*/
if(!PluginConfig::IsRecordLoaded())
{
PluginConfig::SetRecordLoaded(true);
Record::ResetConfigs();
}
deviceListsResetScope.Release();
encoderResetScope.Release();
recordResetScope.Release();
channelResetScope.Release();
LogVoice("[sv:dbg:record:init] : module initialized");
Record::initStatus = true;
Record::SyncConfigs();
return true;
}
bool Record::IsInited() noexcept
{
return Record::initStatus;
}
void Record::Free() noexcept
{
if(!Record::initStatus)
return;
LogVoice("[sv:dbg:record:free] : module releasing...");
Record::StopRecording();
BASS_ChannelStop(Record::recordChannel);
BASS_RecordFree();
Record::StopChecking();
BASS_StreamFree(Record::checkChannel);
opus_encoder_destroy(Record::encoder);
Record::usedDeviceIndex = -1;
Record::deviceNumbersList.clear();
Record::deviceNamesList.clear();
LogVoice("[sv:dbg:record:free] : module released");
Record::initStatus = false;
}
void Record::Tick() noexcept
{
if(!Record::initStatus || !Record::checkStatus)
return;
if(const auto bufferSize = BASS_ChannelGetData(Record::recordChannel,
nullptr, BASS_DATA_AVAILABLE); bufferSize != -1 && bufferSize != 0)
{
if(const auto readDataSize = BASS_ChannelGetData(Record::recordChannel, Record::encBuffer.data(),
clampEx(bufferSize, 0ul, SV::kFrameSizeInBytes)); readDataSize != -1 && readDataSize != 0)
{
std::array<opus_int16, SV::kFrameSizeInSamples> encOutBuffer {};
// perform echo canceling
speex_echo_capture(speexEchoState, Record::encBuffer.data(), encOutBuffer.data());
// apply noise/echo suppresion
speex_preprocess_run(speexPreprocessState, encOutBuffer.data());
// playback the audio and reset echo canceller if we got underrun
BASS_StreamPutData(Record::checkChannel, encOutBuffer.data(), readDataSize);
//speex_echo_state_reset(speexEchoState);
// put frame into playback buffer
speex_echo_playback(speexEchoState, Record::encBuffer.data());
//(*bqPlayerBufferQueue)->Enqueue(bqPlayerBufferQueue, Record::encBuffer.data(), readDataSize);
}
}
}
uint32_t Record::GetFrame(uint8_t* const bufferPtr, const uint32_t bufferSize) noexcept
{
if(!Record::initStatus || !Record::recordStatus || Record::checkStatus)
return NULL;
LogVoice("Stuck?");
const auto cBufferSize = BASS_ChannelGetData(Record::recordChannel, nullptr, BASS_DATA_AVAILABLE);
if(cBufferSize == -1 || cBufferSize < SV::kFrameSizeInBytes) return NULL;
if(BASS_ChannelGetData(Record::recordChannel, Record::encBuffer.data(),
SV::kFrameSizeInBytes) != SV::kFrameSizeInBytes) return NULL;
std::array<opus_int16, SV::kFrameSizeInSamples> encOutBuffer {};
// perform echo canceling
speex_echo_capture(Record::speexEchoState, Record::encBuffer.data(), encOutBuffer.data());
LogVoice("Here?");
const auto encDataLength = opus_encode(Record::encoder, encOutBuffer.data(),
SV::kFrameSizeInSamples, bufferPtr, bufferSize);
LogVoice("Here!");
return encDataLength > 0 ? static_cast<uint32_t>(encDataLength) : NULL;
}
bool Record::HasMicro() noexcept
{
BASS_DEVICEINFO devInfo {};
for(uint32_t devNumber { 0 }; BASS_RecordGetDeviceInfo(devNumber, &devInfo); ++devNumber)
{
const bool deviceEnabled = devInfo.flags & BASS_DEVICE_ENABLED;
const bool deviceLoopback = devInfo.flags & BASS_DEVICE_LOOPBACK;
if(deviceEnabled && !deviceLoopback && devInfo.name != nullptr)
return true;
}
return false;
}
bool Record::StartRecording() noexcept
{
if(!Record::initStatus || Record::recordStatus || Record::checkStatus)
return false;
if(!PluginConfig::GetMicroEnable())
return false;
LogVoice("[sv:dbg:record:startrecording] : channel recording starting...");
BASS_ChannelPlay(Record::recordChannel, 0);
Record::recordStatus = true;
return true;
}
bool Record::IsRecording() noexcept
{
return Record::recordStatus;
}
void Record::StopRecording() noexcept
{
if(!Record::initStatus)
return;
Record::recordStatus = false;
if(Record::checkStatus)
return;
BASS_ChannelPause(Record::recordChannel);
opus_encoder_ctl(Record::encoder, OPUS_RESET_STATE);
LogVoice("[sv:dbg:record:stoprecording] : channel recording stoped");
const auto bufferSize = BASS_ChannelGetData(Record::recordChannel, nullptr, BASS_DATA_AVAILABLE);
if(bufferSize == -1 && bufferSize == 0) return;
BASS_ChannelGetData(Record::recordChannel, nullptr, bufferSize);
}
bool Record::StartChecking() noexcept
{
if(!Record::initStatus || Record::checkStatus)
return false;
if(!PluginConfig::GetMicroEnable())
return false;
Record::StopRecording();
LogVoice("[sv:dbg:record:startchecking] : checking device starting...");
BASS_ChannelPlay(Record::checkChannel, 1);
BASS_ChannelPlay(Record::recordChannel, 1);
Record::checkStatus = true;
return true;
}
bool Record::IsChecking() noexcept
{
return Record::checkStatus;
}
void Record::StopChecking() noexcept
{
if(Record::initStatus && Record::checkStatus)
{
LogVoice("[sv:dbg:record:stopchecking] : checking device stoped");
BASS_ChannelStop(Record::checkChannel);
Record::checkStatus = false;
}
}
bool Record::GetMicroEnable() noexcept
{
return PluginConfig::GetMicroEnable();
}
int Record::GetMicroVolume() noexcept
{
return PluginConfig::GetMicroVolume();
}
int Record::GetMicroDevice() noexcept
{
return Record::usedDeviceIndex;
}
void Record::SetMicroEnable(const bool microEnable) noexcept
{
if(!Record::initStatus)
return;
PluginConfig::SetMicroEnable(microEnable);
if(!PluginConfig::GetMicroEnable())
{
Record::StopRecording();
Record::StopChecking();
}
}
void Record::SetMicroVolume(const int microVolume) noexcept
{
if(!Record::initStatus)
return;
PluginConfig::SetMicroVolume(clampEx(microVolume, 0, 100));
BASS_RecordSetInput(-1, BASS_INPUT_ON, static_cast<float>
(PluginConfig::GetMicroVolume()) / 100.f);
}
void Record::SetMicroDevice(const int deviceIndex) noexcept
{
if(!Record::initStatus)
return;
/*const auto devNamesCount = Record::deviceNamesList.size();
const auto devNumbersCount = Record::deviceNumbersList.size();
if(deviceIndex < 0 || deviceIndex >= fmin(devNamesCount, devNumbersCount))
return;
if(deviceIndex == Record::usedDeviceIndex)
return;
BASS_ChannelStop(Record::recordChannel);
BASS_RecordFree();
const auto oldDevIndex = Record::usedDeviceIndex;
if(BASS_RecordInit(Record::deviceNumbersList[Record::usedDeviceIndex = deviceIndex]) == 0 &&
BASS_RecordInit(Record::deviceNumbersList[Record::usedDeviceIndex = oldDevIndex]) == 0)
return;
Record::recordChannel = BASS_RecordStart(SV::kFrequency2, 1, !Record::recordStatus &&
!Record::checkStatus ? BASS_RECORD_PAUSE : NULL, nullptr, nullptr);
PluginConfig::SetDeviceName(Record::deviceNamesList[Record::usedDeviceIndex]);*/
}
void Record::SyncConfigs() noexcept
{
Record::SetMicroEnable(PluginConfig::GetMicroEnable());
Record::SetMicroVolume(PluginConfig::GetMicroVolume());
}
void Record::ResetConfigs() noexcept
{
PluginConfig::SetMicroEnable(PluginConfig::kDefValMicroEnable);
PluginConfig::SetMicroVolume(PluginConfig::kDefValMicroVolume);
}
const std::vector<std::string>& Record::GetDeviceNamesList() noexcept
{
return Record::deviceNamesList;
}
const std::vector<int>& Record::GetDeviceNumbersList() noexcept
{
return Record::deviceNumbersList;
}
bool Record::initStatus { false };
bool Record::checkStatus { false };
bool Record::recordStatus { false };
HRECORD Record::recordChannel { NULL };
OpusEncoder* Record::encoder { nullptr };
std::array<opus_int16, SV::kFrameSizeInSamples> Record::encBuffer {};
HSTREAM Record::checkChannel { NULL };
int Record::usedDeviceIndex { -1 };
std::vector<std::string> Record::deviceNamesList;
std::vector<int> Record::deviceNumbersList;
SpeexEchoState *Record::speexEchoState { NULL };
SpeexPreprocessState *Record::speexPreprocessState { NULL };