File: impulseinterp.cpp

package info (click to toggle)
faust 2.14.4~repack2-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 276,136 kB
  • sloc: cpp: 231,578; ansic: 15,403; sh: 10,871; java: 6,917; objc: 4,085; makefile: 3,002; cs: 1,077; ruby: 951; python: 885; xml: 550; yacc: 516; lex: 233; lisp: 201
file content (148 lines) | stat: -rw-r--r-- 5,433 bytes parent folder | download
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148

#ifndef FAUSTFLOAT
#define FAUSTFLOAT double
#endif

#include "faust/dsp/interpreter-dsp.h"
#include "controlTools.h"

int main(int argc, char* argv[])
{
    interpreter_dsp_factory* factory = NULL;
    
    bool inpl = isopt(argv, "-inpl");
    int linenum = 0;
    int nbsamples = 60000;
    
    if (endsWith(argv[1], ".dsp")) {
        
        {
            int argc1 = argc - 2;
            const char* argv1[argc1];
            for (int i = 0; i < argc - 2;  i++) {
                argv1[i] = argv[i + 2];
            }
            
            // Test factory generated from compilation
            string error_msg;
            factory = createInterpreterDSPFactoryFromFile(argv[1], argc1, argv1, error_msg);
            
            if (!factory) {
                cerr << "ERROR in createInterpreterDSPFactory " << error_msg  << endl;
                exit(-1);
            }
            
            dsp* DSP = factory->createDSPInstance();
            if (!DSP) {
                cerr << "ERROR : createDSPInstance " << endl;
                exit(-1);
            }
            
            // print general informations
            printHeader(DSP, nbsamples);
            
            runDSP1(factory, argv[1], linenum, nbsamples/4);
            runDSP1(factory, argv[1], linenum, nbsamples/4, false, false, true);
            runPolyDSP1(factory, linenum, nbsamples/4, 4);
            runPolyDSP1(factory, linenum, nbsamples/4, 1);
            
            // print general informations
            printHeader(DSP, nbsamples);
            
            runDSP1(factory, argv[1], linenum, nbsamples/4, true);
            runDSP1(factory, argv[1], linenum, nbsamples/4, true, false, true);
            runPolyDSP1(factory, linenum, nbsamples/4, 4);
            runPolyDSP1(factory, linenum, nbsamples/4, 1);
            
            // print general informations
            printHeader(DSP, nbsamples);
            
            runDSP1(factory, argv[1], linenum, nbsamples/4, false, inpl);
            runDSP1(factory, argv[1], linenum, nbsamples/4, false, inpl, true);
            runPolyDSP1(factory, linenum, nbsamples/4, 4);
            runPolyDSP1(factory, linenum, nbsamples/4, 1);
        }
        
        {
            string error_msg;
            // Test writeInterpreterDSPFactoryToBitcodeFile/readInterpreterDSPFactoryFromBitcodeFile
            stringstream str; str << "/var/tmp/interp-factory" << factory << ".fbc";
            writeInterpreterDSPFactoryToBitcodeFile(factory, str.str());
            deleteInterpreterDSPFactory(static_cast<interpreter_dsp_factory*>(factory));
            factory = readInterpreterDSPFactoryFromBitcodeFile(str.str(), error_msg);
            
            if (!factory) {
                cerr << "ERROR in readInterpreterDSPFactoryFromBitcodeFile " << error_msg;
                exit(-1);
            }
            
            dsp* DSP = factory->createDSPInstance();
            if (!DSP) {
                cerr << "ERROR : createDSPInstance " << endl;
                exit(-1);
            }
            
            // print general informations
            printHeader(DSP, nbsamples);
            
            runDSP1(factory, argv[1], linenum, nbsamples/4);
            runDSP1(factory, argv[1], linenum, nbsamples/4, false, false, true);
            runPolyDSP1(factory, linenum, nbsamples/4, 4);
            runPolyDSP1(factory, linenum, nbsamples/4, 1);
        }
        
        {
            string error_msg;
            // Test writeInterpreterDSPFactoryToBitcode/readInterpreterDSPFactoryFromBitcode
            string factory_str = writeInterpreterDSPFactoryToBitcode(factory);
            deleteInterpreterDSPFactory(static_cast<interpreter_dsp_factory*>(factory));
            factory = readInterpreterDSPFactoryFromBitcode(factory_str, error_msg);
            
            if (!factory) {
                cerr << "ERROR in readInterpreterDSPFactoryFromBitcode " << error_msg;
                exit(-1);
            }
            
            dsp* DSP = factory->createDSPInstance();
            if (!DSP) {
                cerr << "ERROR : createDSPInstance " << endl;
                exit(-1);
            }
            
            // print general informations
            printHeader(DSP, nbsamples);
            
            runDSP1(factory, argv[1], linenum, nbsamples/4);
            runDSP1(factory, argv[1], linenum, nbsamples/4, false, false, false);
            runPolyDSP1(factory, linenum, nbsamples/4, 4);
            runPolyDSP1(factory, linenum, nbsamples/4, 1);
        }
     
    } else {
        
        // Test factory generated from file
        string error_msg;
        factory = readInterpreterDSPFactoryFromBitcodeFile(argv[1], error_msg);
        
        if (!factory) {
            cerr << "ERROR in readInterpreterDSPFactoryFromBitcodeFile " << error_msg;
            exit(-1);
        }
        
        dsp* DSP = factory->createDSPInstance();
        if (!DSP) {
            cerr << "ERROR : createDSPInstance " << endl;
            exit(-1);
        }
        
        // print general informations
        printHeader(DSP, nbsamples);
        
        runDSP1(factory, argv[1], linenum, nbsamples/4);
        runDSP1(factory, argv[1], linenum, nbsamples/4, false, false, true);
        runPolyDSP1(factory, linenum, nbsamples/4, 4);
        runPolyDSP1(factory, linenum, nbsamples/4, 1);
    }
  
    return 0;
}