-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsoundmanage.cpp
More file actions
37 lines (31 loc) · 967 Bytes
/
soundmanage.cpp
File metadata and controls
37 lines (31 loc) · 967 Bytes
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
#include "soundmanage.h"
SoundManage::SoundManage(){
lowState = highState = true;
beepSoundLow = new QSoundEffect();
beepSoundLow->setSource(QUrl("qrc:/audio/audio/beep_low.wav"));
beepSoundHigh = new QSoundEffect();
beepSoundHigh->setSource(QUrl("qrc:/audio/audio/beep_high.wav"));
soundThread = new QThread();
soundThread->start();
beepSoundLow->moveToThread(soundThread);
beepSoundHigh->moveToThread(soundThread);
}
SoundManage::~SoundManage(){
soundThread->quit();
}
void SoundManage::SoundPlay(SOUND_TYPE type){
QTimer* timer = new QTimer();
timer->moveToThread(soundThread);
if(type == LOW){
if(lowState) timer->singleShot(0, beepSoundLow, SLOT(play()));
}
else {
if(highState) timer->singleShot(0, beepSoundHigh, SLOT(play()));
}
}
void SoundManage::ChangeLowState(bool state){
lowState = state;
}
void SoundManage::ChangeHighState(bool state){
highState = state;
}