MCPcopy Create free account
hub / github.com/Yaafe/Yaafe / processFile

Method processFile

src_cpp/yaafe-core/AudioFileProcessor.cpp:69–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67 }
68
69 int AudioFileProcessor::processFile(Engine& engine, const std::string& filename)
70 {
71 {
72 // check engine inputs
73 vector<string> inputs = engine.getInputs();
74 if (inputs.size()!=1) {
75 cerr << "ERROR: dataflow must have exactly 1 root node" << endl;
76 return -1;
77 }
78 if (inputs[0]!="audio") {
79 cerr << "ERROR: root node is not 'audio' node !" << endl;
80 return -2;
81 }
82 }
83
84 int exitCode = 0;
85 ComponentFactory* factory = ComponentFactory::instance();
86 Component* reader = NULL;
87 std::vector<pair<string,Component*> > writers;
88
89 cerr << "process file " << filename << endl;
90 clock_t end;
91 clock_t start = clock();
92
93 // reset engine state
94 engine.reset();
95
96 // determine audio file format and select appropriate reader
97 std::string readerComponent = "";
98 {
99 std::string lowerFilename = filename;
100 transform(lowerFilename.begin(),lowerFilename.end(),lowerFilename.begin(),::tolower);
101 if (hasEnding(lowerFilename,"mp3")) {
102 if (!factory->exists("MP3FileReader")) {
103 cerr << "ERROR: cannot read mp3 file ! please compile yaafe with mpg123 support" << endl;
104 return -4;
105 }
106 readerComponent = "MP3FileReader";
107 } else {
108 if (!factory->exists("AudioFileReader")) {
109 cerr << "ERROR: please compile yaafe with libsndfile support" << endl;
110 return -3;
111 }
112 readerComponent = "AudioFileReader";
113 }
114 }
115
116 // initialize reader
117 ParameterMap readerParams = engine.getInputParams("audio");
118 readerParams["File"] = filename;
119 reader = factory->createComponent(readerComponent);
120 Ports<StreamInfo> inports;
121 if (!reader->init(readerParams,inports)) {
122 cerr << "ERROR: cannot initialize reader " << readerComponent << " for file " << filename << endl;
123 exitCode = -6; goto exit;
124 }
125
126 // bind audio input

Callers 4

mainFunction · 0.95
mainFunction · 0.45
processFileFunction · 0.45

Calls 15

hasEndingFunction · 0.85
existsMethod · 0.80
getInputParamsMethod · 0.80
createComponentMethod · 0.80
bindInputMethod · 0.80
addMethod · 0.80
getOutputMethod · 0.80
createWriterMethod · 0.80
getOutputParamsMethod · 0.80
bindOutputMethod · 0.80
detachInputMethod · 0.80
detachOutputMethod · 0.80

Tested by

no test coverage detected