-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrws2wav.cpp
More file actions
59 lines (50 loc) · 1.11 KB
/
rws2wav.cpp
File metadata and controls
59 lines (50 loc) · 1.11 KB
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
#include "rwexception.h"
#include "rwstream.h"
#include <cstdio>
//-----------------------------------------------------------------------------
void usage()
{
}
//-----------------------------------------------------------------------------
void convert(std::string const filename)
{
try
{
auto is = rws::stream{filename};
auto base_name = filename;
auto ep = base_name.rfind('.');
base_name = base_name.substr(0, ep);
for (auto const& t : is.tracks())
{
// get name for output file
std::ostringstream ss;
ss << base_name << "-tr" << t->id() << ".wav";
// write track
try
{
t->write(ss.str());
}
catch (rws::exception const& e)
{
fprintf(stderr, "%s\n", e.what());
}
}
}
catch (rws::exception const& e)
{
fprintf(stderr, "%s\n", e.what());
}
}
//-----------------------------------------------------------------------------
int main(int argc, char** argv)
{
if (argc < 1)
{
usage();
return 1;
}
// Iterate over input files
for (int i = 1; i < argc; ++i)
convert(argv[i]);
return 0;
}