In my audio processing code (audio processor) I have something like below code. I am trying to avoid this below repetitive code. Wondering if there is any better way to write this code?
Code is just an illustration to understand the problem: I have several audio processing blocks where the audio of one block is passed as input to second block and so on until the final processed output. There are 4 major components of this 'blocks': Initialization, processing, reset, and de-initilzation.
/* some code here to initialize audio processing blocks */
//snip
/*
* order of audio processing is important here.
* Is there any way to avoid writing below code
* for every processing block that gets added in
* future in c++11 perhaps??
*/
if (t1) {
t1->process(iFrame, oFrame);
iFrame = oFrame;
}
if (t2) {
t2->reset();
t2->process(iFrame, oFrame);
iFrame = oFrame;
}
if (t3) {
t3->process(iFrame, oFrame);
iFrame = oFrame;
}
/*
* if in future we want this way t1 - > t3 - > t2 then code change is required,
* is there any way to avoid this code change
*/
Please suggest right way of dealing with this.
Aucun commentaire:
Enregistrer un commentaire