-
Notifications
You must be signed in to change notification settings - Fork 3
/
codec.cpp
71 lines (61 loc) · 1.56 KB
/
codec.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
/*
* Copyright 2010 by Idiap Research Institute, http://www.idiap.ch
*
* See the file COPYING for the licence associated with this software.
*/
#include <tracter/SndFileSource.h>
#include <tracter/SndFileSink.h>
#include <tracter/Frame.h>
#include <tracter/FourierTransform.h>
#include <tracter/OverlapAdd.h>
using namespace Tracter;
/**
* Originally, perhaps only, a testbed for overlap add. The idea here
* is that the class copies audio to audio allowing the various
* conversions that the components allow.
*/
class Codec : public Tracter::Object
{
public:
Codec()
{
objectName("Codec");
// Source
SndFileSource *s = new SndFileSource();
Component<float>* p = s;
#if 1
Component<complex>* c = 0;
p = new Frame(p);
c = new FourierTransformR2C(p, "DFT");
p = new FourierTransformC2R(c, "IDFT");
p = new OverlapAdd(p);
#endif
mSink = new SndFileSink(p);
mSource = s;
}
virtual ~Codec() throw ()
{
// Delete the sink
delete mSink;
}
void All(int argc, char* argv[])
{
if (argc != 3)
throw Exception(
"argc != 3\n"
"usage: codec <infile> <outfile>\n"
"(and don't forget to set your environment variables!)\n"
);
verbose(0, "%s -> %s\n", argv[1], argv[2]);
mSource->open(argv[1]);
mSink->open(argv[2]);
}
private:
ISource* mSource;
SndFileSink* mSink;
};
int main(int argc, char* argv[])
{
Codec r;
r.All(argc, argv);
}