-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAECDlg.cpp
87 lines (74 loc) · 1.7 KB
/
AECDlg.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
// AECDlg.cpp : implementation file
//
#include <windows.h>
#include "general.h"
#include "AECDlg.h"
#include "WaveIn.h"
#include "WaveOut.h"
#include "delayTone.h"
#include <QDebug>
#define PROGRAM_MAJOR_VERSION 1
#define PROGRAM_MINOR_VERSION 0
int __argc ;
char** __argv ;
// CAECDlg message handlers
bool CAECDlg::aecStart()
{
pWaveIn = new CWaveIn();
pWaveOut= new CWaveOut();
started= false;
aecRun();
return true; // return TRUE unless you set the focus to a control
}
int CAECDlg::OpenInputDevice(void)
{
MMRESULT mRes = 0 ;
mRes = pWaveIn->OpenDevice(0,22050,1,16);
if(mRes!=MMSYSERR_NOERROR)
{
return FAILURE;
}
return SUCCESS;
}
int CAECDlg::OpenOutputDevice(void)
{
MMRESULT mRes= 0 ;
mRes = pWaveOut->OpenDevice(0,22050,1,16);
if(mRes!=MMSYSERR_NOERROR)
{
return FAILURE;
}
return SUCCESS;
}
void CAECDlg::aecRun()
{
if(!started)
{
if(OpenInputDevice()==FAILURE)
{
qWarning("Problem opening input device, returning...","Error");
return;
}
if(pWaveIn->StartCapture(CHUNK_RATIO)!= SUCCESS)
{
qWarning("Problem starting input device, returning...","Error");
return;
}
if(OpenOutputDevice()==FAILURE)
{
qWarning("Problem opening output device, returning...","Error");
return;
}
if(pWaveOut->StartPlay(CHUNK_RATIO)!= SUCCESS)
{
qWarning("Problem starting input device, returning...","Error");
return;
}
pWaveOut->pReaderQ->Connect(pWaveIn->pWriterQ);
started = true;
}
else
{
qWarning("Program is active now","Warning");
}
}