fork download
  1. template<typename T>
  2. //audio data frame managing audio samples
  3. class frame {};
  4.  
  5. /*
  6.  * t1, t2... tn classes are very different in the way they are processing audio
  7.  * data so can't have the same base type but they have some common functions such
  8.  * as process and reset.
  9.  */
  10. template<typename T>
  11. class test1 {
  12. public:
  13. void reset() {}
  14. int process(const frame<T>& in, frame<T>& out) {}
  15. };
  16.  
  17. template<typename T>
  18. class test2 {
  19. public:
  20. void reset() {}
  21. int process(const frame<T>& in, frame<T>& out);
  22. };
  23.  
  24. template<typename T>
  25. class test3 {
  26. public:
  27. void reset() {}
  28. int process(const frame<T>& in, frame<T>& out);
  29. };
  30.  
  31. int main()
  32. {
  33. test1<int> *t1 = new test1<int>();
  34. test2<int> *t2 = new test2<int>();
  35. test3<int> *t3 = new test3<int>();
  36. frame<int> iFrame;
  37. frame<int> oFrame;
  38.  
  39. /* some code here to initialize audio processing blocks */
  40. //snip
  41.  
  42. /*
  43. * order of audio processing is important here.
  44. * Is there any way to avoid writing below code
  45. * for every processing block that gets added in
  46. * future in c++11 perhaps??
  47. */
  48. if (t1) {
  49. t1->process(iFrame, oFrame);
  50. iFrame = oFrame;
  51. }
  52. if (t2) {
  53. t2->reset();
  54. t2->process(iFrame, oFrame);
  55. iFrame = oFrame;
  56. }
  57. if (t3) {
  58. t3->process(iFrame, oFrame);
  59. iFrame = oFrame;
  60. }
  61. }
Success #stdin #stdout 0s 4388KB
stdin
Standard input is empty
stdout
Standard output is empty