-
Notifications
You must be signed in to change notification settings - Fork 9
/
main.cc
40 lines (27 loc) · 1.01 KB
/
main.cc
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
#include <iostream>
#include <oyoung/soundstream.h>
#include <oyoung/soundplayer.h>
using namespace oyoung::audio;
int main(int argc, char *argv[])
{
const char *file = argc > 1 ? argv[1]: "/home/oyoung/Music/normal_fault.wav"; //"/usr/local/tmp/tts_in.wav";
auto wav = StreamCreator::createSoundStream(file);
if(wav) {
SoundPlayer player("default");
player.load(wav);
wav->open();
std::cout << "total seconds: " << wav->total() << std::endl;
std::cout << "sample rate: " << wav->sample_rate() << "Hz" << std::endl;
std::cout << "channels: " << wav->channels() << std::endl;
if(!player.start()) {
std::cerr << player.error_msg() << std::endl;
}
std::this_thread::sleep_for(std::chrono::milliseconds(10));
while(player.is_playing()) {
std::cout << player.currentSecond() << std::endl;
std::this_thread::sleep_for(std::chrono::seconds(1));
}
player.stop();
}
return 0;
}