-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtils.cpp
56 lines (45 loc) · 1.62 KB
/
Utils.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
//---------------------------------------------------------------------------
#pragma hdrstop
#include <MMSystem.h>
#include "Utils.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
namespace PitchDet {
WaveInDevsCont GetWaveInDevices()
{
WaveInDevsCont Devs;
/* Get the number of Digital Audio In devices in this computer */
auto iNumDevs = ::waveInGetNumDevs();
Devs.reserve( iNumDevs );
WAVEINCAPS wic;
/* Go through all of those devices, displaying their names */
for ( decltype( iNumDevs ) i {} ; i < iNumDevs ; ++i ) {
/* Get info about the next device */
if ( !waveInGetDevCaps( i, &wic, sizeof wic ) ) {
Devs.emplace_back( wic.szPname );
}
}
return Devs;
}
//---------------------------------------------------------------------------
void AppendWaveInDevices( TStrings& DeviceNames )
{
struct UpdateMngr {
TStrings& sl_;
UpdateMngr( TStrings& SL ) : sl_{ SL } { SL.BeginUpdate(); }
~UpdateMngr() { try { sl_.EndUpdate(); } catch ( ... ) {} }
}
Mngr { DeviceNames };
WAVEINCAPS wic;
/* Get the number of Digital Audio In devices in this computer */
auto iNumDevs = ::waveInGetNumDevs();
/* Go through all of those devices, displaying their names */
for ( decltype( iNumDevs ) i {} ; i < iNumDevs ; ++i ) {
/* Get info about the next device */
if ( !waveInGetDevCaps( i, &wic, sizeof wic ) ) {
DeviceNames.Append( wic.szPname );
}
}
}
//---------------------------------------------------------------------------
}